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"
17 struct WinCompositorWnds
{
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
)
29 /// Can be called from any thread.
30 static WinCompositorWindowThread
* Get();
32 /// Can only be called from the main thread.
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
);
51 explicit WinCompositorWindowThread(base::Thread
* aThread
);
52 ~WinCompositorWindowThread() {}
56 UniquePtr
<base::Thread
> const mThread
;
59 // Has ShutDown been called on us? We might have survived if our thread join
61 bool mHasAttemptedShutdown
= false;
65 } // namespace mozilla
67 #endif // widget_windows_WinCompositorWindowThread_h