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

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

Issue 2779763004: Create ServiceWorkerProviderHost before starting worker (Closed)
Patch Set: Pass the param of BindWithProviderInfo by value instead of pointer 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') | tools/metrics/histograms/enums.xml » ('j') | 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..d35286ebcc15b3e2c8294167d9738f1d9ea9483f 100644
--- a/content/renderer/service_worker/service_worker_context_client.cc
+++ b/content/renderer/service_worker/service_worker_context_client.cc
@@ -554,6 +554,7 @@ ServiceWorkerContextClient::ServiceWorkerContextClient(
const GURL& script_url,
mojom::ServiceWorkerEventDispatcherRequest dispatcher_request,
mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderInfoForStartWorkerPtr provider_info,
std::unique_ptr<EmbeddedWorkerInstanceClientImpl> embedded_worker_client)
: embedded_worker_id_(embedded_worker_id),
service_worker_version_id_(service_worker_version_id),
@@ -575,6 +576,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_info));
+ provider_context_ = pending_network_provider_->context();
}
ServiceWorkerContextClient::~ServiceWorkerContextClient() {}
@@ -716,9 +722,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 +1098,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 +1116,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') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698