Bug 1826326 [wpt PR 39360] - Get rid of ResourceWarnings produced by the tests, a...
[gecko.git] / widget / windows / WinCompositorWindowThread.h
blob372e3d91c27e8d15db96afe64707bf5c3c7f6631
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/. */
7 #ifndef widget_windows_WinCompositorWindowThread_h
8 #define widget_windows_WinCompositorWindowThread_h
10 #include "base/thread.h"
11 #include "base/message_loop.h"
12 #include "mozilla/Monitor.h"
14 namespace mozilla {
15 namespace widget {
17 struct WinCompositorWnds {
18 HWND mCompositorWnd;
19 HWND mInitialParentWnd;
20 WinCompositorWnds(HWND aCompositorWnd, HWND aInitialParentWnd)
21 : mCompositorWnd(aCompositorWnd), mInitialParentWnd(aInitialParentWnd) {}
24 class WinCompositorWindowThread final {
25 NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_DELETE_ON_MAIN_THREAD(
26 WinCompositorWindowThread)
28 public:
29 /// Can be called from any thread.
30 static WinCompositorWindowThread* Get();
32 /// Can only be called from the main thread.
33 static void Start();
35 /// Can only be called from the main thread.
36 static void ShutDown();
38 /// Can be called from any thread.
39 static MessageLoop* Loop();
41 /// Can be called from any thread.
42 static bool IsInCompositorWindowThread();
44 /// Can be called from any thread.
45 static WinCompositorWnds CreateCompositorWindow();
47 /// Can be called from any thread.
48 static void DestroyCompositorWindow(WinCompositorWnds aWnds);
50 private:
51 explicit WinCompositorWindowThread(base::Thread* aThread);
52 ~WinCompositorWindowThread() {}
54 void ShutDownTask();
56 UniquePtr<base::Thread> const mThread;
57 Monitor mMonitor;
59 // Has ShutDown been called on us? We might have survived if our thread join
60 // timed out.
61 bool mHasAttemptedShutdown = false;
64 } // namespace widget
65 } // namespace mozilla
67 #endif // widget_windows_WinCompositorWindowThread_h