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