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

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

Issue 2804843005: Implement the infrastructure of creating WorkerFetchContext in worker global scope. (Closed)
Patch Set: incorporated yhirano's comment Created 3 years, 8 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) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 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 20 matching lines...) Expand all
31 #include "web/WebSharedWorkerImpl.h" 31 #include "web/WebSharedWorkerImpl.h"
32 32
33 #include <memory> 33 #include <memory>
34 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
35 #include "core/dom/TaskRunnerHelper.h" 35 #include "core/dom/TaskRunnerHelper.h"
36 #include "core/events/MessageEvent.h" 36 #include "core/events/MessageEvent.h"
37 #include "core/inspector/ConsoleMessage.h" 37 #include "core/inspector/ConsoleMessage.h"
38 #include "core/loader/FrameLoadRequest.h" 38 #include "core/loader/FrameLoadRequest.h"
39 #include "core/loader/FrameLoader.h" 39 #include "core/loader/FrameLoader.h"
40 #include "core/loader/ThreadableLoadingContext.h" 40 #include "core/loader/ThreadableLoadingContext.h"
41 #include "core/loader/WorkerFetchContext.h"
41 #include "core/probe/CoreProbes.h" 42 #include "core/probe/CoreProbes.h"
42 #include "core/workers/ParentFrameTaskRunners.h" 43 #include "core/workers/ParentFrameTaskRunners.h"
43 #include "core/workers/SharedWorkerGlobalScope.h" 44 #include "core/workers/SharedWorkerGlobalScope.h"
44 #include "core/workers/SharedWorkerThread.h" 45 #include "core/workers/SharedWorkerThread.h"
45 #include "core/workers/WorkerClients.h" 46 #include "core/workers/WorkerClients.h"
46 #include "core/workers/WorkerContentSettingsClient.h" 47 #include "core/workers/WorkerContentSettingsClient.h"
47 #include "core/workers/WorkerGlobalScope.h" 48 #include "core/workers/WorkerGlobalScope.h"
48 #include "core/workers/WorkerInspectorProxy.h" 49 #include "core/workers/WorkerInspectorProxy.h"
49 #include "core/workers/WorkerLoaderProxy.h" 50 #include "core/workers/WorkerLoaderProxy.h"
50 #include "core/workers/WorkerScriptLoader.h" 51 #include "core/workers/WorkerScriptLoader.h"
51 #include "core/workers/WorkerThreadStartupData.h" 52 #include "core/workers/WorkerThreadStartupData.h"
52 #include "platform/CrossThreadFunctional.h" 53 #include "platform/CrossThreadFunctional.h"
54 #include "platform/RuntimeEnabledFeatures.h"
53 #include "platform/heap/Handle.h" 55 #include "platform/heap/Handle.h"
54 #include "platform/heap/Persistent.h" 56 #include "platform/heap/Persistent.h"
55 #include "platform/loader/fetch/ResourceResponse.h" 57 #include "platform/loader/fetch/ResourceResponse.h"
56 #include "platform/network/ContentSecurityPolicyParsers.h" 58 #include "platform/network/ContentSecurityPolicyParsers.h"
57 #include "platform/weborigin/KURL.h" 59 #include "platform/weborigin/KURL.h"
58 #include "platform/weborigin/SecurityOrigin.h" 60 #include "platform/weborigin/SecurityOrigin.h"
59 #include "platform/wtf/Functional.h" 61 #include "platform/wtf/Functional.h"
60 #include "platform/wtf/PtrUtil.h" 62 #include "platform/wtf/PtrUtil.h"
61 #include "public/platform/Platform.h" 63 #include "public/platform/Platform.h"
62 #include "public/platform/WebMessagePortChannel.h" 64 #include "public/platform/WebMessagePortChannel.h"
63 #include "public/platform/WebString.h" 65 #include "public/platform/WebString.h"
64 #include "public/platform/WebURL.h" 66 #include "public/platform/WebURL.h"
65 #include "public/platform/WebURLRequest.h" 67 #include "public/platform/WebURLRequest.h"
68 #include "public/platform/WebWorkerFetchContext.h"
66 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h" 69 #include "public/platform/modules/serviceworker/WebServiceWorkerNetworkProvider. h"
67 #include "public/web/WebDevToolsAgent.h" 70 #include "public/web/WebDevToolsAgent.h"
68 #include "public/web/WebFrame.h" 71 #include "public/web/WebFrame.h"
69 #include "public/web/WebSettings.h" 72 #include "public/web/WebSettings.h"
70 #include "public/web/WebView.h" 73 #include "public/web/WebView.h"
71 #include "public/web/WebWorkerContentSettingsClientProxy.h" 74 #include "public/web/WebWorkerContentSettingsClientProxy.h"
72 #include "web/IndexedDBClientImpl.h" 75 #include "web/IndexedDBClientImpl.h"
73 #include "web/LocalFileSystemClient.h" 76 #include "web/LocalFileSystemClient.h"
74 #include "web/WebDataSourceImpl.h" 77 #include "web/WebDataSourceImpl.h"
75 #include "web/WebLocalFrameImpl.h" 78 #include "web/WebLocalFrameImpl.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 WorkerClients* worker_clients = WorkerClients::Create(); 338 WorkerClients* worker_clients = WorkerClients::Create();
336 ProvideLocalFileSystemToWorker(worker_clients, 339 ProvideLocalFileSystemToWorker(worker_clients,
337 LocalFileSystemClient::Create()); 340 LocalFileSystemClient::Create());
338 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin()); 341 WebSecurityOrigin web_security_origin(loading_document_->GetSecurityOrigin());
339 ProvideContentSettingsClientToWorker( 342 ProvideContentSettingsClientToWorker(
340 worker_clients, 343 worker_clients,
341 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy( 344 WTF::WrapUnique(client_->CreateWorkerContentSettingsClientProxy(
342 web_security_origin))); 345 web_security_origin)));
343 ProvideIndexedDBClientToWorker(worker_clients, 346 ProvideIndexedDBClientToWorker(worker_clients,
344 IndexedDBClientImpl::Create(*worker_clients)); 347 IndexedDBClientImpl::Create(*worker_clients));
348
349 if (RuntimeEnabledFeatures::offMainThreadFetchEnabled()) {
350 std::unique_ptr<WebWorkerFetchContext> web_worker_fetch_context =
351 client_->CreateWorkerFetchContext(
352 WebLocalFrameImpl::FromFrame(main_frame_->GetFrame())
353 ->DataSource()
354 ->GetServiceWorkerNetworkProvider());
355 DCHECK(web_worker_fetch_context);
356 // TODO(horo): Set more information about the context (ex: DataSaverEnabled)
357 // to |web_worker_fetch_context|.
358 ProvideWorkerFetchContextToWorker(worker_clients,
359 std::move(web_worker_fetch_context));
360 }
361
345 ContentSecurityPolicy* content_security_policy = 362 ContentSecurityPolicy* content_security_policy =
346 main_script_loader_->ReleaseContentSecurityPolicy(); 363 main_script_loader_->ReleaseContentSecurityPolicy();
347 WorkerThreadStartMode start_mode = 364 WorkerThreadStartMode start_mode =
348 worker_inspector_proxy_->WorkerStartMode(document); 365 worker_inspector_proxy_->WorkerStartMode(document);
349 std::unique_ptr<WorkerSettings> worker_settings = 366 std::unique_ptr<WorkerSettings> worker_settings =
350 WTF::WrapUnique(new WorkerSettings(document->GetSettings())); 367 WTF::WrapUnique(new WorkerSettings(document->GetSettings()));
351 std::unique_ptr<WorkerThreadStartupData> startup_data = 368 std::unique_ptr<WorkerThreadStartupData> startup_data =
352 WorkerThreadStartupData::Create( 369 WorkerThreadStartupData::Create(
353 url_, loading_document_->UserAgent(), 370 url_, loading_document_->UserAgent(),
354 main_script_loader_->SourceText(), nullptr, start_mode, 371 main_script_loader_->SourceText(), nullptr, start_mode,
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 if (devtools_agent) 441 if (devtools_agent)
425 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method, 442 devtools_agent->DispatchOnInspectorBackend(session_id, call_id, method,
426 message); 443 message);
427 } 444 }
428 445
429 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) { 446 WebSharedWorker* WebSharedWorker::Create(WebSharedWorkerClient* client) {
430 return new WebSharedWorkerImpl(client); 447 return new WebSharedWorkerImpl(client);
431 } 448 }
432 449
433 } // namespace blink 450 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698