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 GMPServiceChild_h_
7 : #define GMPServiceChild_h_
8 :
9 : #include "GMPService.h"
10 : #include "base/process.h"
11 : #include "mozilla/ipc/Transport.h"
12 : #include "mozilla/gmp/PGMPServiceChild.h"
13 : #include "nsRefPtrHashtable.h"
14 : #include "mozilla/dom/ContentChild.h"
15 :
16 : namespace mozilla {
17 : namespace gmp {
18 :
19 : class GMPContentParent;
20 : class GMPServiceChild;
21 :
22 0 : class GeckoMediaPluginServiceChild : public GeckoMediaPluginService
23 : {
24 : friend class GMPServiceChild;
25 :
26 : public:
27 : static already_AddRefed<GeckoMediaPluginServiceChild> GetSingleton();
28 :
29 : NS_IMETHOD HasPluginForAPI(const nsACString& aAPI,
30 : nsTArray<nsCString>* aTags,
31 : bool *aRetVal) override;
32 : NS_IMETHOD GetNodeId(const nsAString& aOrigin,
33 : const nsAString& aTopLevelOrigin,
34 : const nsAString& aGMPName,
35 : UniquePtr<GetNodeIdCallback>&& aCallback) override;
36 :
37 : NS_DECL_NSIOBSERVER
38 :
39 : void SetServiceChild(UniquePtr<GMPServiceChild>&& aServiceChild);
40 :
41 : void RemoveGMPContentParent(GMPContentParent* aGMPContentParent);
42 :
43 : static void UpdateGMPCapabilities(nsTArray<mozilla::dom::GMPCapabilityData>&& aCapabilities);
44 :
45 : void BeginShutdown();
46 :
47 : protected:
48 0 : void InitializePlugins(AbstractThread*) override
49 : {
50 : // Nothing to do here.
51 0 : }
52 :
53 : virtual RefPtr<GetGMPContentParentPromise> GetContentParent(
54 : GMPCrashHelper* aHelper,
55 : const nsACString& aNodeIdString,
56 : const nsCString& aAPI,
57 : const nsTArray<nsCString>& aTags) override;
58 :
59 : RefPtr<GetGMPContentParentPromise> GetContentParent(
60 : GMPCrashHelper* aHelper,
61 : const NodeId& aNodeId,
62 : const nsCString& aAPI,
63 : const nsTArray<nsCString>& aTags) override;
64 :
65 : private:
66 : friend class OpenPGMPServiceChild;
67 :
68 : typedef MozPromise<GMPServiceChild*, nsresult, /* IsExclusive = */ true> GetServiceChildPromise;
69 : RefPtr<GetServiceChildPromise> GetServiceChild();
70 :
71 : nsTArray<MozPromiseHolder<GetServiceChildPromise>> mGetServiceChildPromises;
72 : UniquePtr<GMPServiceChild> mServiceChild;
73 : };
74 :
75 : class GMPServiceChild : public PGMPServiceChild
76 : {
77 : public:
78 : explicit GMPServiceChild();
79 : virtual ~GMPServiceChild();
80 :
81 : already_AddRefed<GMPContentParent> GetBridgedGMPContentParent(ProcessId aOtherPid,
82 : ipc::Endpoint<PGMPContentParent>&& endpoint);
83 :
84 : void RemoveGMPContentParent(GMPContentParent* aGMPContentParent);
85 :
86 : void GetAlreadyBridgedTo(nsTArray<ProcessId>& aAlreadyBridgedTo);
87 :
88 : static bool Create(Endpoint<PGMPServiceChild>&& aGMPService);
89 :
90 : ipc::IPCResult RecvBeginShutdown() override;
91 :
92 : bool HaveContentParents() const;
93 :
94 : private:
95 : nsRefPtrHashtable<nsUint64HashKey, GMPContentParent> mContentParents;
96 : };
97 :
98 : } // namespace gmp
99 : } // namespace mozilla
100 :
101 : #endif // GMPServiceChild_h_
|