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

Side by Side Diff: content/browser/service_worker/service_worker_register_job.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_register_job.h" 5 #include "content/browser/service_worker/service_worker_register_job.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType; 67 typedef ServiceWorkerRegisterJobBase::RegistrationJobType RegistrationJobType;
68 68
69 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( 69 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
70 base::WeakPtr<ServiceWorkerContextCore> context, 70 base::WeakPtr<ServiceWorkerContextCore> context,
71 const GURL& script_url, 71 const GURL& script_url,
72 const ServiceWorkerRegistrationOptions& options) 72 const ServiceWorkerRegistrationOptions& options)
73 : context_(context), 73 : context_(context),
74 job_type_(REGISTRATION_JOB), 74 job_type_(REGISTRATION_JOB),
75 pattern_(options.scope), 75 pattern_(options.scope),
76 script_url_(script_url), 76 script_url_(script_url),
77 update_via_cache_(options.update_via_cache),
77 phase_(INITIAL), 78 phase_(INITIAL),
78 doom_installing_worker_(false), 79 doom_installing_worker_(false),
79 is_promise_resolved_(false), 80 is_promise_resolved_(false),
80 should_uninstall_on_failure_(false), 81 should_uninstall_on_failure_(false),
81 force_bypass_cache_(false), 82 force_bypass_cache_(false),
82 skip_script_comparison_(false), 83 skip_script_comparison_(false),
83 promise_resolved_status_(SERVICE_WORKER_OK), 84 promise_resolved_status_(SERVICE_WORKER_OK),
84 weak_factory_(this) {} 85 weak_factory_(this) {}
85 86
86 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( 87 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
87 base::WeakPtr<ServiceWorkerContextCore> context, 88 base::WeakPtr<ServiceWorkerContextCore> context,
88 ServiceWorkerRegistration* registration, 89 ServiceWorkerRegistration* registration,
89 bool force_bypass_cache, 90 bool force_bypass_cache,
90 bool skip_script_comparison) 91 bool skip_script_comparison)
91 : context_(context), 92 : context_(context),
92 job_type_(UPDATE_JOB), 93 job_type_(UPDATE_JOB),
93 pattern_(registration->pattern()), 94 pattern_(registration->pattern()),
95 update_via_cache_(registration->update_via_cache()),
94 phase_(INITIAL), 96 phase_(INITIAL),
95 doom_installing_worker_(false), 97 doom_installing_worker_(false),
96 is_promise_resolved_(false), 98 is_promise_resolved_(false),
97 should_uninstall_on_failure_(false), 99 should_uninstall_on_failure_(false),
98 force_bypass_cache_(force_bypass_cache), 100 force_bypass_cache_(force_bypass_cache),
99 skip_script_comparison_(skip_script_comparison), 101 skip_script_comparison_(skip_script_comparison),
100 promise_resolved_status_(SERVICE_WORKER_OK), 102 promise_resolved_status_(SERVICE_WORKER_OK),
101 weak_factory_(this) { 103 weak_factory_(this) {
102 internal_.registration = registration; 104 internal_.registration = registration;
103 } 105 }
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 void ServiceWorkerRegisterJob::RegisterAndContinue() { 315 void ServiceWorkerRegisterJob::RegisterAndContinue() {
314 SetPhase(REGISTER); 316 SetPhase(REGISTER);
315 317
316 int64_t registration_id = context_->storage()->NewRegistrationId(); 318 int64_t registration_id = context_->storage()->NewRegistrationId();
317 if (registration_id == kInvalidServiceWorkerRegistrationId) { 319 if (registration_id == kInvalidServiceWorkerRegistrationId) {
318 Complete(SERVICE_WORKER_ERROR_ABORT); 320 Complete(SERVICE_WORKER_ERROR_ABORT);
319 return; 321 return;
320 } 322 }
321 323
322 set_registration(new ServiceWorkerRegistration( 324 set_registration(new ServiceWorkerRegistration(
323 ServiceWorkerRegistrationOptions(pattern_), registration_id, context_)); 325 ServiceWorkerRegistrationOptions(pattern_, update_via_cache_),
326 registration_id, context_));
324 AddRegistrationToMatchingProviderHosts(registration()); 327 AddRegistrationToMatchingProviderHosts(registration());
325 UpdateAndContinue(); 328 UpdateAndContinue();
326 } 329 }
327 330
328 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration( 331 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration(
329 scoped_refptr<ServiceWorkerRegistration> existing_registration, 332 scoped_refptr<ServiceWorkerRegistration> existing_registration,
330 ServiceWorkerStatusCode status) { 333 ServiceWorkerStatusCode status) {
331 if (status != SERVICE_WORKER_OK) { 334 if (status != SERVICE_WORKER_OK) {
332 Complete(status); 335 Complete(status);
333 return; 336 return;
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 new_version()->force_bypass_cache_for_scripts() || 675 new_version()->force_bypass_cache_for_scripts() ||
673 registration()->last_update_check().is_null()) { 676 registration()->last_update_check().is_null()) {
674 registration()->set_last_update_check(base::Time::Now()); 677 registration()->set_last_update_check(base::Time::Now());
675 678
676 if (registration()->has_installed_version()) 679 if (registration()->has_installed_version())
677 context_->storage()->UpdateLastUpdateCheckTime(registration()); 680 context_->storage()->UpdateLastUpdateCheckTime(registration());
678 } 681 }
679 } 682 }
680 683
681 } // namespace content 684 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698