Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/gmp/GMPStorageChild.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 GMPStorageChild_h_
7
#define GMPStorageChild_h_
8
9
#include "mozilla/gmp/PGMPStorageChild.h"
10
#include "gmp-storage.h"
11
#include "nsTHashtable.h"
12
#include "nsRefPtrHashtable.h"
13
#include "gmp-platform.h"
14
15
#include <queue>
16
17
namespace mozilla {
18
namespace gmp {
19
20
class GMPChild;
21
class GMPStorageChild;
22
23
class GMPRecordImpl : public GMPRecord
24
{
25
public:
26
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPRecordImpl)
27
28
  GMPRecordImpl(GMPStorageChild* aOwner,
29
                const nsCString& aName,
30
                GMPRecordClient* aClient);
31
32
  // GMPRecord.
33
  GMPErr Open() override;
34
  GMPErr Read() override;
35
  GMPErr Write(const uint8_t* aData,
36
               uint32_t aDataSize) override;
37
  GMPErr Close() override;
38
39
0
  const nsCString& Name() const { return mName; }
40
41
  void OpenComplete(GMPErr aStatus);
42
  void ReadComplete(GMPErr aStatus, const uint8_t* aBytes, uint32_t aLength);
43
  void WriteComplete(GMPErr aStatus);
44
45
private:
46
0
  ~GMPRecordImpl() {}
47
  const nsCString mName;
48
  GMPRecordClient* const mClient;
49
  GMPStorageChild* const mOwner;
50
};
51
52
class GMPStorageChild : public PGMPStorageChild
53
{
54
public:
55
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GMPStorageChild)
56
57
  explicit GMPStorageChild(GMPChild* aPlugin);
58
59
  GMPErr CreateRecord(const nsCString& aRecordName,
60
                      GMPRecord** aOutRecord,
61
                      GMPRecordClient* aClient);
62
63
  GMPErr Open(GMPRecordImpl* aRecord);
64
65
  GMPErr Read(GMPRecordImpl* aRecord);
66
67
  GMPErr Write(GMPRecordImpl* aRecord,
68
               const uint8_t* aData,
69
               uint32_t aDataSize);
70
71
  GMPErr Close(const nsCString& aRecordName);
72
73
private:
74
  bool HasRecord(const nsCString& aRecordName);
75
  already_AddRefed<GMPRecordImpl> GetRecord(const nsCString& aRecordName);
76
77
protected:
78
0
  ~GMPStorageChild() {}
79
80
  // PGMPStorageChild
81
  mozilla::ipc::IPCResult RecvOpenComplete(const nsCString& aRecordName,
82
                                           const GMPErr& aStatus) override;
83
  mozilla::ipc::IPCResult RecvReadComplete(const nsCString& aRecordName,
84
                                           const GMPErr& aStatus,
85
                                           InfallibleTArray<uint8_t>&& aBytes) override;
86
  mozilla::ipc::IPCResult RecvWriteComplete(const nsCString& aRecordName,
87
                                            const GMPErr& aStatus) override;
88
  mozilla::ipc::IPCResult RecvShutdown() override;
89
90
private:
91
  Monitor mMonitor;
92
  nsRefPtrHashtable<nsCStringHashKey, GMPRecordImpl> mRecords;
93
  GMPChild* mPlugin;
94
  bool mShutdown;
95
};
96
97
} // namespace gmp
98
} // namespace mozilla
99
100
#endif // GMPStorageChild_h_