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

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

Issue 345583002: ServiceWorker: Add a function to abort all pending jobs in SWJobCoordinator (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments and add test cases Created 6 years, 6 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 16 matching lines...) Expand all
27 callbacks_.push_back(callback); 27 callbacks_.push_back(callback);
28 } 28 }
29 29
30 void ServiceWorkerUnregisterJob::Start() { 30 void ServiceWorkerUnregisterJob::Start() {
31 context_->storage()->FindRegistrationForPattern( 31 context_->storage()->FindRegistrationForPattern(
32 pattern_, 32 pattern_,
33 base::Bind(&ServiceWorkerUnregisterJob::DeleteExistingRegistration, 33 base::Bind(&ServiceWorkerUnregisterJob::DeleteExistingRegistration,
34 weak_factory_.GetWeakPtr())); 34 weak_factory_.GetWeakPtr()));
35 } 35 }
36 36
37 void ServiceWorkerUnregisterJob::Abort() {
38 CompleteInternal(SERVICE_WORKER_ERROR_ABORT);
39 }
40
37 bool ServiceWorkerUnregisterJob::Equals(ServiceWorkerRegisterJobBase* job) { 41 bool ServiceWorkerUnregisterJob::Equals(ServiceWorkerRegisterJobBase* job) {
38 if (job->GetType() != GetType()) 42 if (job->GetType() != GetType())
39 return false; 43 return false;
40 return static_cast<ServiceWorkerUnregisterJob*>(job)->pattern_ == pattern_; 44 return static_cast<ServiceWorkerUnregisterJob*>(job)->pattern_ == pattern_;
41 } 45 }
42 46
43 RegistrationJobType ServiceWorkerUnregisterJob::GetType() { 47 RegistrationJobType ServiceWorkerUnregisterJob::GetType() {
44 return ServiceWorkerRegisterJobBase::UNREGISTRATION; 48 return ServiceWorkerRegisterJobBase::UNREGISTRATION;
45 } 49 }
46 50
(...skipping 16 matching lines...) Expand all
63 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) { 67 if (status == SERVICE_WORKER_ERROR_NOT_FOUND) {
64 DCHECK(!registration); 68 DCHECK(!registration);
65 Complete(SERVICE_WORKER_OK); 69 Complete(SERVICE_WORKER_OK);
66 return; 70 return;
67 } 71 }
68 72
69 Complete(status); 73 Complete(status);
70 } 74 }
71 75
72 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) { 76 void ServiceWorkerUnregisterJob::Complete(ServiceWorkerStatusCode status) {
77 CompleteInternal(status);
78 context_->job_coordinator()->FinishJob(pattern_, this);
79 }
80
81 void ServiceWorkerUnregisterJob::CompleteInternal(
82 ServiceWorkerStatusCode status) {
73 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin(); 83 for (std::vector<UnregistrationCallback>::iterator it = callbacks_.begin();
74 it != callbacks_.end(); 84 it != callbacks_.end();
75 ++it) { 85 ++it) {
76 it->Run(status); 86 it->Run(status);
77 } 87 }
78 context_->job_coordinator()->FinishJob(pattern_, this);
79 } 88 }
80 89
81 } // namespace content 90 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698