| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ThreadedMessagingProxyBase_h | 5 #ifndef ThreadedMessagingProxyBase_h |
| 6 #define ThreadedMessagingProxyBase_h | 6 #define ThreadedMessagingProxyBase_h |
| 7 | 7 |
| 8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/dom/TaskRunnerHelper.h" |
| 9 #include "core/frame/UseCounter.h" | 10 #include "core/frame/UseCounter.h" |
| 10 #include "core/inspector/ConsoleTypes.h" | 11 #include "core/inspector/ConsoleTypes.h" |
| 11 #include "core/workers/ParentFrameTaskRunners.h" | |
| 12 #include "core/workers/WorkerLoaderProxy.h" | 12 #include "core/workers/WorkerLoaderProxy.h" |
| 13 #include "wtf/Forward.h" | 13 #include "wtf/Forward.h" |
| 14 | 14 |
| 15 namespace blink { | 15 namespace blink { |
| 16 | 16 |
| 17 class ExecutionContext; | 17 class ExecutionContext; |
| 18 class SourceLocation; | 18 class SourceLocation; |
| 19 class WorkerInspectorProxy; | 19 class WorkerInspectorProxy; |
| 20 class WorkerLoaderProxy; | 20 class WorkerLoaderProxy; |
| 21 class WorkerThread; | 21 class WorkerThread; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 void postMessageToPageInspector(const String&); | 42 void postMessageToPageInspector(const String&); |
| 43 | 43 |
| 44 // 'virtual' for testing. | 44 // 'virtual' for testing. |
| 45 virtual void workerThreadTerminated(); | 45 virtual void workerThreadTerminated(); |
| 46 | 46 |
| 47 // Accessed only from the parent thread. | 47 // Accessed only from the parent thread. |
| 48 ExecutionContext* getExecutionContext() const { | 48 ExecutionContext* getExecutionContext() const { |
| 49 return m_executionContext.get(); | 49 return m_executionContext.get(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // Accessed from both the parent thread and the worker. | |
| 53 ParentFrameTaskRunners* getParentFrameTaskRunners() { | |
| 54 return m_parentFrameTaskRunners.get(); | |
| 55 } | |
| 56 | |
| 57 // Number of live messaging proxies, used by leak detection. | 52 // Number of live messaging proxies, used by leak detection. |
| 58 static int proxyCount(); | 53 static int proxyCount(); |
| 59 | 54 |
| 60 protected: | 55 protected: |
| 61 ThreadedMessagingProxyBase(ExecutionContext*); | 56 ThreadedMessagingProxyBase(ExecutionContext*); |
| 62 ~ThreadedMessagingProxyBase() override; | 57 ~ThreadedMessagingProxyBase() override; |
| 63 | 58 |
| 64 void initializeWorkerThread(std::unique_ptr<WorkerThreadStartupData>); | 59 void initializeWorkerThread(std::unique_ptr<WorkerThreadStartupData>); |
| 65 virtual std::unique_ptr<WorkerThread> createWorkerThread( | 60 virtual std::unique_ptr<WorkerThread> createWorkerThread( |
| 66 double originTime) = 0; | 61 double originTime) = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 88 ExecutionContext* getLoaderExecutionContext() override; | 83 ExecutionContext* getLoaderExecutionContext() override; |
| 89 | 84 |
| 90 private: | 85 private: |
| 91 friend class InProcessWorkerMessagingProxyForTest; | 86 friend class InProcessWorkerMessagingProxyForTest; |
| 92 friend class ThreadedWorkletMessagingProxyForTest; | 87 friend class ThreadedWorkletMessagingProxyForTest; |
| 93 | 88 |
| 94 void parentObjectDestroyedInternal(); | 89 void parentObjectDestroyedInternal(); |
| 95 | 90 |
| 96 Persistent<ExecutionContext> m_executionContext; | 91 Persistent<ExecutionContext> m_executionContext; |
| 97 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; | 92 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; |
| 98 // Accessed cross-thread when worker thread posts tasks to the parent. | |
| 99 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; | |
| 100 | 93 |
| 101 std::unique_ptr<WorkerThread> m_workerThread; | 94 std::unique_ptr<WorkerThread> m_workerThread; |
| 102 | 95 |
| 103 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 96 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 104 | 97 |
| 105 bool m_mayBeDestroyed; | 98 bool m_mayBeDestroyed; |
| 106 bool m_askedToTerminate; | 99 bool m_askedToTerminate; |
| 107 }; | 100 }; |
| 108 | 101 |
| 109 } // namespace blink | 102 } // namespace blink |
| 110 | 103 |
| 111 #endif // ThreadedMessagingProxyBase_h | 104 #endif // ThreadedMessagingProxyBase_h |
| OLD | NEW |