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 b728eca653e94cdff0386b4b1e5bec12505c5166..48134cdd64d2281517d2de703de1407f2bf016ad 100644 |
| --- a/content/browser/service_worker/service_worker_register_job.cc |
| +++ b/content/browser/service_worker/service_worker_register_job.cc |
| @@ -69,8 +69,7 @@ void ServiceWorkerRegisterJob::AddCallback( |
| return; |
| } |
| RunSoon(base::Bind( |
| - callback, promise_resolved_status_, |
| - promise_resolved_registration_, promise_resolved_version_)); |
| + callback, promise_resolved_status_, promise_resolved_registration_)); |
| } |
| void ServiceWorkerRegisterJob::Start() { |
| @@ -292,18 +291,18 @@ void ServiceWorkerRegisterJob::ContinueWithRegistrationForSameScriptUrl( |
| } |
| set_registration(existing_registration); |
| - // TODO(falken): Follow the spec: resolve the promise |
| - // with the newest version. |
| - |
| - if (!existing_registration->active_version()) { |
| - UpdateAndContinue(); |
| + // "If newestWorker is not null, and scriptURL is equal to |
| + // newestWorker.scriptURL, then: |
| + // Return a promise resolved with registration." |
| + if (existing_registration->GetNewestVersion()) { |
|
nhiroki
2014/09/26 09:35:53
The CL description says...
|
| + ResolvePromise(status, existing_registration.get()); |
| + Complete(SERVICE_WORKER_OK); |
| return; |
| } |
| - ResolvePromise(status, |
| - existing_registration.get(), |
| - existing_registration->active_version()); |
| - Complete(SERVICE_WORKER_OK); |
| + // "Return the result of running the [[Update]] algorithm, or its equivalent, |
| + // passing registration as the argument." |
| + UpdateAndContinue(); |
| } |
| // This function corresponds to the spec's [[Update]] algorithm. |
| @@ -371,7 +370,7 @@ void ServiceWorkerRegisterJob::InstallAndContinue() { |
| registration()->SetInstallingVersion(new_version()); |
| // "3. Resolve promise with registration." |
| - ResolvePromise(SERVICE_WORKER_OK, registration(), new_version()); |
| + ResolvePromise(SERVICE_WORKER_OK, registration()); |
| // "4. Run the [[UpdateState]] algorithm passing registration.installingWorker |
| // and "installing" as the arguments." |
| @@ -462,7 +461,7 @@ void ServiceWorkerRegisterJob::CompleteInternal( |
| } |
| } |
| if (!is_promise_resolved_) |
| - ResolvePromise(status, NULL, NULL); |
| + ResolvePromise(status, NULL); |
| } |
| DCHECK(callbacks_.empty()); |
| if (registration()) { |
| @@ -475,17 +474,15 @@ void ServiceWorkerRegisterJob::CompleteInternal( |
| void ServiceWorkerRegisterJob::ResolvePromise( |
| ServiceWorkerStatusCode status, |
| - ServiceWorkerRegistration* registration, |
| - ServiceWorkerVersion* version) { |
| + ServiceWorkerRegistration* registration) { |
| DCHECK(!is_promise_resolved_); |
| is_promise_resolved_ = true; |
| promise_resolved_status_ = status; |
| promise_resolved_registration_ = registration; |
| - promise_resolved_version_ = version; |
| for (std::vector<RegistrationCallback>::iterator it = callbacks_.begin(); |
| it != callbacks_.end(); |
| ++it) { |
| - it->Run(status, registration, version); |
| + it->Run(status, registration); |
| } |
| callbacks_.clear(); |
| } |
| @@ -506,10 +503,10 @@ void ServiceWorkerRegisterJob::OnPausedAfterDownload() { |
| // is being downloaded and to avoid writing it to disk until we know |
| // its needed. |
| context_->storage()->CompareScriptResources( |
| - most_recent_script_id, new_script_id, |
| + most_recent_script_id, |
| + new_script_id, |
| base::Bind(&ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete, |
| - weak_factory_.GetWeakPtr(), |
| - most_recent_version)); |
| + weak_factory_.GetWeakPtr())); |
| } |
| bool ServiceWorkerRegisterJob::OnMessageReceived(const IPC::Message& message) { |
| @@ -526,7 +523,6 @@ void ServiceWorkerRegisterJob::OnRegistrationFinishedUninstalling( |
| } |
| void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete( |
| - ServiceWorkerVersion* most_recent_version, |
| ServiceWorkerStatusCode status, |
| bool are_equal) { |
| if (are_equal) { |
| @@ -538,7 +534,7 @@ void ServiceWorkerRegisterJob::OnCompareScriptResourcesComplete( |
| context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| } |
| - ResolvePromise(SERVICE_WORKER_OK, registration(), most_recent_version); |
| + ResolvePromise(SERVICE_WORKER_OK, registration()); |
| Complete(SERVICE_WORKER_ERROR_EXISTS); |
| return; |
| } |