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 #include "core/workers/ThreadedMessagingProxyBase.h" | 5 #include "core/workers/ThreadedMessagingProxyBase.h" |
6 | 6 |
7 #include "bindings/core/v8/SourceLocation.h" | 7 #include "bindings/core/v8/SourceLocation.h" |
8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
9 #include "core/dom/ExecutionContextTask.h" | 9 #include "core/dom/ExecutionContextTask.h" |
10 #include "core/frame/Deprecation.h" | 10 #include "core/frame/Deprecation.h" |
11 #include "core/loader/DocumentLoader.h" | 11 #include "core/loader/DocumentLoader.h" |
12 #include "core/workers/ParentFrameTaskRunners.h" | |
13 #include "core/workers/WorkerInspectorProxy.h" | 12 #include "core/workers/WorkerInspectorProxy.h" |
14 #include "core/workers/WorkerThreadStartupData.h" | 13 #include "core/workers/WorkerThreadStartupData.h" |
15 #include "wtf/CurrentTime.h" | 14 #include "wtf/CurrentTime.h" |
16 | 15 |
17 namespace blink { | 16 namespace blink { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 static int s_liveMessagingProxyCount = 0; | 20 static int s_liveMessagingProxyCount = 0; |
22 | 21 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 return; | 67 return; |
69 | 68 |
70 DCHECK(m_workerThread); | 69 DCHECK(m_workerThread); |
71 m_workerThread->postTask(location, std::move(task)); | 70 m_workerThread->postTask(location, std::move(task)); |
72 } | 71 } |
73 | 72 |
74 void ThreadedMessagingProxyBase::postTaskToLoader( | 73 void ThreadedMessagingProxyBase::postTaskToLoader( |
75 const WebTraceLocation& location, | 74 const WebTraceLocation& location, |
76 std::unique_ptr<ExecutionContextTask> task) { | 75 std::unique_ptr<ExecutionContextTask> task) { |
77 DCHECK(getExecutionContext()->isDocument()); | 76 DCHECK(getExecutionContext()->isDocument()); |
78 m_parentFrameTaskRunners->get(TaskType::Networking) | 77 getParentFrameTaskRunners() |
| 78 ->get(TaskType::Networking) |
79 ->postTask(BLINK_FROM_HERE, | 79 ->postTask(BLINK_FROM_HERE, |
80 crossThreadBind( | 80 crossThreadBind( |
81 &ExecutionContextTask::performTaskIfContextIsValid, | 81 &ExecutionContextTask::performTaskIfContextIsValid, |
82 WTF::passed(std::move(task)), | 82 WTF::passed(std::move(task)), |
83 wrapCrossThreadWeakPersistent(getExecutionContext()))); | 83 wrapCrossThreadWeakPersistent(getExecutionContext()))); |
84 } | 84 } |
85 | 85 |
86 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) { | 86 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) { |
87 DCHECK(isParentContextThread()); | 87 DCHECK(isParentContextThread()); |
88 UseCounter::count(m_executionContext, feature); | 88 UseCounter::count(m_executionContext, feature); |
(...skipping 19 matching lines...) Expand all Loading... |
108 | 108 |
109 void ThreadedMessagingProxyBase::workerThreadCreated() { | 109 void ThreadedMessagingProxyBase::workerThreadCreated() { |
110 DCHECK(isParentContextThread()); | 110 DCHECK(isParentContextThread()); |
111 DCHECK(!m_askedToTerminate); | 111 DCHECK(!m_askedToTerminate); |
112 DCHECK(m_workerThread); | 112 DCHECK(m_workerThread); |
113 } | 113 } |
114 | 114 |
115 void ThreadedMessagingProxyBase::parentObjectDestroyed() { | 115 void ThreadedMessagingProxyBase::parentObjectDestroyed() { |
116 DCHECK(isParentContextThread()); | 116 DCHECK(isParentContextThread()); |
117 | 117 |
118 m_parentFrameTaskRunners->get(TaskType::UnspecedTimer) | 118 getParentFrameTaskRunners() |
| 119 ->get(TaskType::UnspecedTimer) |
119 ->postTask( | 120 ->postTask( |
120 BLINK_FROM_HERE, | 121 BLINK_FROM_HERE, |
121 WTF::bind(&ThreadedMessagingProxyBase::parentObjectDestroyedInternal, | 122 WTF::bind(&ThreadedMessagingProxyBase::parentObjectDestroyedInternal, |
122 WTF::unretained(this))); | 123 WTF::unretained(this))); |
123 } | 124 } |
124 | 125 |
125 void ThreadedMessagingProxyBase::parentObjectDestroyedInternal() { | 126 void ThreadedMessagingProxyBase::parentObjectDestroyedInternal() { |
126 DCHECK(isParentContextThread()); | 127 DCHECK(isParentContextThread()); |
127 m_mayBeDestroyed = true; | 128 m_mayBeDestroyed = true; |
128 if (m_workerThread) | 129 if (m_workerThread) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 166 } |
166 | 167 |
167 bool ThreadedMessagingProxyBase::isParentContextThread() const { | 168 bool ThreadedMessagingProxyBase::isParentContextThread() const { |
168 // TODO(nhiroki): Nested worker is not supported yet, so the parent context | 169 // TODO(nhiroki): Nested worker is not supported yet, so the parent context |
169 // thread should be equal to the main thread (http://crbug.com/31666). | 170 // thread should be equal to the main thread (http://crbug.com/31666). |
170 DCHECK(getExecutionContext()->isDocument()); | 171 DCHECK(getExecutionContext()->isDocument()); |
171 return isMainThread(); | 172 return isMainThread(); |
172 } | 173 } |
173 | 174 |
174 } // namespace blink | 175 } // namespace blink |
OLD | NEW |