/src/mozilla-central/gfx/layers/ipc/CompositorThread.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 | | #ifndef mozilla_layers_CompositorThread_h |
7 | | #define mozilla_layers_CompositorThread_h |
8 | | |
9 | | #include "base/basictypes.h" // for DISALLOW_EVIL_CONSTRUCTORS |
10 | | #include "base/platform_thread.h" // for PlatformThreadId |
11 | | #include "base/thread.h" // for Thread |
12 | | #include "base/message_loop.h" |
13 | | #include "nsISupportsImpl.h" |
14 | | #include "ThreadSafeRefcountingWithMainThreadDestruction.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace layers { |
18 | | |
19 | | class CompositorThreadHolder final |
20 | | { |
21 | | NS_INLINE_DECL_THREADSAFE_REFCOUNTING_WITH_MAIN_THREAD_DESTRUCTION(CompositorThreadHolder) |
22 | | |
23 | | public: |
24 | | CompositorThreadHolder(); |
25 | | |
26 | 0 | base::Thread* GetCompositorThread() const { |
27 | 0 | return mCompositorThread; |
28 | 0 | } |
29 | | |
30 | | static CompositorThreadHolder* GetSingleton(); |
31 | | |
32 | 0 | static bool IsActive() { |
33 | 0 | return !!GetSingleton(); |
34 | 0 | } |
35 | | |
36 | | /** |
37 | | * Creates the compositor thread and the global compositor map. |
38 | | */ |
39 | | static void Start(); |
40 | | |
41 | | /* |
42 | | * Waits for all [CrossProcess]CompositorBridgeParents to shutdown and |
43 | | * releases compositor-thread owned resources. |
44 | | */ |
45 | | static void Shutdown(); |
46 | | |
47 | | static MessageLoop* Loop(); |
48 | | |
49 | | // Returns true if the calling thread is the compositor thread. |
50 | | static bool IsInCompositorThread(); |
51 | | |
52 | | private: |
53 | | ~CompositorThreadHolder(); |
54 | | |
55 | | base::Thread* const mCompositorThread; |
56 | | |
57 | | static base::Thread* CreateCompositorThread(); |
58 | | static void DestroyCompositorThread(base::Thread* aCompositorThread); |
59 | | |
60 | | friend class CompositorBridgeParent; |
61 | | }; |
62 | | |
63 | | base::Thread* CompositorThread(); |
64 | | |
65 | | } // namespace layers |
66 | | } // namespace mozilla |
67 | | |
68 | | #endif // mozilla_layers_CompositorThread_h |