Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/gmp/GMPContentParent.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 GMPContentParent_h_
7
#define GMPContentParent_h_
8
9
#include "mozilla/gmp/PGMPContentParent.h"
10
#include "GMPSharedMemManager.h"
11
#include "nsISupportsImpl.h"
12
13
namespace mozilla {
14
namespace gmp {
15
16
class GMPParent;
17
class GMPVideoDecoderParent;
18
class GMPVideoEncoderParent;
19
class ChromiumCDMParent;
20
21
class GMPContentParent final : public PGMPContentParent,
22
                               public GMPSharedMem
23
{
24
public:
25
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPContentParent)
26
27
  explicit GMPContentParent(GMPParent* aParent = nullptr);
28
29
  nsresult GetGMPVideoDecoder(GMPVideoDecoderParent** aGMPVD,
30
                              uint32_t aDecryptorId);
31
  void VideoDecoderDestroyed(GMPVideoDecoderParent* aDecoder);
32
33
  nsresult GetGMPVideoEncoder(GMPVideoEncoderParent** aGMPVE);
34
  void VideoEncoderDestroyed(GMPVideoEncoderParent* aEncoder);
35
36
  already_AddRefed<ChromiumCDMParent> GetChromiumCDM();
37
  void ChromiumCDMDestroyed(ChromiumCDMParent* aCDM);
38
39
  nsCOMPtr<nsISerialEventTarget> GMPEventTarget();
40
41
  // GMPSharedMem
42
  void CheckThread() override;
43
44
  void SetDisplayName(const nsCString& aDisplayName)
45
0
  {
46
0
    mDisplayName = aDisplayName;
47
0
  }
48
  const nsCString& GetDisplayName()
49
0
  {
50
0
    return mDisplayName;
51
0
  }
52
  void SetPluginId(const uint32_t aPluginId)
53
0
  {
54
0
    mPluginId = aPluginId;
55
0
  }
56
  uint32_t GetPluginId() const
57
0
  {
58
0
    return mPluginId;
59
0
  }
60
61
  class CloseBlocker {
62
  public:
63
    NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CloseBlocker)
64
65
    explicit CloseBlocker(GMPContentParent* aParent)
66
      : mParent(aParent)
67
0
    {
68
0
      mParent->AddCloseBlocker();
69
0
    }
70
    RefPtr<GMPContentParent> mParent;
71
  private:
72
0
    ~CloseBlocker() {
73
0
      mParent->RemoveCloseBlocker();
74
0
    }
75
  };
76
77
private:
78
79
  void AddCloseBlocker();
80
  void RemoveCloseBlocker();
81
82
  ~GMPContentParent();
83
84
  void ActorDestroy(ActorDestroyReason aWhy) override;
85
86
  PGMPVideoDecoderParent* AllocPGMPVideoDecoderParent(const uint32_t& aDecryptorId) override;
87
  bool DeallocPGMPVideoDecoderParent(PGMPVideoDecoderParent* aActor) override;
88
89
  PGMPVideoEncoderParent* AllocPGMPVideoEncoderParent() override;
90
  bool DeallocPGMPVideoEncoderParent(PGMPVideoEncoderParent* aActor) override;
91
92
  PChromiumCDMParent* AllocPChromiumCDMParent() override;
93
  bool DeallocPChromiumCDMParent(PChromiumCDMParent* aActor) override;
94
95
  void CloseIfUnused();
96
  // Needed because NewRunnableMethod tried to use the class that the method
97
  // lives on to store the receiver, but PGMPContentParent isn't refcounted.
98
  void Close()
99
0
  {
100
0
    PGMPContentParent::Close();
101
0
  }
102
103
  nsTArray<RefPtr<GMPVideoDecoderParent>> mVideoDecoders;
104
  nsTArray<RefPtr<GMPVideoEncoderParent>> mVideoEncoders;
105
  nsTArray<RefPtr<ChromiumCDMParent>> mChromiumCDMs;
106
  nsCOMPtr<nsISerialEventTarget> mGMPEventTarget;
107
  RefPtr<GMPParent> mParent;
108
  nsCString mDisplayName;
109
  uint32_t mPluginId;
110
  uint32_t mCloseBlockerCount = 0;
111
};
112
113
} // namespace gmp
114
} // namespace mozilla
115
116
#endif // GMPParent_h_