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

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

Issue 2771823002: Implement updateViaCache flag and no-cache by default for main service worker scripts
Patch Set: Move API change to another patch and address comments Created 3 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
OLDNEW
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_context_wrapper.h" 5 #include "content/browser/service_worker/service_worker_context_wrapper.h"
6 6
7 #include <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 DCHECK_CURRENTLY_ON(BrowserThread::IO); 253 DCHECK_CURRENTLY_ON(BrowserThread::IO);
254 BrowserThread::PostTask( 254 BrowserThread::PostTask(
255 BrowserThread::UI, 255 BrowserThread::UI,
256 FROM_HERE, 256 FROM_HERE,
257 base::Bind(continuation, status == SERVICE_WORKER_OK)); 257 base::Bind(continuation, status == SERVICE_WORKER_OK));
258 } 258 }
259 259
260 void ServiceWorkerContextWrapper::RegisterServiceWorker( 260 void ServiceWorkerContextWrapper::RegisterServiceWorker(
261 const GURL& pattern, 261 const GURL& pattern,
262 const GURL& script_url, 262 const GURL& script_url,
263 blink::WebServiceWorkerUpdateViaCache update_via_cache,
263 const ResultCallback& continuation) { 264 const ResultCallback& continuation) {
264 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { 265 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) {
265 BrowserThread::PostTask( 266 BrowserThread::PostTask(
266 BrowserThread::IO, 267 BrowserThread::IO, FROM_HERE,
267 FROM_HERE, 268 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, this,
268 base::Bind(&ServiceWorkerContextWrapper::RegisterServiceWorker, 269 pattern, script_url, update_via_cache, continuation));
269 this,
270 pattern,
271 script_url,
272 continuation));
273 return; 270 return;
274 } 271 }
275 if (!context_core_) { 272 if (!context_core_) {
276 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 273 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
277 base::Bind(continuation, false)); 274 base::Bind(continuation, false));
278 return; 275 return;
279 } 276 }
280 ServiceWorkerRegistrationOptions options(net::SimplifyUrlForRequest(pattern)); 277 ServiceWorkerRegistrationOptions options(net::SimplifyUrlForRequest(pattern),
278 update_via_cache);
281 context()->RegisterServiceWorker( 279 context()->RegisterServiceWorker(
282 net::SimplifyUrlForRequest(script_url), options, 280 net::SimplifyUrlForRequest(script_url), options,
283 nullptr /* provider_host */, 281 nullptr /* provider_host */,
284 base::Bind(&FinishRegistrationOnIO, continuation)); 282 base::Bind(&FinishRegistrationOnIO, continuation));
285 } 283 }
286 284
287 static void FinishUnregistrationOnIO( 285 static void FinishUnregistrationOnIO(
288 const ServiceWorkerContext::ResultCallback& continuation, 286 const ServiceWorkerContext::ResultCallback& continuation,
289 ServiceWorkerStatusCode status) { 287 ServiceWorkerStatusCode status) {
290 DCHECK_CURRENTLY_ON(BrowserThread::IO); 288 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 service_worker_provider_id, 1035 service_worker_provider_id,
1038 std::move(client_ptr_info)); 1036 std::move(client_ptr_info));
1039 } 1037 }
1040 1038
1041 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() { 1039 ServiceWorkerContextCore* ServiceWorkerContextWrapper::context() {
1042 DCHECK_CURRENTLY_ON(BrowserThread::IO); 1040 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1043 return context_core_.get(); 1041 return context_core_.get();
1044 } 1042 }
1045 1043
1046 } // namespace content 1044 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698