Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef GMPDecryptorParent_h_
7 : #define GMPDecryptorParent_h_
8 :
9 : #include "mozilla/gmp/PGMPDecryptorParent.h"
10 : #include "mozilla/RefPtr.h"
11 : #include "gmp-decryption.h"
12 : #include "GMPDecryptorProxy.h"
13 : #include "GMPCrashHelperHolder.h"
14 :
15 : namespace mozilla {
16 :
17 : class CryptoSample;
18 :
19 : namespace gmp {
20 :
21 : class GMPContentParent;
22 :
23 : class GMPDecryptorParent final : public GMPDecryptorProxy
24 : , public PGMPDecryptorParent
25 : , public GMPCrashHelperHolder
26 : {
27 : public:
28 0 : NS_INLINE_DECL_REFCOUNTING(GMPDecryptorParent)
29 :
30 : explicit GMPDecryptorParent(GMPContentParent *aPlugin);
31 :
32 : // GMPDecryptorProxy
33 :
34 0 : uint32_t GetPluginId() const override { return mPluginId; }
35 :
36 : nsresult Init(GMPDecryptorProxyCallback* aCallback,
37 : bool aDistinctiveIdentifierRequired,
38 : bool aPersistentStateRequired) override;
39 :
40 : void CreateSession(uint32_t aCreateSessionToken,
41 : uint32_t aPromiseId,
42 : const nsCString& aInitDataType,
43 : const nsTArray<uint8_t>& aInitData,
44 : GMPSessionType aSessionType) override;
45 :
46 : void LoadSession(uint32_t aPromiseId,
47 : const nsCString& aSessionId) override;
48 :
49 : void UpdateSession(uint32_t aPromiseId,
50 : const nsCString& aSessionId,
51 : const nsTArray<uint8_t>& aResponse) override;
52 :
53 : void CloseSession(uint32_t aPromiseId,
54 : const nsCString& aSessionId) override;
55 :
56 : void RemoveSession(uint32_t aPromiseId,
57 : const nsCString& aSessionId) override;
58 :
59 : void SetServerCertificate(uint32_t aPromiseId,
60 : const nsTArray<uint8_t>& aServerCert) override;
61 :
62 : void Decrypt(uint32_t aId,
63 : const CryptoSample& aCrypto,
64 : const nsTArray<uint8_t>& aBuffer) override;
65 :
66 : void Close() override;
67 :
68 : void Shutdown();
69 :
70 : private:
71 : ~GMPDecryptorParent();
72 :
73 : // PGMPDecryptorParent
74 :
75 : mozilla::ipc::IPCResult RecvSetDecryptorId(const uint32_t& aId) override;
76 :
77 : mozilla::ipc::IPCResult RecvSetSessionId(const uint32_t& aCreateSessionToken,
78 : const nsCString& aSessionId) override;
79 :
80 : mozilla::ipc::IPCResult RecvResolveLoadSessionPromise(const uint32_t& aPromiseId,
81 : const bool& aSuccess) override;
82 :
83 : mozilla::ipc::IPCResult RecvResolvePromise(const uint32_t& aPromiseId) override;
84 :
85 : mozilla::ipc::IPCResult RecvRejectPromise(const uint32_t& aPromiseId,
86 : const GMPDOMException& aException,
87 : const nsCString& aMessage) override;
88 :
89 : mozilla::ipc::IPCResult RecvSessionMessage(const nsCString& aSessionId,
90 : const GMPSessionMessageType& aMessageType,
91 : nsTArray<uint8_t>&& aMessage) override;
92 :
93 : mozilla::ipc::IPCResult RecvExpirationChange(const nsCString& aSessionId,
94 : const double& aExpiryTime) override;
95 :
96 : mozilla::ipc::IPCResult RecvSessionClosed(const nsCString& aSessionId) override;
97 :
98 : mozilla::ipc::IPCResult RecvSessionError(const nsCString& aSessionId,
99 : const GMPDOMException& aException,
100 : const uint32_t& aSystemCode,
101 : const nsCString& aMessage) override;
102 :
103 : mozilla::ipc::IPCResult RecvDecrypted(const uint32_t& aId,
104 : const GMPErr& aErr,
105 : InfallibleTArray<uint8_t>&& aBuffer) override;
106 :
107 : mozilla::ipc::IPCResult RecvBatchedKeyStatusChanged(const nsCString& aSessionId,
108 : InfallibleTArray<GMPKeyInformation>&& aKeyInfos) override;
109 :
110 : mozilla::ipc::IPCResult RecvShutdown() override;
111 :
112 : void ActorDestroy(ActorDestroyReason aWhy) override;
113 : mozilla::ipc::IPCResult Recv__delete__() override;
114 :
115 : bool mIsOpen;
116 : bool mShuttingDown;
117 : bool mActorDestroyed;
118 : RefPtr<GMPContentParent> mPlugin;
119 : uint32_t mPluginId;
120 : GMPDecryptorProxyCallback* mCallback;
121 : #ifdef DEBUG
122 : nsCOMPtr<nsISerialEventTarget> const mGMPEventTarget;
123 : #endif
124 : };
125 :
126 : } // namespace gmp
127 : } // namespace mozilla
128 :
129 : #endif // GMPDecryptorChild_h_
|