2014-08-19 12:56:33 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef GMPStorageChild_h_
|
|
|
|
#define GMPStorageChild_h_
|
|
|
|
|
|
|
|
#include "mozilla/gmp/PGMPStorageChild.h"
|
|
|
|
#include "gmp-storage.h"
|
|
|
|
#include "nsTHashtable.h"
|
|
|
|
#include "nsRefPtrHashtable.h"
|
2014-11-21 02:25:12 +03:00
|
|
|
#include "gmp-platform.h"
|
|
|
|
|
|
|
|
#include <queue>
|
2014-08-19 12:56:33 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPChild;
|
|
|
|
class GMPStorageChild;
|
|
|
|
|
|
|
|
class GMPRecordImpl : public GMPRecord
|
|
|
|
{
|
|
|
|
public:
|
2014-12-04 23:34:00 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPRecordImpl)
|
2014-08-19 12:56:33 +04:00
|
|
|
|
|
|
|
GMPRecordImpl(GMPStorageChild* aOwner,
|
|
|
|
const nsCString& aName,
|
|
|
|
GMPRecordClient* aClient);
|
|
|
|
|
|
|
|
// GMPRecord.
|
2016-01-18 06:40:49 +03:00
|
|
|
GMPErr Open() override;
|
|
|
|
GMPErr Read() override;
|
|
|
|
GMPErr Write(const uint8_t* aData,
|
|
|
|
uint32_t aDataSize) override;
|
|
|
|
GMPErr Close() override;
|
2014-08-19 12:56:33 +04:00
|
|
|
|
|
|
|
const nsCString& Name() const { return mName; }
|
|
|
|
|
|
|
|
void OpenComplete(GMPErr aStatus);
|
|
|
|
void ReadComplete(GMPErr aStatus, const uint8_t* aBytes, uint32_t aLength);
|
|
|
|
void WriteComplete(GMPErr aStatus);
|
|
|
|
|
|
|
|
private:
|
|
|
|
~GMPRecordImpl() {}
|
|
|
|
const nsCString mName;
|
|
|
|
GMPRecordClient* const mClient;
|
|
|
|
GMPStorageChild* const mOwner;
|
|
|
|
};
|
|
|
|
|
|
|
|
class GMPStorageChild : public PGMPStorageChild
|
|
|
|
{
|
|
|
|
public:
|
2014-12-04 23:34:00 +03:00
|
|
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPStorageChild)
|
2014-08-19 12:56:33 +04:00
|
|
|
|
2014-09-01 07:50:23 +04:00
|
|
|
explicit GMPStorageChild(GMPChild* aPlugin);
|
2014-08-19 12:56:33 +04:00
|
|
|
|
|
|
|
GMPErr CreateRecord(const nsCString& aRecordName,
|
|
|
|
GMPRecord** aOutRecord,
|
|
|
|
GMPRecordClient* aClient);
|
|
|
|
|
|
|
|
GMPErr Open(GMPRecordImpl* aRecord);
|
|
|
|
|
|
|
|
GMPErr Read(GMPRecordImpl* aRecord);
|
|
|
|
|
|
|
|
GMPErr Write(GMPRecordImpl* aRecord,
|
|
|
|
const uint8_t* aData,
|
|
|
|
uint32_t aDataSize);
|
|
|
|
|
2014-11-28 02:34:00 +03:00
|
|
|
GMPErr Close(const nsCString& aRecordName);
|
2014-08-19 12:56:33 +04:00
|
|
|
|
2014-11-28 02:34:00 +03:00
|
|
|
private:
|
|
|
|
bool HasRecord(const nsCString& aRecordName);
|
|
|
|
already_AddRefed<GMPRecordImpl> GetRecord(const nsCString& aRecordName);
|
|
|
|
|
2014-08-19 12:56:33 +04:00
|
|
|
protected:
|
|
|
|
~GMPStorageChild() {}
|
|
|
|
|
|
|
|
// PGMPStorageChild
|
2016-11-15 06:26:00 +03:00
|
|
|
mozilla::ipc::IPCResult RecvOpenComplete(const nsCString& aRecordName,
|
|
|
|
const GMPErr& aStatus) override;
|
|
|
|
mozilla::ipc::IPCResult RecvReadComplete(const nsCString& aRecordName,
|
|
|
|
const GMPErr& aStatus,
|
|
|
|
InfallibleTArray<uint8_t>&& aBytes) override;
|
|
|
|
mozilla::ipc::IPCResult RecvWriteComplete(const nsCString& aRecordName,
|
|
|
|
const GMPErr& aStatus) override;
|
|
|
|
mozilla::ipc::IPCResult RecvShutdown() override;
|
2014-08-19 12:56:33 +04:00
|
|
|
|
|
|
|
private:
|
2014-11-28 02:34:00 +03:00
|
|
|
Monitor mMonitor;
|
2014-08-19 12:56:33 +04:00
|
|
|
nsRefPtrHashtable<nsCStringHashKey, GMPRecordImpl> mRecords;
|
|
|
|
GMPChild* mPlugin;
|
|
|
|
bool mShutdown;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPStorageChild_h_
|