Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/dom/media/gtest/GMPTestMonitor.h
Line
Count
Source (jump to first uncovered line)
1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3
/* This Source Code Form is subject to the terms of the Mozilla Public
4
 * License, v. 2.0. If a copy of the MPL was not distributed with this
5
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7
#include "nsThreadUtils.h"
8
9
#ifndef __GMPTestMonitor_h__
10
#define __GMPTestMonitor_h__
11
12
class GMPTestMonitor
13
{
14
public:
15
  GMPTestMonitor()
16
    : mFinished(false)
17
0
  {
18
0
  }
19
20
  void AwaitFinished()
21
0
  {
22
0
    MOZ_ASSERT(NS_IsMainThread());
23
0
    mozilla::SpinEventLoopUntil([&]() { return mFinished; });
24
0
    mFinished = false;
25
0
  }
26
27
private:
28
  void MarkFinished()
29
0
  {
30
0
    MOZ_ASSERT(NS_IsMainThread());
31
0
    mFinished = true;
32
0
  }
33
34
public:
35
  void SetFinished()
36
0
  {
37
0
    mozilla::SystemGroup::Dispatch(
38
0
      mozilla::TaskCategory::Other,
39
0
      mozilla::NewNonOwningRunnableMethod(
40
0
        "GMPTestMonitor::MarkFinished", this, &GMPTestMonitor::MarkFinished));
41
0
  }
42
43
private:
44
  bool mFinished;
45
};
46
47
#endif // __GMPTestMonitor_h__