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

Unified Diff: content/browser/service_worker/embedded_worker_instance.cc

Issue 2958753003: Revert "Create ServiceWorkerProviderHost before starting worker" (Closed)
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
Index: content/browser/service_worker/embedded_worker_instance.cc
diff --git a/content/browser/service_worker/embedded_worker_instance.cc b/content/browser/service_worker/embedded_worker_instance.cc
index 38d7534e03515b41f92a603479d89eb2e1948554..7ac981841f58a473f30c4378acaa235e6790f54a 100644
--- a/content/browser/service_worker/embedded_worker_instance.cc
+++ b/content/browser/service_worker/embedded_worker_instance.cc
@@ -440,7 +440,6 @@ EmbeddedWorkerInstance::~EmbeddedWorkerInstance() {
void EmbeddedWorkerInstance::Start(
std::unique_ptr<EmbeddedWorkerStartParams> params,
- ProviderInfoGetter provider_info_getter,
mojom::ServiceWorkerEventDispatcherRequest dispatcher_request,
const StatusCallback& callback) {
restart_count_++;
@@ -457,8 +456,6 @@ void EmbeddedWorkerInstance::Start(
status_ = EmbeddedWorkerStatus::STARTING;
starting_phase_ = ALLOCATING_PROCESS;
network_accessed_for_script_ = false;
- provider_info_getter_ = std::move(provider_info_getter);
-
for (auto& observer : listener_list_)
observer.OnStarting();
@@ -471,6 +468,7 @@ void EmbeddedWorkerInstance::Start(
mojo::MakeRequest(&client_);
client_.set_connection_error_handler(
base::Bind(&CallDetach, base::Unretained(this)));
+
pending_dispatcher_request_ = std::move(dispatcher_request);
inflight_start_task_.reset(
@@ -596,13 +594,10 @@ ServiceWorkerStatusCode EmbeddedWorkerInstance::SendStartWorker(
mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo host_ptr_info;
instance_host_binding_.Bind(mojo::MakeRequest(&host_ptr_info));
- mojom::ServiceWorkerProviderInfoForStartWorkerPtr provider_info =
- std::move(provider_info_getter_).Run(process_id());
-
+ DCHECK(pending_dispatcher_request_.is_pending());
client_->StartWorker(*params, std::move(pending_dispatcher_request_),
- std::move(host_ptr_info), std::move(provider_info));
+ std::move(host_ptr_info));
registry_->BindWorkerToProcess(process_id(), embedded_worker_id());
-
OnStartWorkerMessageSent();
// Once the start worker message is received, renderer side will prepare a
// shadow page for getting worker script.
@@ -706,10 +701,20 @@ void EmbeddedWorkerInstance::OnWorkerVersionDoomed() {
devtools_proxy_->NotifyWorkerVersionDoomed();
}
-void EmbeddedWorkerInstance::OnThreadStarted(int thread_id) {
+void EmbeddedWorkerInstance::OnThreadStarted(int thread_id, int provider_id) {
if (!context_ || !inflight_start_task_)
return;
+ ServiceWorkerProviderHost* provider_host =
+ context_->GetProviderHost(process_id(), provider_id);
+ if (!provider_host) {
+ bad_message::ReceivedBadMessage(
+ process_id(), bad_message::SWDH_WORKER_SCRIPT_LOAD_NO_HOST);
+ return;
+ }
+
+ provider_host->SetReadyToSendMessagesToWorker(thread_id);
+
TRACE_EVENT_NESTABLE_ASYNC_END0("ServiceWorker", "LAUNCHING_WORKER_THREAD",
this);
// Renderer side has started to evaluate the loaded worker script.
@@ -806,8 +811,6 @@ void EmbeddedWorkerInstance::OnDetached() {
}
void EmbeddedWorkerInstance::Detach() {
- if (status() == EmbeddedWorkerStatus::STOPPED)
- return;
registry_->DetachWorker(process_id(), embedded_worker_id());
OnDetached();
}
@@ -889,6 +892,7 @@ void EmbeddedWorkerInstance::ReleaseProcess() {
// Abort an inflight start task.
inflight_start_task_.reset();
+ client_.reset();
instance_host_binding_.Close();
devtools_proxy_.reset();
process_handle_.reset();

Powered by Google App Engine
This is Rietveld 408576698