| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/service_worker/service_worker_register_job.h" | 5 #include "content/browser/service_worker/service_worker_register_job.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Throughout this file, comments in quotes are excerpts from the spec. | 190 // Throughout this file, comments in quotes are excerpts from the spec. |
| 191 void ServiceWorkerRegisterJob::ContinueWithRegistration( | 191 void ServiceWorkerRegisterJob::ContinueWithRegistration( |
| 192 ServiceWorkerStatusCode status, | 192 ServiceWorkerStatusCode status, |
| 193 const scoped_refptr<ServiceWorkerRegistration>& existing_registration) { | 193 const scoped_refptr<ServiceWorkerRegistration>& existing_registration) { |
| 194 DCHECK_EQ(REGISTRATION_JOB, job_type_); | 194 DCHECK_EQ(REGISTRATION_JOB, job_type_); |
| 195 if (status != SERVICE_WORKER_ERROR_NOT_FOUND && status != SERVICE_WORKER_OK) { | 195 if (status != SERVICE_WORKER_ERROR_NOT_FOUND && status != SERVICE_WORKER_OK) { |
| 196 Complete(status); | 196 Complete(status); |
| 197 return; | 197 return; |
| 198 } | 198 } |
| 199 | 199 |
| 200 if (!existing_registration.get()) { | 200 if (!existing_registration.get() || existing_registration->is_uninstalled()) { |
| 201 RegisterAndContinue(SERVICE_WORKER_OK); | 201 RegisterAndContinue(SERVICE_WORKER_OK); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 DCHECK(existing_registration->GetNewestVersion()); |
| 205 // "If scriptURL is equal to registration.[[ScriptURL]], then:" | 206 // "If scriptURL is equal to registration.[[ScriptURL]], then:" |
| 206 if (existing_registration->GetNewestVersion()->script_url() == script_url_) { | 207 if (existing_registration->GetNewestVersion()->script_url() == script_url_) { |
| 207 // "Set registration.[[Uninstalling]] to false." | 208 // "Set registration.[[Uninstalling]] to false." |
| 208 existing_registration->AbortPendingClear(base::Bind( | 209 existing_registration->AbortPendingClear(base::Bind( |
| 209 &ServiceWorkerRegisterJob::ContinueWithRegistrationForSameScriptUrl, | 210 &ServiceWorkerRegisterJob::ContinueWithRegistrationForSameScriptUrl, |
| 210 weak_factory_.GetWeakPtr(), | 211 weak_factory_.GetWeakPtr(), |
| 211 existing_registration)); | 212 existing_registration)); |
| 212 return; | 213 return; |
| 213 } | 214 } |
| 214 | 215 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 537 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 537 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 538 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| 538 host->document_url())) { | 539 host->document_url())) { |
| 539 if (host->CanAssociateRegistration(registration)) | 540 if (host->CanAssociateRegistration(registration)) |
| 540 host->AssociateRegistration(registration); | 541 host->AssociateRegistration(registration); |
| 541 } | 542 } |
| 542 } | 543 } |
| 543 } | 544 } |
| 544 | 545 |
| 545 } // namespace content | 546 } // namespace content |
| OLD | NEW |