| 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_info.h" | 8 #include "content/browser/service_worker/service_worker_info.h" |
| 9 #include "content/browser/service_worker/service_worker_register_job.h" | 9 #include "content/browser/service_worker/service_worker_register_job.h" |
| 10 #include "content/browser/service_worker/service_worker_utils.h" | 10 #include "content/browser/service_worker/service_worker_utils.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 if (status != SERVICE_WORKER_OK) { | 296 if (status != SERVICE_WORKER_OK) { |
| 297 // "11. If activateFailed is true, then:..." | 297 // "11. If activateFailed is true, then:..." |
| 298 UnsetVersion(activating_version); | 298 UnsetVersion(activating_version); |
| 299 activating_version->Doom(); | 299 activating_version->Doom(); |
| 300 if (!waiting_version()) { | 300 if (!waiting_version()) { |
| 301 // Delete the records from the db. | 301 // Delete the records from the db. |
| 302 context_->storage()->DeleteRegistration( | 302 context_->storage()->DeleteRegistration( |
| 303 id(), pattern().GetOrigin(), | 303 id(), pattern().GetOrigin(), |
| 304 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this)); | 304 base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this)); |
| 305 // But not from memory if there is a version in the pipeline. | 305 // But not from memory if there is a version in the pipeline. |
| 306 if (installing_version()) | 306 if (installing_version()) { |
| 307 is_deleted_ = false; | 307 is_deleted_ = false; |
| 308 else | 308 } else { |
| 309 is_uninstalled_ = true; | 309 is_uninstalled_ = true; |
| 310 FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this)); |
| 311 } |
| 310 } | 312 } |
| 311 return; | 313 return; |
| 312 } | 314 } |
| 313 | 315 |
| 314 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker | 316 // "12. Run the [[UpdateState]] algorithm passing registration.activeWorker |
| 315 // and "activated" as the arguments." | 317 // and "activated" as the arguments." |
| 316 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED); | 318 activating_version->SetStatus(ServiceWorkerVersion::ACTIVATED); |
| 317 if (context_) { | 319 if (context_) { |
| 318 context_->storage()->UpdateToActiveState( | 320 context_->storage()->UpdateToActiveState( |
| 319 this, | 321 this, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 348 active_version_->Doom(); | 350 active_version_->Doom(); |
| 349 active_version_->RemoveListener(this); | 351 active_version_->RemoveListener(this); |
| 350 active_version_ = NULL; | 352 active_version_ = NULL; |
| 351 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); | 353 mask.add(ChangedVersionAttributesMask::ACTIVE_VERSION); |
| 352 } | 354 } |
| 353 if (mask.changed()) { | 355 if (mask.changed()) { |
| 354 ServiceWorkerRegistrationInfo info = GetInfo(); | 356 ServiceWorkerRegistrationInfo info = GetInfo(); |
| 355 FOR_EACH_OBSERVER(Listener, listeners_, | 357 FOR_EACH_OBSERVER(Listener, listeners_, |
| 356 OnVersionAttributesChanged(this, mask, info)); | 358 OnVersionAttributesChanged(this, mask, info)); |
| 357 } | 359 } |
| 360 |
| 361 FOR_EACH_OBSERVER( |
| 362 Listener, listeners_, OnRegistrationFinishedUninstalling(this)); |
| 358 } | 363 } |
| 359 | 364 |
| 360 void ServiceWorkerRegistration::OnRestoreFinished( | 365 void ServiceWorkerRegistration::OnRestoreFinished( |
| 361 const StatusCallback& callback, | 366 const StatusCallback& callback, |
| 362 scoped_refptr<ServiceWorkerVersion> version, | 367 scoped_refptr<ServiceWorkerVersion> version, |
| 363 ServiceWorkerStatusCode status) { | 368 ServiceWorkerStatusCode status) { |
| 364 if (!context_) { | 369 if (!context_) { |
| 365 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 370 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 366 return; | 371 return; |
| 367 } | 372 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 if (registration && | 413 if (registration && |
| 409 (registration->is_uninstalling() || registration->is_uninstalled())) | 414 (registration->is_uninstalling() || registration->is_uninstalled())) |
| 410 continue; | 415 continue; |
| 411 if (matcher.MatchLongest(info.pattern)) | 416 if (matcher.MatchLongest(info.pattern)) |
| 412 return false; | 417 return false; |
| 413 } | 418 } |
| 414 return true; | 419 return true; |
| 415 } | 420 } |
| 416 | 421 |
| 417 } // namespace content | 422 } // namespace content |
| OLD | NEW |