2014-08-19 01:56:33 -07: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 GMPStorageParent_h_
|
|
|
|
#define GMPStorageParent_h_
|
|
|
|
|
|
|
|
#include "mozilla/gmp/PGMPStorageParent.h"
|
|
|
|
#include "gmp-storage.h"
|
2014-10-12 15:53:44 -07:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2014-08-19 01:56:33 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gmp {
|
|
|
|
|
|
|
|
class GMPParent;
|
|
|
|
|
2014-10-12 15:53:44 -07:00
|
|
|
class GMPStorage {
|
|
|
|
public:
|
|
|
|
virtual ~GMPStorage() {}
|
|
|
|
|
|
|
|
virtual GMPErr Open(const nsCString& aRecordName) = 0;
|
|
|
|
virtual bool IsOpen(const nsCString& aRecordName) = 0;
|
|
|
|
virtual GMPErr Read(const nsCString& aRecordName,
|
|
|
|
nsTArray<uint8_t>& aOutBytes) = 0;
|
|
|
|
virtual GMPErr Write(const nsCString& aRecordName,
|
|
|
|
const nsTArray<uint8_t>& aBytes) = 0;
|
2014-11-20 15:25:12 -08:00
|
|
|
virtual GMPErr GetRecordNames(nsTArray<nsCString>& aOutRecordNames) = 0;
|
2014-10-12 15:53:44 -07:00
|
|
|
virtual void Close(const nsCString& aRecordName) = 0;
|
|
|
|
};
|
|
|
|
|
2014-08-19 01:56:33 -07:00
|
|
|
class GMPStorageParent : public PGMPStorageParent {
|
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_REFCOUNTING(GMPStorageParent)
|
2014-10-12 15:53:44 -07:00
|
|
|
GMPStorageParent(const nsCString& aNodeId,
|
|
|
|
GMPParent* aPlugin);
|
2014-08-19 01:56:33 -07:00
|
|
|
|
2014-10-12 15:53:44 -07:00
|
|
|
nsresult Init();
|
2014-08-19 01:56:33 -07:00
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool RecvOpen(const nsCString& aRecordName) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvRead(const nsCString& aRecordName) MOZ_OVERRIDE;
|
|
|
|
virtual bool RecvWrite(const nsCString& aRecordName,
|
2015-01-16 11:58:52 -08:00
|
|
|
InfallibleTArray<uint8_t>&& aBytes) MOZ_OVERRIDE;
|
2014-11-20 15:25:12 -08:00
|
|
|
virtual bool RecvGetRecordNames() MOZ_OVERRIDE;
|
2014-08-19 01:56:33 -07:00
|
|
|
virtual bool RecvClose(const nsCString& aRecordName) MOZ_OVERRIDE;
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
|
|
|
|
|
|
|
|
private:
|
|
|
|
~GMPStorageParent() {}
|
|
|
|
|
2014-10-12 15:53:44 -07:00
|
|
|
UniquePtr<GMPStorage> mStorage;
|
|
|
|
|
|
|
|
const nsCString mNodeId;
|
2014-08-19 01:56:33 -07:00
|
|
|
nsRefPtr<GMPParent> mPlugin;
|
|
|
|
bool mShutdown;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace gmp
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // GMPStorageParent_h_
|