Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/gmp/GMPTimerParent.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 GMPTimerParent_h_
7
#define GMPTimerParent_h_
8
9
#include "mozilla/gmp/PGMPTimerParent.h"
10
#include "nsITimer.h"
11
#include "nsCOMPtr.h"
12
#include "nsClassHashtable.h"
13
#include "nsHashKeys.h"
14
#include "mozilla/Monitor.h"
15
#include "nsIThread.h"
16
17
namespace mozilla {
18
namespace gmp {
19
20
class GMPTimerParent : public PGMPTimerParent {
21
public:
22
  NS_INLINE_DECL_REFCOUNTING(GMPTimerParent)
23
  explicit GMPTimerParent(nsISerialEventTarget* aGMPEventTarget);
24
25
  void Shutdown();
26
27
protected:
28
  mozilla::ipc::IPCResult RecvSetTimer(const uint32_t& aTimerId,
29
                                       const uint32_t& aTimeoutMs) override;
30
  void ActorDestroy(ActorDestroyReason aWhy) override;
31
32
private:
33
0
  ~GMPTimerParent() {}
34
35
  static void GMPTimerExpired(nsITimer *aTimer, void *aClosure);
36
37
  struct Context {
38
    Context()
39
0
      : mId(0) {
40
0
      MOZ_COUNT_CTOR(Context);
41
0
    }
42
0
    ~Context() {
43
0
      MOZ_COUNT_DTOR(Context);
44
0
    }
45
    nsCOMPtr<nsITimer> mTimer;
46
    RefPtr<GMPTimerParent> mParent; // Note: live timers keep the GMPTimerParent alive.
47
    uint32_t mId;
48
  };
49
50
  void TimerExpired(Context* aContext);
51
52
  nsTHashtable<nsPtrHashKey<Context>> mTimers;
53
54
  nsCOMPtr<nsISerialEventTarget> mGMPEventTarget;
55
56
  bool mIsOpen;
57
};
58
59
} // namespace gmp
60
} // namespace mozilla
61
62
#endif // GMPTimerParent_h_