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

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 return getExecutionContext();
82 WTF::passed(std::move(task)),
83 wrapCrossThreadWeakPersistent(getExecutionContext())));
84 } 82 }
85 83
86 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) { 84 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) {
87 DCHECK(isParentContextThread()); 85 DCHECK(isParentContextThread());
88 UseCounter::count(m_executionContext, feature); 86 UseCounter::count(m_executionContext, feature);
89 } 87 }
90 88
91 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) { 89 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) {
92 DCHECK(isParentContextThread()); 90 DCHECK(isParentContextThread());
93 Deprecation::countDeprecation(m_executionContext, feature); 91 Deprecation::countDeprecation(m_executionContext, feature);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 164 }
167 165
168 bool ThreadedMessagingProxyBase::isParentContextThread() const { 166 bool ThreadedMessagingProxyBase::isParentContextThread() const {
169 // TODO(nhiroki): Nested worker is not supported yet, so the parent context 167 // 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). 168 // thread should be equal to the main thread (http://crbug.com/31666).
171 DCHECK(getExecutionContext()->isDocument()); 169 DCHECK(getExecutionContext()->isDocument());
172 return isMainThread(); 170 return isMainThread();
173 } 171 }
174 172
175 } // namespace blink 173 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698