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 0f7e5303406f20b2d3999c061a538e385a3d7bcc..ff7591fc36ba3e823208befcc2cae2a91c18c9ab 100644 |
| --- a/content/browser/service_worker/embedded_worker_instance.cc |
| +++ b/content/browser/service_worker/embedded_worker_instance.cc |
| @@ -462,6 +462,8 @@ void EmbeddedWorkerInstance::Start( |
| mojom::EmbeddedWorkerInstanceClientRequest request = |
| GetProxy(&instance_client_); |
| + instance_client_.set_connection_error_handler( |
| + base::Bind(&EmbeddedWorkerInstance::Detach, AsWeakPtr())); |
| inflight_start_task_.reset( |
| new StartTask(this, params->script_url, std::move(request))); |
| @@ -476,8 +478,19 @@ 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()) { |
| + if (!instance_client_) { |
| + registry_->OnWorkerStopped(process_id(), embedded_worker_id()); |
| + return SERVICE_WORKER_ERROR_IPC_FAILED; |
| + } |
| + status = SERVICE_WORKER_OK; |
| + instance_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, |
| @@ -772,7 +785,7 @@ void EmbeddedWorkerInstance::OnDetached() { |
| } |
| void EmbeddedWorkerInstance::Detach() { |
| - registry_->RemoveWorker(process_id(), embedded_worker_id_); |
| + registry_->DetachWorker(process_id(), embedded_worker_id()); |
|
horo
2016/09/05 08:05:57
Could you please explain why you don't erase the E
shimazu
2016/09/06 08:53:59
If I understand correctly, EmbeddedWorkerInstance
horo
2016/09/13 08:25:32
I see.
But I think the name of the error handler
|
| OnDetached(); |
| } |
| @@ -852,6 +865,7 @@ void EmbeddedWorkerInstance::ReleaseProcess() { |
| // Abort an inflight start task. |
| inflight_start_task_.reset(); |
| + instance_client_.reset(); |
| devtools_proxy_.reset(); |
| process_handle_.reset(); |
| status_ = EmbeddedWorkerStatus::STOPPED; |