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

Side by Side Diff: third_party/WebKit/Source/modules/exported/WebEmbeddedWorkerImpl.cpp

Issue 2939623002: [DONT COMMIT] WIP: WorkerClientsInitializer (Closed)
Patch Set: finalize2 Created 3 years, 6 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 28 matching lines...) Expand all
39 #include "core/exported/WebFactory.h" 39 #include "core/exported/WebFactory.h"
40 #include "core/exported/WebViewBase.h" 40 #include "core/exported/WebViewBase.h"
41 #include "core/frame/WebLocalFrameBase.h" 41 #include "core/frame/WebLocalFrameBase.h"
42 #include "core/frame/csp/ContentSecurityPolicy.h" 42 #include "core/frame/csp/ContentSecurityPolicy.h"
43 #include "core/inspector/ConsoleMessage.h" 43 #include "core/inspector/ConsoleMessage.h"
44 #include "core/loader/FrameLoadRequest.h" 44 #include "core/loader/FrameLoadRequest.h"
45 #include "core/loader/ThreadableLoadingContext.h" 45 #include "core/loader/ThreadableLoadingContext.h"
46 #include "core/loader/WorkerFetchContext.h" 46 #include "core/loader/WorkerFetchContext.h"
47 #include "core/probe/CoreProbes.h" 47 #include "core/probe/CoreProbes.h"
48 #include "core/workers/ParentFrameTaskRunners.h" 48 #include "core/workers/ParentFrameTaskRunners.h"
49 #include "core/workers/WorkerClients.h"
50 #include "core/workers/WorkerContentSettingsClient.h" 49 #include "core/workers/WorkerContentSettingsClient.h"
51 #include "core/workers/WorkerGlobalScope.h" 50 #include "core/workers/WorkerGlobalScope.h"
52 #include "core/workers/WorkerInspectorProxy.h" 51 #include "core/workers/WorkerInspectorProxy.h"
53 #include "core/workers/WorkerScriptLoader.h" 52 #include "core/workers/WorkerScriptLoader.h"
54 #include "core/workers/WorkerThreadStartupData.h" 53 #include "core/workers/WorkerThreadStartupData.h"
55 #include "modules/indexeddb/IndexedDBClientImpl.h"
56 #include "modules/serviceworkers/ServiceWorkerContainerClient.h" 54 #include "modules/serviceworkers/ServiceWorkerContainerClient.h"
57 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClientImpl.h" 55 #include "modules/serviceworkers/ServiceWorkerGlobalScopeClientImpl.h"
58 #include "modules/serviceworkers/ServiceWorkerGlobalScopeProxy.h" 56 #include "modules/serviceworkers/ServiceWorkerGlobalScopeProxy.h"
59 #include "modules/serviceworkers/ServiceWorkerThread.h" 57 #include "modules/serviceworkers/ServiceWorkerThread.h"
60 #include "platform/Histogram.h" 58 #include "platform/Histogram.h"
61 #include "platform/RuntimeEnabledFeatures.h" 59 #include "platform/RuntimeEnabledFeatures.h"
62 #include "platform/SharedBuffer.h" 60 #include "platform/SharedBuffer.h"
63 #include "platform/heap/Handle.h" 61 #include "platform/heap/Handle.h"
64 #include "platform/loader/fetch/SubstituteData.h" 62 #include "platform/loader/fetch/SubstituteData.h"
65 #include "platform/network/ContentSecurityPolicyParsers.h" 63 #include "platform/network/ContentSecurityPolicyParsers.h"
66 #include "platform/network/ContentSecurityPolicyResponseHeaders.h" 64 #include "platform/network/ContentSecurityPolicyResponseHeaders.h"
67 #include "platform/network/NetworkUtils.h" 65 #include "platform/network/NetworkUtils.h"
68 #include "platform/weborigin/SecurityOrigin.h" 66 #include "platform/weborigin/SecurityOrigin.h"
69 #include "platform/wtf/Functional.h" 67 #include "platform/wtf/Functional.h"
70 #include "platform/wtf/PtrUtil.h" 68 #include "platform/wtf/PtrUtil.h"
71 #include "public/platform/Platform.h" 69 #include "public/platform/Platform.h"
72 #include "public/platform/WebContentSettingsClient.h" 70 #include "public/platform/WebContentSettingsClient.h"
73 #include "public/platform/WebURLRequest.h" 71 #include "public/platform/WebURLRequest.h"
74 #include "public/platform/WebWorkerFetchContext.h" 72 #include "public/platform/WebWorkerFetchContext.h"
75 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h" 73 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h"
76 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h" 74 #include "public/platform/modules/serviceworker/WebServiceWorkerProvider.h"
77 #include "public/web/WebConsoleMessage.h" 75 #include "public/web/WebConsoleMessage.h"
78 #include "public/web/WebDevToolsAgent.h" 76 #include "public/web/WebDevToolsAgent.h"
79 #include "public/web/WebSettings.h" 77 #include "public/web/WebSettings.h"
80 #include "public/web/WebView.h" 78 #include "public/web/WebView.h"
81 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h" 79 #include "public/web/modules/serviceworker/WebServiceWorkerContextClient.h"
82 80
83 namespace blink { 81 namespace blink {
84 82
83 template class MODULES_EXPORT WorkerClientsInitializer<WebEmbeddedWorkerImpl>;
84
85 WebEmbeddedWorker* WebEmbeddedWorker::Create( 85 WebEmbeddedWorker* WebEmbeddedWorker::Create(
86 WebServiceWorkerContextClient* client, 86 WebServiceWorkerContextClient* client,
87 WebContentSettingsClient* content_settings_client) { 87 WebContentSettingsClient* content_settings_client) {
88 return new WebEmbeddedWorkerImpl(WTF::WrapUnique(client), 88 return new WebEmbeddedWorkerImpl(WTF::WrapUnique(client),
89 WTF::WrapUnique(content_settings_client)); 89 WTF::WrapUnique(content_settings_client));
90 } 90 }
91 91
92 static HashSet<WebEmbeddedWorkerImpl*>& RunningWorkerInstances() { 92 static HashSet<WebEmbeddedWorkerImpl*>& RunningWorkerInstances() {
93 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); 93 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ());
94 return set; 94 return set;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 DCHECK_EQ(pause_after_download_state_, kDontPauseAfterDownload); 403 DCHECK_EQ(pause_after_download_state_, kDontPauseAfterDownload);
404 DCHECK(!asked_to_terminate_); 404 DCHECK(!asked_to_terminate_);
405 405
406 Document* document = main_frame_->GetFrame()->GetDocument(); 406 Document* document = main_frame_->GetFrame()->GetDocument();
407 407
408 // FIXME: this document's origin is pristine and without any extra privileges. 408 // FIXME: this document's origin is pristine and without any extra privileges.
409 // (crbug.com/254993) 409 // (crbug.com/254993)
410 SecurityOrigin* starter_origin = document->GetSecurityOrigin(); 410 SecurityOrigin* starter_origin = document->GetSecurityOrigin();
411 411
412 WorkerClients* worker_clients = WorkerClients::Create(); 412 WorkerClients* worker_clients = WorkerClients::Create();
413 WorkerClientsInitializer<WebEmbeddedWorkerImpl>::Run(worker_clients);
414
413 ProvideContentSettingsClientToWorker(worker_clients, 415 ProvideContentSettingsClientToWorker(worker_clients,
414 std::move(content_settings_client_)); 416 std::move(content_settings_client_));
415 ProvideIndexedDBClientToWorker(worker_clients,
416 IndexedDBClientImpl::Create(*worker_clients));
417 ProvideServiceWorkerGlobalScopeClientToWorker( 417 ProvideServiceWorkerGlobalScopeClientToWorker(
418 worker_clients, 418 worker_clients,
419 ServiceWorkerGlobalScopeClientImpl::Create(*worker_context_client_)); 419 ServiceWorkerGlobalScopeClientImpl::Create(*worker_context_client_));
420 ProvideServiceWorkerContainerClientToWorker( 420 ProvideServiceWorkerContainerClientToWorker(
421 worker_clients, worker_context_client_->CreateServiceWorkerProvider()); 421 worker_clients, worker_context_client_->CreateServiceWorkerProvider());
422 422
423 if (RuntimeEnabledFeatures::OffMainThreadFetchEnabled()) { 423 if (RuntimeEnabledFeatures::OffMainThreadFetchEnabled()) {
424 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context = 424 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context =
425 worker_context_client_->CreateServiceWorkerFetchContext(); 425 worker_context_client_->CreateServiceWorkerFetchContext();
426 DCHECK(web_worker_fetch_context); 426 DCHECK(web_worker_fetch_context);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 // populate the task runners with null document not to confuse the frame 472 // populate the task runners with null document not to confuse the frame
473 // scheduler (which will end up using the thread's default task runner). 473 // scheduler (which will end up using the thread's default task runner).
474 worker_thread_->Start(std::move(startup_data), 474 worker_thread_->Start(std::move(startup_data),
475 ParentFrameTaskRunners::Create(nullptr)); 475 ParentFrameTaskRunners::Create(nullptr));
476 476
477 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(), 477 worker_inspector_proxy_->WorkerThreadCreated(document, worker_thread_.get(),
478 script_url); 478 script_url);
479 } 479 }
480 480
481 } // namespace blink 481 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/exported/WebEmbeddedWorkerImpl.h ('k') | third_party/WebKit/Source/web/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698