OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CompositorWorkerManager_h |
| 6 #define CompositorWorkerManager_h |
| 7 |
| 8 #include "core/workers/WorkerV8Isolate.h" |
| 9 #include "wtf/OwnPtr.h" |
| 10 #include "wtf/PassOwnPtr.h" |
| 11 #include "wtf/ThreadingPrimitives.h" |
| 12 #include <v8.h> |
| 13 |
| 14 namespace blink { |
| 15 |
| 16 class WebThreadSupportingGC; |
| 17 |
| 18 class CompositorWorkerManager final { |
| 19 public: |
| 20 static void initialize(); |
| 21 static void shutdown(); |
| 22 |
| 23 static CompositorWorkerManager* instance(); |
| 24 |
| 25 // Returns the thread used for compositor workers. This creates a new thread
if a |
| 26 // thread doesn't already exist. |
| 27 WebThreadSupportingGC& compositorWorkerThread(); |
| 28 |
| 29 // Attempts to initialize/shutdown a thread if necessary. Does nothing if th
e thread |
| 30 // is already initialized, or if the thread has more than one active workers
at the |
| 31 // time of shutdown. |
| 32 void initializeBackingThread(); |
| 33 void shutdownBackingThread(); |
| 34 |
| 35 PassOwnPtr<WorkerV8Isolate> createIsolate(); |
| 36 void willDestroyIsolate(); |
| 37 void destroyIsolate(); |
| 38 void terminateIsolate(); |
| 39 |
| 40 private: |
| 41 CompositorWorkerManager(); |
| 42 ~CompositorWorkerManager(); |
| 43 |
| 44 Mutex m_mutex; |
| 45 OwnPtr<WebThreadSupportingGC> m_thread; |
| 46 int m_workerCount = 0; |
| 47 OwnPtr<WorkerV8Isolate> m_isolate; |
| 48 int m_isolateCount = 0; |
| 49 }; |
| 50 |
| 51 } // namespace blink |
| 52 |
| 53 #endif // CompositorWorkerManager_h |
OLD | NEW |