Chromium Code Reviews| 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 3a3e9692d03c51fa323087705c6a688dade61749..ff718073ab85019c0478131e12359f7addbefcd5 100644 |
| --- a/content/browser/service_worker/embedded_worker_instance.cc |
| +++ b/content/browser/service_worker/embedded_worker_instance.cc |
| @@ -457,8 +457,11 @@ void EmbeddedWorkerInstance::Start( |
| params->settings.v8_cache_options = GetV8CacheOptions(); |
| mojom::EmbeddedWorkerInstanceClientRequest request; |
| - if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) |
| + if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| request = mojo::GetProxy(&client_); |
| + client_.set_connection_error_handler( |
| + base::Bind(&EmbeddedWorkerInstance::Detach, AsWeakPtr())); |
|
dcheng
2016/09/30 08:25:28
It should be unnecessary to use AsWeakPtr() here.
shimazu
2016/10/06 03:50:51
Done.
|
| + } |
| inflight_start_task_.reset( |
| new StartTask(this, params->script_url, std::move(request))); |
| @@ -473,8 +476,15 @@ ServiceWorkerStatusCode EmbeddedWorkerInstance::Stop() { |
| // Abort an inflight start task. |
| inflight_start_task_.reset(); |
| - ServiceWorkerStatusCode status = |
| - registry_->StopWorker(process_id(), embedded_worker_id_); |
| + ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_IPC_FAILED; |
| + if (ServiceWorkerUtils::IsMojoForServiceWorkerEnabled()) { |
| + status = SERVICE_WORKER_OK; |
| + client_->StopWorker(base::Bind(&EmbeddedWorkerRegistry::OnWorkerStopped, |
| + base::Unretained(registry_.get()), |
| + process_id(), embedded_worker_id())); |
| + } else { |
| + status = registry_->StopWorker(process_id(), embedded_worker_id_); |
| + } |
| UMA_HISTOGRAM_ENUMERATION("ServiceWorker.SendStopWorker.Status", status, |
| SERVICE_WORKER_ERROR_MAX_VALUE); |
| // StopWorker could fail if we were starting up and don't have a process yet, |
| @@ -752,7 +762,7 @@ void EmbeddedWorkerInstance::OnDetached() { |
| } |
| void EmbeddedWorkerInstance::Detach() { |
| - registry_->RemoveWorker(process_id(), embedded_worker_id_); |
| + registry_->DetachWorker(process_id(), embedded_worker_id()); |
| OnDetached(); |
| } |
| @@ -832,6 +842,7 @@ void EmbeddedWorkerInstance::ReleaseProcess() { |
| // Abort an inflight start task. |
| inflight_start_task_.reset(); |
| + client_.reset(); |
| devtools_proxy_.reset(); |
| process_handle_.reset(); |
| status_ = EmbeddedWorkerStatus::STOPPED; |