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

Side by Side Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.cpp

Issue 2716853002: (WIP) Worker: Merge ParentFrameTaskRunners into TaskRunnerHelper
Patch Set: WIP 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "web/WebEmbeddedWorkerImpl.h" 31 #include "web/WebEmbeddedWorkerImpl.h"
32 32
33 #include <memory>
33 #include "bindings/core/v8/SourceLocation.h" 34 #include "bindings/core/v8/SourceLocation.h"
34 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
35 #include "core/dom/ExecutionContextTask.h" 36 #include "core/dom/ExecutionContextTask.h"
36 #include "core/dom/SecurityContext.h" 37 #include "core/dom/SecurityContext.h"
38 #include "core/dom/TaskRunnerHelper.h"
37 #include "core/frame/csp/ContentSecurityPolicy.h" 39 #include "core/frame/csp/ContentSecurityPolicy.h"
38 #include "core/inspector/ConsoleMessage.h" 40 #include "core/inspector/ConsoleMessage.h"
39 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
40 #include "core/loader/FrameLoadRequest.h" 42 #include "core/loader/FrameLoadRequest.h"
41 #include "core/workers/ParentFrameTaskRunners.h"
42 #include "core/workers/WorkerClients.h" 43 #include "core/workers/WorkerClients.h"
43 #include "core/workers/WorkerGlobalScope.h" 44 #include "core/workers/WorkerGlobalScope.h"
44 #include "core/workers/WorkerInspectorProxy.h" 45 #include "core/workers/WorkerInspectorProxy.h"
45 #include "core/workers/WorkerLoaderProxy.h" 46 #include "core/workers/WorkerLoaderProxy.h"
46 #include "core/workers/WorkerScriptLoader.h" 47 #include "core/workers/WorkerScriptLoader.h"
47 #include "core/workers/WorkerThreadStartupData.h" 48 #include "core/workers/WorkerThreadStartupData.h"
48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 49 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
49 #include "modules/serviceworkers/ServiceWorkerThread.h" 50 #include "modules/serviceworkers/ServiceWorkerThread.h"
50 #include "platform/Histogram.h" 51 #include "platform/Histogram.h"
51 #include "platform/SharedBuffer.h" 52 #include "platform/SharedBuffer.h"
(...skipping 14 matching lines...) Expand all
66 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 67 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" 68 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h"
68 #include "web/IndexedDBClientImpl.h" 69 #include "web/IndexedDBClientImpl.h"
69 #include "web/ServiceWorkerGlobalScopeClientImpl.h" 70 #include "web/ServiceWorkerGlobalScopeClientImpl.h"
70 #include "web/ServiceWorkerGlobalScopeProxy.h" 71 #include "web/ServiceWorkerGlobalScopeProxy.h"
71 #include "web/WebDataSourceImpl.h" 72 #include "web/WebDataSourceImpl.h"
72 #include "web/WebLocalFrameImpl.h" 73 #include "web/WebLocalFrameImpl.h"
73 #include "web/WorkerContentSettingsClient.h" 74 #include "web/WorkerContentSettingsClient.h"
74 #include "wtf/Functional.h" 75 #include "wtf/Functional.h"
75 #include "wtf/PtrUtil.h" 76 #include "wtf/PtrUtil.h"
76 #include <memory>
77 77
78 namespace blink { 78 namespace blink {
79 79
80 WebEmbeddedWorker* WebEmbeddedWorker::create( 80 WebEmbeddedWorker* WebEmbeddedWorker::create(
81 WebServiceWorkerContextClient* client, 81 WebServiceWorkerContextClient* client,
82 WebWorkerContentSettingsClientProxy* contentSettingsClient) { 82 WebWorkerContentSettingsClientProxy* contentSettingsClient) {
83 return new WebEmbeddedWorkerImpl(WTF::wrapUnique(client), 83 return new WebEmbeddedWorkerImpl(WTF::wrapUnique(client),
84 WTF::wrapUnique(contentSettingsClient)); 84 WTF::wrapUnique(contentSettingsClient));
85 } 85 }
86 86
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 message.columnNumber, nullptr))); 256 message.columnNumber, nullptr)));
257 } 257 }
258 258
259 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) { 259 void WebEmbeddedWorkerImpl::postMessageToPageInspector(const String& message) {
260 m_workerInspectorProxy->dispatchMessageFromWorker(message); 260 m_workerInspectorProxy->dispatchMessageFromWorker(message);
261 } 261 }
262 262
263 void WebEmbeddedWorkerImpl::postTaskToLoader( 263 void WebEmbeddedWorkerImpl::postTaskToLoader(
264 const WebTraceLocation& location, 264 const WebTraceLocation& location,
265 std::unique_ptr<WTF::CrossThreadClosure> task) { 265 std::unique_ptr<WTF::CrossThreadClosure> task) {
266 m_mainThreadTaskRunners->get(TaskType::Networking) 266 FrameTaskRunnerHelper::get(TaskType::Networking, m_workerThread.get())
267 ->postTask(BLINK_FROM_HERE, std::move(task)); 267 ->postTask(BLINK_FROM_HERE, std::move(task));
268 } 268 }
269 269
270 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope( 270 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(
271 const WebTraceLocation& location, 271 const WebTraceLocation& location,
272 std::unique_ptr<WTF::CrossThreadClosure> task) { 272 std::unique_ptr<WTF::CrossThreadClosure> task) {
273 if (m_askedToTerminate || !m_workerThread) 273 if (m_askedToTerminate || !m_workerThread)
274 return; 274 return;
275 m_workerThread->postTask(location, std::move(task)); 275 m_workerThread->postTask(location, std::move(task));
276 } 276 }
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(), 457 scriptURL, m_workerStartData.userAgent, m_mainScriptLoader->script(),
458 m_mainScriptLoader->releaseCachedMetadata(), startMode, 458 m_mainScriptLoader->releaseCachedMetadata(), startMode,
459 document->contentSecurityPolicy()->headers().get(), 459 document->contentSecurityPolicy()->headers().get(),
460 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients, 460 m_mainScriptLoader->getReferrerPolicy(), starterOrigin, workerClients,
461 m_mainScriptLoader->responseAddressSpace(), 461 m_mainScriptLoader->responseAddressSpace(),
462 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings), 462 m_mainScriptLoader->originTrialTokens(), std::move(workerSettings),
463 workerV8Settings); 463 workerV8Settings);
464 464
465 m_mainScriptLoader.clear(); 465 m_mainScriptLoader.clear();
466 466
467 // We have a dummy document here for loading but it doesn't really represent
468 // the document/frame of associated document(s) for this worker. Here we
469 // populate the task runners with null document not to confuse the frame
470 // scheduler (which will end up using the thread's default task runner).
471 m_mainThreadTaskRunners = ParentFrameTaskRunners::create(nullptr);
472
473 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create( 467 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(
474 *this, *document, *m_workerContextClient); 468 *this, *document, *m_workerContextClient);
475 m_loaderProxy = WorkerLoaderProxy::create(this); 469 m_loaderProxy = WorkerLoaderProxy::create(this);
476 m_workerThread = 470 m_workerThread =
477 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); 471 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy);
478 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); 472 // We have a dummy document here for loading but it doesn't really represent
473 // the document/frame of associated document(s) for this worker. Here we
474 // populate the task runners with null document not to confuse the frame
475 // scheduler (which will end up using the thread's default task runner).
476 m_workerThread->start(std::move(startupData),
477 FrameTaskRunnersHolder::create(nullptr));
479 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), 478 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
480 scriptURL); 479 scriptURL);
481 } 480 }
482 481
483 } // namespace blink 482 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.h ('k') | third_party/WebKit/Source/web/WebSharedWorkerImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698