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

Side by Side Diff: third_party/WebKit/Source/web/WebEmbeddedWorkerImpl.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 /* 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"
37 #include "core/frame/csp/ContentSecurityPolicy.h" 38 #include "core/frame/csp/ContentSecurityPolicy.h"
38 #include "core/inspector/ConsoleMessage.h" 39 #include "core/inspector/ConsoleMessage.h"
39 #include "core/inspector/InspectorInstrumentation.h" 40 #include "core/inspector/InspectorInstrumentation.h"
40 #include "core/loader/FrameLoadRequest.h" 41 #include "core/loader/FrameLoadRequest.h"
42 #include "core/loader/ThreadableLoadingContext.h"
41 #include "core/workers/ParentFrameTaskRunners.h" 43 #include "core/workers/ParentFrameTaskRunners.h"
42 #include "core/workers/WorkerClients.h" 44 #include "core/workers/WorkerClients.h"
43 #include "core/workers/WorkerGlobalScope.h" 45 #include "core/workers/WorkerGlobalScope.h"
44 #include "core/workers/WorkerInspectorProxy.h" 46 #include "core/workers/WorkerInspectorProxy.h"
45 #include "core/workers/WorkerLoaderProxy.h" 47 #include "core/workers/WorkerLoaderProxy.h"
46 #include "core/workers/WorkerScriptLoader.h" 48 #include "core/workers/WorkerScriptLoader.h"
47 #include "core/workers/WorkerThreadStartupData.h" 49 #include "core/workers/WorkerThreadStartupData.h"
48 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 50 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
49 #include "modules/serviceworkers/ServiceWorkerThread.h" 51 #include "modules/serviceworkers/ServiceWorkerThread.h"
50 #include "platform/Histogram.h" 52 #include "platform/Histogram.h"
(...skipping 15 matching lines...) Expand all
66 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 68 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
67 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h" 69 #include "public/web/modules/serviceworker/WebServiceWorkerNetworkProvider.h"
68 #include "web/IndexedDBClientImpl.h" 70 #include "web/IndexedDBClientImpl.h"
69 #include "web/ServiceWorkerGlobalScopeClientImpl.h" 71 #include "web/ServiceWorkerGlobalScopeClientImpl.h"
70 #include "web/ServiceWorkerGlobalScopeProxy.h" 72 #include "web/ServiceWorkerGlobalScopeProxy.h"
71 #include "web/WebDataSourceImpl.h" 73 #include "web/WebDataSourceImpl.h"
72 #include "web/WebLocalFrameImpl.h" 74 #include "web/WebLocalFrameImpl.h"
73 #include "web/WorkerContentSettingsClient.h" 75 #include "web/WorkerContentSettingsClient.h"
74 #include "wtf/Functional.h" 76 #include "wtf/Functional.h"
75 #include "wtf/PtrUtil.h" 77 #include "wtf/PtrUtil.h"
76 #include <memory>
77 78
78 namespace blink { 79 namespace blink {
79 80
80 WebEmbeddedWorker* WebEmbeddedWorker::create( 81 WebEmbeddedWorker* WebEmbeddedWorker::create(
81 WebServiceWorkerContextClient* client, 82 WebServiceWorkerContextClient* client,
82 WebWorkerContentSettingsClientProxy* contentSettingsClient) { 83 WebWorkerContentSettingsClientProxy* contentSettingsClient) {
83 return new WebEmbeddedWorkerImpl(WTF::wrapUnique(client), 84 return new WebEmbeddedWorkerImpl(WTF::wrapUnique(client),
84 WTF::wrapUnique(contentSettingsClient)); 85 WTF::wrapUnique(contentSettingsClient));
85 } 86 }
86 87
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 269 }
269 270
270 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope( 271 void WebEmbeddedWorkerImpl::postTaskToWorkerGlobalScope(
271 const WebTraceLocation& location, 272 const WebTraceLocation& location,
272 std::unique_ptr<WTF::CrossThreadClosure> task) { 273 std::unique_ptr<WTF::CrossThreadClosure> task) {
273 if (m_askedToTerminate || !m_workerThread) 274 if (m_askedToTerminate || !m_workerThread)
274 return; 275 return;
275 m_workerThread->postTask(location, std::move(task)); 276 m_workerThread->postTask(location, std::move(task));
276 } 277 }
277 278
278 ExecutionContext* WebEmbeddedWorkerImpl::getLoaderExecutionContext() { 279 ThreadableLoadingContext* WebEmbeddedWorkerImpl::getThreadableLoadingContext() {
279 return m_mainFrame->frame()->document(); 280 if (!m_loadingContext) {
281 m_loadingContext =
282 ThreadableLoadingContext::create(*m_mainFrame->frame()->document());
283 }
284 return m_loadingContext;
280 } 285 }
281 286
282 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() { 287 void WebEmbeddedWorkerImpl::prepareShadowPageForLoader() {
283 // Create 'shadow page', which is never displayed and is used mainly to 288 // Create 'shadow page', which is never displayed and is used mainly to
284 // provide a context for loading on the main thread. 289 // provide a context for loading on the main thread.
285 // 290 //
286 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader. 291 // FIXME: This does mostly same as WebSharedWorkerImpl::initializeLoader.
287 // This code, and probably most of the code in this class should be shared 292 // This code, and probably most of the code in this class should be shared
288 // with SharedWorker. 293 // with SharedWorker.
289 DCHECK(!m_webView); 294 DCHECK(!m_webView);
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 *this, *document, *m_workerContextClient); 479 *this, *document, *m_workerContextClient);
475 m_loaderProxy = WorkerLoaderProxy::create(this); 480 m_loaderProxy = WorkerLoaderProxy::create(this);
476 m_workerThread = 481 m_workerThread =
477 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy); 482 ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalScopeProxy);
478 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get()); 483 m_workerThread->start(std::move(startupData), m_mainThreadTaskRunners.get());
479 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), 484 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(),
480 scriptURL); 485 scriptURL);
481 } 486 }
482 487
483 } // namespace blink 488 } // 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