Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: content/browser/service_worker/service_worker_registration.cc

Issue 1098083003: Evict Service Worker when reading it from disk cache fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rm friend Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/service_worker/service_worker_registration.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_registration.cc
diff --git a/content/browser/service_worker/service_worker_registration.cc b/content/browser/service_worker/service_worker_registration.cc
index 4f5e6113b327e454adeb5ea71ef157a8b6f7073e..ba89eecdbbce1160c0ea8e5e46c82b14f7c5d951 100644
--- a/content/browser/service_worker/service_worker_registration.cc
+++ b/content/browser/service_worker/service_worker_registration.cc
@@ -302,6 +302,45 @@ void ServiceWorkerRegistration::ActivateWaitingVersion() {
this, activating_version));
}
+void ServiceWorkerRegistration::DeleteVersion(
+ const scoped_refptr<ServiceWorkerVersion>& version) {
nhiroki 2015/04/27 04:24:25 ServiceWorkerRegisterJob::CompleteInternal seems t
falken 2015/04/27 04:58:16 Yes good point, these are pretty similar. I'll see
+ DCHECK_EQ(id(), version->registration_id());
+
+ // "Set registration's active worker to null." (The spec's step order may
+ // differ. It's OK because the other steps queue a task.)
+ UnsetVersion(version.get());
+
+ // "Run the Update State algorithm passing registration's active worker and
+ // 'redundant' as the arguments."
+ version->SetStatus(ServiceWorkerVersion::REDUNDANT);
+
+ // "For each service worker client client whose active worker is
+ // registration's active worker..." set the active worker to null.
+ for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
+ context_->GetProviderHostIterator();
+ !it->IsAtEnd(); it->Advance()) {
+ ServiceWorkerProviderHost* host = it->GetProviderHost();
+ if (host->controlling_version() == version)
+ host->NotifyControllerActivationFailed();
+ }
+
+ version->Doom();
+
+ if (!active_version() && !waiting_version()) {
+ // Delete the records from the db.
+ context_->storage()->DeleteRegistration(
+ id(), pattern().GetOrigin(),
+ base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this));
+ // But not from memory if there is a version in the pipeline.
+ if (installing_version()) {
+ is_deleted_ = false;
+ } else {
+ is_uninstalled_ = true;
+ FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this));
+ }
+ }
+}
+
void ServiceWorkerRegistration::OnActivateEventFinished(
ServiceWorkerVersion* activating_version,
ServiceWorkerStatusCode status) {
@@ -311,38 +350,7 @@ void ServiceWorkerRegistration::OnActivateEventFinished(
// "If activateFailed is true, then:..."
if (status != SERVICE_WORKER_OK) {
- // "Set registration's active worker to null." (The spec's step order may
- // differ. It's OK because the other steps queue a task.)
- UnsetVersion(activating_version);
-
- // "Run the Update State algorithm passing registration's active worker and
- // 'redundant' as the arguments."
- activating_version->SetStatus(ServiceWorkerVersion::REDUNDANT);
-
- // "For each service worker client client whose active worker is
- // registration's active worker..." set the active worker to null.
- for (scoped_ptr<ServiceWorkerContextCore::ProviderHostIterator> it =
- context_->GetProviderHostIterator();
- !it->IsAtEnd(); it->Advance()) {
- ServiceWorkerProviderHost* host = it->GetProviderHost();
- if (host->controlling_version() == activating_version)
- host->NotifyControllerActivationFailed();
- }
-
- activating_version->Doom();
- if (!waiting_version()) {
- // Delete the records from the db.
- context_->storage()->DeleteRegistration(
- id(), pattern().GetOrigin(),
- base::Bind(&ServiceWorkerRegistration::OnDeleteFinished, this));
- // But not from memory if there is a version in the pipeline.
- if (installing_version()) {
- is_deleted_ = false;
- } else {
- is_uninstalled_ = true;
- FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this));
- }
- }
+ DeleteVersion(make_scoped_refptr(activating_version));
return;
}
« no previous file with comments | « content/browser/service_worker/service_worker_registration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698