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

Side by Side Diff: content/browser/service_worker/service_worker_unregister_job.cc

Issue 377153003: Service Worker: set active worker to REDUNDANT when unregistered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_unregister_job.h" 5 #include "content/browser/service_worker/service_worker_unregister_job.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_job_coordinator.h" 8 #include "content/browser/service_worker/service_worker_job_coordinator.h"
9 #include "content/browser/service_worker/service_worker_registration.h" 9 #include "content/browser/service_worker/service_worker_registration.h"
10 #include "content/browser/service_worker/service_worker_storage.h" 10 #include "content/browser/service_worker/service_worker_storage.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 Complete(status); 61 Complete(status);
62 return; 62 return;
63 } 63 }
64 64
65 DCHECK(registration); 65 DCHECK(registration);
66 DeleteRegistration(registration); 66 DeleteRegistration(registration);
67 } 67 }
68 68
69 void ServiceWorkerUnregisterJob::DeleteRegistration( 69 void ServiceWorkerUnregisterJob::DeleteRegistration(
70 const scoped_refptr<ServiceWorkerRegistration>& registration) { 70 const scoped_refptr<ServiceWorkerRegistration>& registration) {
71 // TODO(nhiroki): When we've implemented the installing version, terminate and 71 // TODO: Also doom installing version.
72 // set it to redundant here as per spec. 72 if (registration->waiting_version())
73 73 registration->waiting_version()->Doom();
74 if (registration->waiting_version()) { 74 if (registration->active_version())
75 registration->waiting_version()->SetStatus( 75 registration->active_version()->Doom();
76 ServiceWorkerVersion::REDUNDANT);
77 }
78 76
79 context_->storage()->DeleteRegistration( 77 context_->storage()->DeleteRegistration(
80 registration->id(), 78 registration->id(),
81 registration->script_url().GetOrigin(), 79 registration->script_url().GetOrigin(),
82 base::Bind(&ServiceWorkerUnregisterJob::Complete, 80 base::Bind(&ServiceWorkerUnregisterJob::Complete,
83 weak_factory_.GetWeakPtr())); 81 weak_factory_.GetWeakPtr()));
84 } 82 }
85 83
86 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) { 84 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) {
87 CompleteInternal(status); 85 CompleteInternal(status);
88 context_->job_coordinator()->FinishJob(pattern_, this); 86 context_->job_coordinator()->FinishJob(pattern_, this);
89 } 87 }
90 88
91 void ServiceWorkerUnregisterJob::CompleteInternal( 89 void ServiceWorkerUnregisterJob::CompleteInternal(
92 ServiceWorkerStatusCode status) { 90 ServiceWorkerStatusCode status) {
93 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin(); 91 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin();
94 it != callbacks_.end(); 92 it != callbacks_.end();
95 ++it) { 93 ++it) {
96 it->Run(status); 94 it->Run(status);
97 } 95 }
98 } 96 }
99 97
100 } // namespace content 98 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698