Bug 1772053 - Enable dynamic code disable mitigations only on Windows 10 1703+ r...
[gecko.git] / dom / media / gtest / GMPTestMonitor.h
blob226d5c77a9f55eec55d2e1476a518e9362ae10e8
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 #ifndef __GMPTestMonitor_h__
7 #define __GMPTestMonitor_h__
9 #include "nsThreadUtils.h"
10 #include "mozilla/SchedulerGroup.h"
11 #include "mozilla/SpinEventLoopUntil.h"
13 class GMPTestMonitor {
14 public:
15 GMPTestMonitor() : mFinished(false) {}
17 void AwaitFinished() {
18 MOZ_ASSERT(NS_IsMainThread());
19 mozilla::SpinEventLoopUntil("GMPTestMonitor::AwaitFinished"_ns,
20 [&]() { return mFinished; });
21 mFinished = false;
24 private:
25 void MarkFinished() {
26 MOZ_ASSERT(NS_IsMainThread());
27 mFinished = true;
30 public:
31 void SetFinished() {
32 mozilla::SchedulerGroup::Dispatch(mozilla::TaskCategory::Other,
33 mozilla::NewNonOwningRunnableMethod(
34 "GMPTestMonitor::MarkFinished", this,
35 &GMPTestMonitor::MarkFinished));
38 private:
39 bool mFinished;
42 #endif // __GMPTestMonitor_h__