Chromium Code Reviews| Index: content/browser/service_worker/service_worker_register_job.cc |
| diff --git a/content/browser/service_worker/service_worker_register_job.cc b/content/browser/service_worker/service_worker_register_job.cc |
| index 149502cddbd0e1e7bb1afe57312536b211c7c019..e929bb443153826f9cd1b9e2db151c8bad2096a8 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -410,7 +410,7 @@ void ServiceWorkerRegisterJob::InstallAndContinue() { |
| ServiceWorkerMetrics::EventType::INSTALL, |
| base::Bind(&ServiceWorkerRegisterJob::DispatchInstallEvent, |
| weak_factory_.GetWeakPtr()), |
| - base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
| + base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed, |
| weak_factory_.GetWeakPtr())); |
| // A subsequent registration job may terminate our installing worker. It can |
| @@ -427,18 +427,27 @@ void ServiceWorkerRegisterJob::DispatchInstallEvent() { |
| << "Worker stopped too soon after it was started."; |
| int request_id = new_version()->StartRequest( |
| ServiceWorkerMetrics::EventType::INSTALL, |
| + base::Bind(&ServiceWorkerRegisterJob::OnInstallFailed, |
| + weak_factory_.GetWeakPtr())); |
| + new_version()->DispatchEvent<ServiceWorkerHostMsg_InstallEventFinished>( |
| + request_id, ServiceWorkerMsg_InstallEvent(request_id), |
| base::Bind(&ServiceWorkerRegisterJob::OnInstallFinished, |
| weak_factory_.GetWeakPtr())); |
| - new_version()->DispatchSimpleEvent<ServiceWorkerHostMsg_InstallEventFinished>( |
| - request_id, ServiceWorkerMsg_InstallEvent(request_id)); |
| } |
| void ServiceWorkerRegisterJob::OnInstallFinished( |
| - ServiceWorkerStatusCode status) { |
| - ServiceWorkerMetrics::RecordInstallEventStatus(status); |
| + int request_id, |
| + blink::WebServiceWorkerEventResult result, |
| + bool has_fetch_handler) { |
| + new_version()->FinishRequest( |
| + request_id, result == blink::WebServiceWorkerEventResultCompleted); |
| + ServiceWorkerStatusCode status = SERVICE_WORKER_OK; |
| + if (result == blink::WebServiceWorkerEventResultRejected) |
| + status = SERVICE_WORKER_ERROR_EVENT_WAITUNTIL_REJECTED; |
|
falken
2016/05/24 06:25:48
This construct is a bit scary. If we someday add a
shimazu
2016/05/24 08:30:27
Done.
|
| + |
| + ServiceWorkerMetrics::RecordInstallEventStatus(status); |
|
falken
2016/05/24 06:25:48
I think you need this in OnInstallFailed() also.
shimazu
2016/05/24 08:30:27
Done.
|
| if (status != SERVICE_WORKER_OK) { |
| - // "8. If installFailed is true, then:..." |
| Complete(status, std::string("ServiceWorker failed to install: ") + |
| ServiceWorkerStatusToString(status)); |
|
falken
2016/05/24 06:25:48
Prefer to call OnInstallFailed over copy/pasting t
shimazu
2016/05/24 08:30:27
Done.
|
| return; |
| @@ -446,6 +455,7 @@ void ServiceWorkerRegisterJob::OnInstallFinished( |
| SetPhase(STORE); |
| DCHECK(!registration()->last_update_check().is_null()); |
| + new_version()->set_has_fetch_handler(has_fetch_handler); |
| context_->storage()->StoreRegistration( |
| registration(), |
| new_version(), |
| @@ -453,6 +463,15 @@ void ServiceWorkerRegisterJob::OnInstallFinished( |
| weak_factory_.GetWeakPtr())); |
| } |
| +void ServiceWorkerRegisterJob::OnInstallFailed(ServiceWorkerStatusCode status) { |
| + if (status != SERVICE_WORKER_OK) { |
| + Complete(status, std::string("ServiceWorker failed to install: ") + |
| + ServiceWorkerStatusToString(status)); |
| + } else { |
| + NOTREACHED() << "OnInstallFailed should not handle SERVICE_WORKER_OK"; |
| + } |
| +} |
| + |
| void ServiceWorkerRegisterJob::OnStoreRegistrationComplete( |
| ServiceWorkerStatusCode status) { |
| if (status != SERVICE_WORKER_OK) { |