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

Unified Diff: content/renderer/service_worker/service_worker_context_client.cc

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
Patch Set: . 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/service_worker_context_client.cc
diff --git a/content/renderer/service_worker/service_worker_context_client.cc b/content/renderer/service_worker/service_worker_context_client.cc
index 60821cc41360dee0f721d75a029affa6f6a55120..84e6ae5e82c2cf77f612b98968247dec6e9dcb38 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -100,6 +100,8 @@ class WebServiceWorkerNetworkProviderImpl
// Service workers are only available in secure contexts, so all requests
// are initiated in a secure context.
extra_data->set_initiated_in_secure_context(true);
+ extra_data->set_url_loader_factory_override(
+ provider_->script_loader_factory());
request.SetExtraData(extra_data.release());
}
@@ -554,6 +556,7 @@ ServiceWorkerContextClient::ServiceWorkerContextClient(
const GURL& script_url,
mojom::ServiceWorkerEventDispatcherRequest dispatcher_request,
mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderClientInfoPtr provider_client_info,
std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client)
: embedded_worker_id_(embedded_worker_id),
service_worker_version_id_(service_worker_version_id),
@@ -575,6 +578,11 @@ ServiceWorkerContextClient::ServiceWorkerContextClient(
"ServiceWorkerContextClient::StartingWorkerContext",
this,
"PrepareWorker");
+ // Create a content::ServiceWorkerNetworkProvider for this data source so
+ // we can observe its requests.
+ pending_network_provider_ = base::MakeUnique<ServiceWorkerNetworkProvider>(
+ std::move(provider_client_info));
+ provider_context_ = pending_network_provider_->context();
}
ServiceWorkerContextClient::~ServiceWorkerContextClient() {}
@@ -716,9 +724,7 @@ void ServiceWorkerContextClient::WorkerContextStarted(
SetRegistrationInServiceWorkerGlobalScope(registration_info, version_attrs);
- (*instance_host_)
- ->OnThreadStarted(WorkerThread::GetCurrentId(),
- provider_context_->provider_id());
+ (*instance_host_)->OnThreadStarted(WorkerThread::GetCurrentId());
TRACE_EVENT_ASYNC_STEP_INTO0(
"ServiceWorker",
@@ -1094,23 +1100,9 @@ void ServiceWorkerContextClient::DidHandlePaymentRequestEvent(
std::unique_ptr<blink::WebServiceWorkerNetworkProvider>
ServiceWorkerContextClient::CreateServiceWorkerNetworkProvider() {
DCHECK(main_thread_task_runner_->RunsTasksInCurrentSequence());
-
- // Create a content::ServiceWorkerNetworkProvider for this data source so
- // we can observe its requests.
- std::unique_ptr<ServiceWorkerNetworkProvider> provider =
- base::MakeUnique<ServiceWorkerNetworkProvider>(
- MSG_ROUTING_NONE, SERVICE_WORKER_PROVIDER_FOR_CONTROLLER,
- true /* is_parent_frame_secure */);
- provider_context_ = provider->context();
- network_provider_id_ = provider->provider_id();
-
- // Tell the network provider about which version to load.
- provider->SetServiceWorkerVersionId(service_worker_version_id_,
- embedded_worker_id_);
-
// Blink is responsible for deleting the returned object.
return base::MakeUnique<WebServiceWorkerNetworkProviderImpl>(
- std::move(provider));
+ std::move(pending_network_provider_));
}
std::unique_ptr<blink::WebWorkerFetchContext>
@@ -1126,7 +1118,7 @@ ServiceWorkerContextClient::CreateServiceWorkerFetchContext() {
// Blink is responsible for deleting the returned object.
return base::MakeUnique<ServiceWorkerFetchContextImpl>(
script_url_, worker_url_loader_factory_provider.PassInterface(),
- network_provider_id_);
+ provider_context_->provider_id());
}
std::unique_ptr<blink::WebServiceWorkerProvider>
« no previous file with comments | « content/renderer/service_worker/service_worker_context_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698