From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- dom/media/gmp/GMPStorageChild.h | 94 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 dom/media/gmp/GMPStorageChild.h (limited to 'dom/media/gmp/GMPStorageChild.h') diff --git a/dom/media/gmp/GMPStorageChild.h b/dom/media/gmp/GMPStorageChild.h new file mode 100644 index 0000000000..97c61a5007 --- /dev/null +++ b/dom/media/gmp/GMPStorageChild.h @@ -0,0 +1,94 @@ +/* -*- 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" +#include "gmp-platform.h" + +#include + +namespace mozilla::gmp { + +class GMPChild; +class GMPStorageChild; + +class GMPRecordImpl : public GMPRecord { + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPRecordImpl) + + GMPRecordImpl(GMPStorageChild* aOwner, const nsCString& aName, + GMPRecordClient* aClient); + + // GMPRecord. + GMPErr Open() override; + GMPErr Read() override; + GMPErr Write(const uint8_t* aData, uint32_t aDataSize) override; + GMPErr Close() override; + + 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() = default; + const nsCString mName; + GMPRecordClient* const mClient; + GMPStorageChild* const mOwner; +}; + +class GMPStorageChild : public PGMPStorageChild { + friend class PGMPStorageChild; + + public: + NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPStorageChild) + + explicit GMPStorageChild(GMPChild* aPlugin); + + 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); + + GMPErr Close(const nsCString& aRecordName); + + private: + bool HasRecord(const nsCString& aRecordName); + already_AddRefed GetRecord(const nsCString& aRecordName); + + protected: + ~GMPStorageChild() = default; + + // PGMPStorageChild + mozilla::ipc::IPCResult RecvOpenComplete(const nsCString& aRecordName, + const GMPErr& aStatus); + mozilla::ipc::IPCResult RecvReadComplete(const nsCString& aRecordName, + const GMPErr& aStatus, + nsTArray&& aBytes); + mozilla::ipc::IPCResult RecvWriteComplete(const nsCString& aRecordName, + const GMPErr& aStatus); + mozilla::ipc::IPCResult RecvShutdown(); + + private: + Monitor mMonitor MOZ_UNANNOTATED; + nsRefPtrHashtable mRecords; + GMPChild* mPlugin; + bool mShutdown; +}; + +} // namespace mozilla::gmp + +#endif // GMPStorageChild_h_ -- cgit v1.2.3