Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: third_party/WebKit/Source/core/workers/ThreadedMessagingProxyBase.cpp

Issue 2709193002: WorkerLoaderProxy: stop accessing cross-thread execution context (Closed)
Patch Set: . Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 std::unique_ptr<WTF::CrossThreadClosure> task) { 65 std::unique_ptr<WTF::CrossThreadClosure> task) {
66 if (m_askedToTerminate) 66 if (m_askedToTerminate)
67 return; 67 return;
68 68
69 DCHECK(m_workerThread); 69 DCHECK(m_workerThread);
70 m_workerThread->postTask(location, std::move(task)); 70 m_workerThread->postTask(location, std::move(task));
71 } 71 }
72 72
73 void ThreadedMessagingProxyBase::postTaskToLoader( 73 void ThreadedMessagingProxyBase::postTaskToLoader(
74 const WebTraceLocation& location, 74 const WebTraceLocation& location,
75 std::unique_ptr<ExecutionContextTask> task) { 75 std::unique_ptr<WTF::CrossThreadClosure> task) {
76 DCHECK(getExecutionContext()->isDocument()); 76 m_parentFrameTaskRunners->get(TaskType::Networking)
77 getParentFrameTaskRunners() 77 ->postTask(BLINK_FROM_HERE, std::move(task));
78 ->get(TaskType::Networking) 78 }
79 ->postTask(BLINK_FROM_HERE, 79
80 crossThreadBind( 80 ExecutionContext* ThreadedMessagingProxyBase::getLoaderExecutionContext() {
81 &ExecutionContextTask::performTaskIfContextIsValid, 81 DCHECK(isParentContextThread());
82 WTF::passed(std::move(task)), 82 return getExecutionContext();
83 wrapCrossThreadWeakPersistent(getExecutionContext())));
84 } 83 }
85 84
86 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) { 85 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) {
87 DCHECK(isParentContextThread()); 86 DCHECK(isParentContextThread());
88 UseCounter::count(m_executionContext, feature); 87 UseCounter::count(m_executionContext, feature);
89 } 88 }
90 89
91 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) { 90 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) {
92 DCHECK(isParentContextThread()); 91 DCHECK(isParentContextThread());
93 Deprecation::countDeprecation(m_executionContext, feature); 92 Deprecation::countDeprecation(m_executionContext, feature);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 void ThreadedMessagingProxyBase::postMessageToPageInspector( 160 void ThreadedMessagingProxyBase::postMessageToPageInspector(
162 const String& message) { 161 const String& message) {
163 DCHECK(isParentContextThread()); 162 DCHECK(isParentContextThread());
164 if (m_workerInspectorProxy) 163 if (m_workerInspectorProxy)
165 m_workerInspectorProxy->dispatchMessageFromWorker(message); 164 m_workerInspectorProxy->dispatchMessageFromWorker(message);
166 } 165 }
167 166
168 bool ThreadedMessagingProxyBase::isParentContextThread() const { 167 bool ThreadedMessagingProxyBase::isParentContextThread() const {
169 // TODO(nhiroki): Nested worker is not supported yet, so the parent context 168 // TODO(nhiroki): Nested worker is not supported yet, so the parent context
170 // thread should be equal to the main thread (http://crbug.com/31666). 169 // thread should be equal to the main thread (http://crbug.com/31666).
171 DCHECK(getExecutionContext()->isDocument()); 170 DCHECK(m_executionContext->isDocument());
172 return isMainThread(); 171 return isMainThread();
173 } 172 }
174 173
175 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698