Chromium Code Reviews| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "content/browser/service_worker/embedded_worker_status.h" | 9 #include "content/browser/service_worker/embedded_worker_status.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 } | 248 } |
| 249 | 249 |
| 250 void ServiceWorkerRegistration::OnNoControllees(ServiceWorkerVersion* version) { | 250 void ServiceWorkerRegistration::OnNoControllees(ServiceWorkerVersion* version) { |
| 251 if (!context_) | 251 if (!context_) |
| 252 return; | 252 return; |
| 253 DCHECK_EQ(active_version(), version); | 253 DCHECK_EQ(active_version(), version); |
| 254 if (is_uninstalling_) | 254 if (is_uninstalling_) |
| 255 Clear(); | 255 Clear(); |
| 256 else if (should_activate_when_ready_) | 256 else if (should_activate_when_ready_) |
| 257 ActivateWaitingVersion(true); | 257 ActivateWaitingVersion(true); |
| 258 is_uninstalling_ = false; | |
| 259 should_activate_when_ready_ = false; | |
| 260 } | 258 } |
| 261 | 259 |
| 262 void ServiceWorkerRegistration::ActivateWaitingVersion(bool delay) { | 260 void ServiceWorkerRegistration::ActivateWaitingVersion(bool delay) { |
| 263 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 261 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 264 DCHECK(context_); | 262 DCHECK(context_); |
| 265 DCHECK(waiting_version()); | 263 DCHECK(waiting_version()); |
| 266 DCHECK(should_activate_when_ready_); | 264 DCHECK(should_activate_when_ready_); |
| 267 should_activate_when_ready_ = false; | 265 should_activate_when_ready_ = false; |
| 268 scoped_refptr<ServiceWorkerVersion> activating_version = waiting_version(); | 266 scoped_refptr<ServiceWorkerVersion> activating_version = waiting_version(); |
| 269 scoped_refptr<ServiceWorkerVersion> exiting_version = active_version(); | 267 scoped_refptr<ServiceWorkerVersion> exiting_version = active_version(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 422 context_->storage()->UpdateToActiveState( | 420 context_->storage()->UpdateToActiveState( |
| 423 this, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 421 this, base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 424 } | 422 } |
| 425 | 423 |
| 426 void ServiceWorkerRegistration::OnDeleteFinished( | 424 void ServiceWorkerRegistration::OnDeleteFinished( |
| 427 ServiceWorkerStatusCode status) { | 425 ServiceWorkerStatusCode status) { |
| 428 // Intentionally empty completion callback, used to prevent | 426 // Intentionally empty completion callback, used to prevent |
| 429 // |this| from being deleted until the storage method completes. | 427 // |this| from being deleted until the storage method completes. |
| 430 } | 428 } |
| 431 | 429 |
| 432 void ServiceWorkerRegistration::Clear() { | 430 void ServiceWorkerRegistration::Clear() { |
|
nhiroki
2016/07/04 07:53:38
How about checking pre-conditions before flipping
falken
2016/07/04 08:14:37
Unfortunately I'm not 100% sure those hold. Since
nhiroki
2016/07/04 08:39:05
Acknowledged.
| |
| 433 is_uninstalling_ = false; | 431 is_uninstalling_ = false; |
| 434 is_uninstalled_ = true; | 432 is_uninstalled_ = true; |
| 433 should_activate_when_ready_ = false; | |
| 435 if (context_) | 434 if (context_) |
| 436 context_->storage()->NotifyDoneUninstallingRegistration(this); | 435 context_->storage()->NotifyDoneUninstallingRegistration(this); |
| 437 | 436 |
| 438 std::vector<scoped_refptr<ServiceWorkerVersion>> versions_to_doom; | 437 std::vector<scoped_refptr<ServiceWorkerVersion>> versions_to_doom; |
| 439 ChangedVersionAttributesMask mask; | 438 ChangedVersionAttributesMask mask; |
| 440 if (installing_version_.get()) { | 439 if (installing_version_.get()) { |
| 441 versions_to_doom.push_back(installing_version_); | 440 versions_to_doom.push_back(installing_version_); |
| 442 installing_version_ = nullptr; | 441 installing_version_ = nullptr; |
| 443 mask.add(ChangedVersionAttributesMask::INSTALLING_VERSION); | 442 mask.add(ChangedVersionAttributesMask::INSTALLING_VERSION); |
| 444 } | 443 } |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 475 if (!context_) { | 474 if (!context_) { |
| 476 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 475 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 477 return; | 476 return; |
| 478 } | 477 } |
| 479 context_->storage()->NotifyDoneInstallingRegistration( | 478 context_->storage()->NotifyDoneInstallingRegistration( |
| 480 this, version.get(), status); | 479 this, version.get(), status); |
| 481 callback.Run(status); | 480 callback.Run(status); |
| 482 } | 481 } |
| 483 | 482 |
| 484 } // namespace content | 483 } // namespace content |
| OLD | NEW |