| 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/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
| 10 #include "core/inspector/ConsoleTypes.h" | 10 #include "core/inspector/ConsoleTypes.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 void reportConsoleMessage(MessageSource, | 38 void reportConsoleMessage(MessageSource, |
| 39 MessageLevel, | 39 MessageLevel, |
| 40 const String& message, | 40 const String& message, |
| 41 std::unique_ptr<SourceLocation>); | 41 std::unique_ptr<SourceLocation>); |
| 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 from both the parent thread and the worker. | 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. | 52 // Accessed from both the parent thread and the worker. |
| 53 ParentFrameTaskRunners* getParentFrameTaskRunners() { | 53 ParentFrameTaskRunners* getParentFrameTaskRunners() { |
| 54 return m_parentFrameTaskRunners.get(); | 54 return m_parentFrameTaskRunners.get(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Number of live messaging proxies, used by leak detection. | 57 // Number of live messaging proxies, used by leak detection. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 74 return m_workerInspectorProxy.get(); | 74 return m_workerInspectorProxy.get(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 // Returns true if this is called on the parent context thread. | 77 // Returns true if this is called on the parent context thread. |
| 78 bool isParentContextThread() const; | 78 bool isParentContextThread() const; |
| 79 | 79 |
| 80 // WorkerLoaderProxyProvider | 80 // WorkerLoaderProxyProvider |
| 81 // These methods are called on different threads to schedule loading | 81 // These methods are called on different threads to schedule loading |
| 82 // requests and to send callbacks back to WorkerGlobalScope. | 82 // requests and to send callbacks back to WorkerGlobalScope. |
| 83 void postTaskToLoader(const WebTraceLocation&, | 83 void postTaskToLoader(const WebTraceLocation&, |
| 84 std::unique_ptr<ExecutionContextTask>) override; | 84 std::unique_ptr<WTF::CrossThreadClosure>) override; |
| 85 void postTaskToWorkerGlobalScope( | 85 void postTaskToWorkerGlobalScope( |
| 86 const WebTraceLocation&, | 86 const WebTraceLocation&, |
| 87 std::unique_ptr<WTF::CrossThreadClosure>) override; | 87 std::unique_ptr<WTF::CrossThreadClosure>) override; |
| 88 ExecutionContext* getLoaderExecutionContext() override; |
| 88 | 89 |
| 89 private: | 90 private: |
| 90 friend class InProcessWorkerMessagingProxyForTest; | 91 friend class InProcessWorkerMessagingProxyForTest; |
| 91 friend class ThreadedWorkletMessagingProxyForTest; | 92 friend class ThreadedWorkletMessagingProxyForTest; |
| 92 | 93 |
| 93 void parentObjectDestroyedInternal(); | 94 void parentObjectDestroyedInternal(); |
| 94 | 95 |
| 95 // Accessed cross-thread when worker thread posts tasks to the parent; | 96 Persistent<ExecutionContext> m_executionContext; |
| 96 // it is not ideal to have ExecutionContext be cross-thread accessible. | |
| 97 // | |
| 98 // TODO: try to drop the need for the CrossThreadPersistent<>. | |
| 99 CrossThreadPersistent<ExecutionContext> m_executionContext; | |
| 100 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; | 97 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; |
| 101 // Accessed cross-thread when worker thread posts tasks to the parent. | 98 // Accessed cross-thread when worker thread posts tasks to the parent. |
| 102 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; | 99 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; |
| 103 | 100 |
| 104 std::unique_ptr<WorkerThread> m_workerThread; | 101 std::unique_ptr<WorkerThread> m_workerThread; |
| 105 | 102 |
| 106 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 103 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 107 | 104 |
| 108 bool m_mayBeDestroyed; | 105 bool m_mayBeDestroyed; |
| 109 bool m_askedToTerminate; | 106 bool m_askedToTerminate; |
| 110 }; | 107 }; |
| 111 | 108 |
| 112 } // namespace blink | 109 } // namespace blink |
| 113 | 110 |
| 114 #endif // ThreadedMessagingProxyBase_h | 111 #endif // ThreadedMessagingProxyBase_h |
| OLD | NEW |