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

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

Issue 2715803004: Introduce ThreadableLoadingContext: make threaded loading code one step away from Document (Closed)
Patch Set: . Created 3 years, 9 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"
10 #include "core/frame/Deprecation.h" 9 #include "core/frame/Deprecation.h"
11 #include "core/loader/DocumentLoader.h" 10 #include "core/loader/DocumentLoader.h"
11 #include "core/loader/ThreadableLoadingContext.h"
12 #include "core/workers/WorkerInspectorProxy.h" 12 #include "core/workers/WorkerInspectorProxy.h"
13 #include "core/workers/WorkerThreadStartupData.h" 13 #include "core/workers/WorkerThreadStartupData.h"
14 #include "wtf/CurrentTime.h" 14 #include "wtf/CurrentTime.h"
15 15
16 namespace blink { 16 namespace blink {
17 17
18 namespace { 18 namespace {
19 19
20 static int s_liveMessagingProxyCount = 0; 20 static int s_liveMessagingProxyCount = 0;
21 21
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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<WTF::CrossThreadClosure> task) { 75 std::unique_ptr<WTF::CrossThreadClosure> task) {
76 m_parentFrameTaskRunners->get(TaskType::Networking) 76 m_parentFrameTaskRunners->get(TaskType::Networking)
77 ->postTask(BLINK_FROM_HERE, std::move(task)); 77 ->postTask(BLINK_FROM_HERE, std::move(task));
78 } 78 }
79 79
80 ExecutionContext* ThreadedMessagingProxyBase::getLoaderExecutionContext() { 80 ThreadableLoadingContext*
81 ThreadedMessagingProxyBase::getThreadableLoadingContext() {
81 DCHECK(isParentContextThread()); 82 DCHECK(isParentContextThread());
82 return getExecutionContext(); 83 if (!m_loadingContext) {
84 m_loadingContext =
85 ThreadableLoadingContext::create(*toDocument(m_executionContext));
86 }
87 return m_loadingContext;
83 } 88 }
84 89
85 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) { 90 void ThreadedMessagingProxyBase::countFeature(UseCounter::Feature feature) {
86 DCHECK(isParentContextThread()); 91 DCHECK(isParentContextThread());
87 UseCounter::count(m_executionContext, feature); 92 UseCounter::count(m_executionContext, feature);
88 } 93 }
89 94
90 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) { 95 void ThreadedMessagingProxyBase::countDeprecation(UseCounter::Feature feature) {
91 DCHECK(isParentContextThread()); 96 DCHECK(isParentContextThread());
92 Deprecation::countDeprecation(m_executionContext, feature); 97 Deprecation::countDeprecation(m_executionContext, feature);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 170 }
166 171
167 bool ThreadedMessagingProxyBase::isParentContextThread() const { 172 bool ThreadedMessagingProxyBase::isParentContextThread() const {
168 // TODO(nhiroki): Nested worker is not supported yet, so the parent context 173 // 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). 174 // thread should be equal to the main thread (http://crbug.com/31666).
170 DCHECK(m_executionContext->isDocument()); 175 DCHECK(m_executionContext->isDocument());
171 return isMainThread(); 176 return isMainThread();
172 } 177 }
173 178
174 } // namespace blink 179 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698