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_job_coordinator.cc

Issue 1270513002: Service Worker: Make ServiceWorkerRegistration.update() return a promise. (Chromium 2/3) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix strings. Created 5 years, 4 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
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_job_coordinator.h" 5 #include "content/browser/service_worker/service_worker_job_coordinator.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/service_worker/service_worker_register_job_base.h" 9 #include "content/browser/service_worker/service_worker_register_job_base.h"
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 ServiceWorkerRegistration* registration, 126 ServiceWorkerRegistration* registration,
127 bool force_bypass_cache) { 127 bool force_bypass_cache) {
128 DCHECK(registration); 128 DCHECK(registration);
129 DCHECK(registration->GetNewestVersion()); 129 DCHECK(registration->GetNewestVersion());
130 job_queues_[registration->pattern()].Push( 130 job_queues_[registration->pattern()].Push(
131 make_scoped_ptr<ServiceWorkerRegisterJobBase>( 131 make_scoped_ptr<ServiceWorkerRegisterJobBase>(
132 new ServiceWorkerRegisterJob(context_, registration, 132 new ServiceWorkerRegisterJob(context_, registration,
133 force_bypass_cache))); 133 force_bypass_cache)));
134 } 134 }
135 135
136 void ServiceWorkerJobCoordinator::Update(
137 ServiceWorkerRegistration* registration,
138 bool force_bypass_cache,
139 ServiceWorkerProviderHost* provider_host,
140 const ServiceWorkerRegisterJob::RegistrationCallback& callback) {
141 DCHECK(registration);
142 DCHECK(registration->GetNewestVersion());
143 ServiceWorkerRegisterJob* queued_job = static_cast<ServiceWorkerRegisterJob*>(
144 job_queues_[registration->pattern()].Push(
145 make_scoped_ptr<ServiceWorkerRegisterJobBase>(
146 new ServiceWorkerRegisterJob(context_, registration,
147 force_bypass_cache))));
148 queued_job->AddCallback(callback, provider_host);
149 }
150
136 void ServiceWorkerJobCoordinator::AbortAll() { 151 void ServiceWorkerJobCoordinator::AbortAll() {
137 for (RegistrationJobMap::iterator it = job_queues_.begin(); 152 for (RegistrationJobMap::iterator it = job_queues_.begin();
138 it != job_queues_.end(); ++it) { 153 it != job_queues_.end(); ++it) {
139 it->second.AbortAll(); 154 it->second.AbortAll();
140 } 155 }
141 job_queues_.clear(); 156 job_queues_.clear();
142 } 157 }
143 158
144 void ServiceWorkerJobCoordinator::FinishJob(const GURL& pattern, 159 void ServiceWorkerJobCoordinator::FinishJob(const GURL& pattern,
145 ServiceWorkerRegisterJobBase* job) { 160 ServiceWorkerRegisterJobBase* job) {
146 RegistrationJobMap::iterator pending_jobs = job_queues_.find(pattern); 161 RegistrationJobMap::iterator pending_jobs = job_queues_.find(pattern);
147 DCHECK(pending_jobs != job_queues_.end()) << "Deleting non-existent job."; 162 DCHECK(pending_jobs != job_queues_.end()) << "Deleting non-existent job.";
148 pending_jobs->second.Pop(job); 163 pending_jobs->second.Pop(job);
149 if (pending_jobs->second.empty()) 164 if (pending_jobs->second.empty())
150 job_queues_.erase(pending_jobs); 165 job_queues_.erase(pending_jobs);
151 } 166 }
152 167
153 } // namespace content 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698