Coverage Report

Created: 2018-09-25 14:53

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