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 GMPDecryptorChild_h_
7 : #define GMPDecryptorChild_h_
8 :
9 : #include "mozilla/gmp/PGMPDecryptorChild.h"
10 : #include "gmp-decryption.h"
11 : #include "mozilla/gmp/GMPTypes.h"
12 : #include "GMPEncryptedBufferDataImpl.h"
13 : #include <string>
14 :
15 : namespace mozilla {
16 : namespace gmp {
17 :
18 : class GMPContentChild;
19 :
20 : class GMPDecryptorChild : public GMPDecryptorCallback
21 : , public PGMPDecryptorChild
22 : {
23 : public:
24 0 : NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPDecryptorChild);
25 :
26 : explicit GMPDecryptorChild(GMPContentChild* aPlugin);
27 :
28 : void Init(GMPDecryptor* aSession);
29 :
30 : // GMPDecryptorCallback
31 : void SetSessionId(uint32_t aCreateSessionToken,
32 : const char* aSessionId,
33 : uint32_t aSessionIdLength) override;
34 : void ResolveLoadSessionPromise(uint32_t aPromiseId,
35 : bool aSuccess) override;
36 : void ResolvePromise(uint32_t aPromiseId) override;
37 :
38 : void RejectPromise(uint32_t aPromiseId,
39 : GMPDOMException aException,
40 : const char* aMessage,
41 : uint32_t aMessageLength) override;
42 :
43 : void SessionMessage(const char* aSessionId,
44 : uint32_t aSessionIdLength,
45 : GMPSessionMessageType aMessageType,
46 : const uint8_t* aMessage,
47 : uint32_t aMessageLength) override;
48 :
49 : void ExpirationChange(const char* aSessionId,
50 : uint32_t aSessionIdLength,
51 : GMPTimestamp aExpiryTime) override;
52 :
53 : void SessionClosed(const char* aSessionId,
54 : uint32_t aSessionIdLength) override;
55 :
56 : void SessionError(const char* aSessionId,
57 : uint32_t aSessionIdLength,
58 : GMPDOMException aException,
59 : uint32_t aSystemCode,
60 : const char* aMessage,
61 : uint32_t aMessageLength) override;
62 :
63 : void KeyStatusChanged(const char* aSessionId,
64 : uint32_t aSessionIdLength,
65 : const uint8_t* aKeyId,
66 : uint32_t aKeyIdLength,
67 : GMPMediaKeyStatus aStatus) override;
68 :
69 : void SetCapabilities(uint64_t aCaps) override;
70 :
71 : void Decrypted(GMPBuffer* aBuffer, GMPErr aResult) override;
72 :
73 : void BatchedKeyStatusChanged(const char* aSessionId,
74 : uint32_t aSessionIdLength,
75 : const GMPMediaKeyInfo* aKeyInfos,
76 : uint32_t aKeyInfosLength) override;
77 :
78 0 : uint32_t DecryptorId() const { return mDecryptorId; }
79 : private:
80 : ~GMPDecryptorChild();
81 :
82 : // GMPDecryptorChild
83 : mozilla::ipc::IPCResult RecvInit(const bool& aDistinctiveIdentifierRequired,
84 : const bool& aPersistentStateRequired) override;
85 :
86 : mozilla::ipc::IPCResult RecvCreateSession(const uint32_t& aCreateSessionToken,
87 : const uint32_t& aPromiseId,
88 : const nsCString& aInitDataType,
89 : InfallibleTArray<uint8_t>&& aInitData,
90 : const GMPSessionType& aSessionType) override;
91 :
92 : mozilla::ipc::IPCResult RecvLoadSession(const uint32_t& aPromiseId,
93 : const nsCString& aSessionId) override;
94 :
95 : mozilla::ipc::IPCResult RecvUpdateSession(const uint32_t& aPromiseId,
96 : const nsCString& aSessionId,
97 : InfallibleTArray<uint8_t>&& aResponse) override;
98 :
99 : mozilla::ipc::IPCResult RecvCloseSession(const uint32_t& aPromiseId,
100 : const nsCString& aSessionId) override;
101 :
102 : mozilla::ipc::IPCResult RecvRemoveSession(const uint32_t& aPromiseId,
103 : const nsCString& aSessionId) override;
104 :
105 : mozilla::ipc::IPCResult RecvDecrypt(const uint32_t& aId,
106 : InfallibleTArray<uint8_t>&& aBuffer,
107 : const GMPDecryptionData& aMetadata) override;
108 :
109 : // Resolve/reject promise on completion.
110 : mozilla::ipc::IPCResult RecvSetServerCertificate(const uint32_t& aPromiseId,
111 : InfallibleTArray<uint8_t>&& aServerCert) override;
112 :
113 : mozilla::ipc::IPCResult RecvDecryptingComplete() override;
114 :
115 : template <typename MethodType, typename... ParamType>
116 : void CallMethod(MethodType, ParamType&&...);
117 :
118 : template<typename MethodType, typename... ParamType>
119 : void CallOnGMPThread(MethodType, ParamType&&...);
120 :
121 : // GMP's GMPDecryptor implementation.
122 : // Only call into this on the (GMP process) main thread.
123 : GMPDecryptor* mSession;
124 : GMPContentChild* mPlugin;
125 :
126 : const uint32_t mDecryptorId;
127 : };
128 :
129 : } // namespace gmp
130 : } // namespace mozilla
131 :
132 : #endif // GMPDecryptorChild_h_
|