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

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: fix a database error Created 3 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 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 is_promise_resolved_(false), 79 is_promise_resolved_(false),
79 should_uninstall_on_failure_(false), 80 should_uninstall_on_failure_(false),
80 force_bypass_cache_(false), 81 force_bypass_cache_(false),
81 skip_script_comparison_(false), 82 skip_script_comparison_(false),
82 promise_resolved_status_(SERVICE_WORKER_OK), 83 promise_resolved_status_(SERVICE_WORKER_OK),
83 weak_factory_(this) {} 84 weak_factory_(this) {}
84 85
85 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob( 86 ServiceWorkerRegisterJob::ServiceWorkerRegisterJob(
86 base::WeakPtr<ServiceWorkerContextCore> context, 87 base::WeakPtr<ServiceWorkerContextCore> context,
87 ServiceWorkerRegistration* registration, 88 ServiceWorkerRegistration* registration,
88 bool force_bypass_cache, 89 bool force_bypass_cache,
89 bool skip_script_comparison) 90 bool skip_script_comparison)
90 : context_(context), 91 : context_(context),
91 job_type_(UPDATE_JOB), 92 job_type_(UPDATE_JOB),
92 pattern_(registration->pattern()), 93 pattern_(registration->pattern()),
94 update_via_cache_(registration->update_via_cache()),
93 phase_(INITIAL), 95 phase_(INITIAL),
94 is_promise_resolved_(false), 96 is_promise_resolved_(false),
95 should_uninstall_on_failure_(false), 97 should_uninstall_on_failure_(false),
96 force_bypass_cache_(force_bypass_cache), 98 force_bypass_cache_(force_bypass_cache),
97 skip_script_comparison_(skip_script_comparison), 99 skip_script_comparison_(skip_script_comparison),
98 promise_resolved_status_(SERVICE_WORKER_OK), 100 promise_resolved_status_(SERVICE_WORKER_OK),
99 weak_factory_(this) { 101 weak_factory_(this) {
100 internal_.registration = registration; 102 internal_.registration = registration;
101 } 103 }
102 104
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 void ServiceWorkerRegisterJob::RegisterAndContinue() { 312 void ServiceWorkerRegisterJob::RegisterAndContinue() {
311 SetPhase(REGISTER); 313 SetPhase(REGISTER);
312 314
313 int64_t registration_id = context_->storage()->NewRegistrationId(); 315 int64_t registration_id = context_->storage()->NewRegistrationId();
314 if (registration_id == kInvalidServiceWorkerRegistrationId) { 316 if (registration_id == kInvalidServiceWorkerRegistrationId) {
315 Complete(SERVICE_WORKER_ERROR_ABORT); 317 Complete(SERVICE_WORKER_ERROR_ABORT);
316 return; 318 return;
317 } 319 }
318 320
319 set_registration(new ServiceWorkerRegistration( 321 set_registration(new ServiceWorkerRegistration(
320 ServiceWorkerRegistrationOptions(pattern_), registration_id, context_)); 322 ServiceWorkerRegistrationOptions(pattern_, update_via_cache_),
323 registration_id, context_));
321 AddRegistrationToMatchingProviderHosts(registration()); 324 AddRegistrationToMatchingProviderHosts(registration());
322 UpdateAndContinue(); 325 UpdateAndContinue();
323 } 326 }
324 327
325 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration( 328 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration(
326 scoped_refptr<ServiceWorkerRegistration> existing_registration, 329 scoped_refptr<ServiceWorkerRegistration> existing_registration,
327 ServiceWorkerStatusCode status) { 330 ServiceWorkerStatusCode status) {
328 if (status != SERVICE_WORKER_OK) { 331 if (status != SERVICE_WORKER_OK) {
329 Complete(status); 332 Complete(status);
330 return; 333 return;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 new_version()->force_bypass_cache_for_scripts() || 666 new_version()->force_bypass_cache_for_scripts() ||
664 registration()->last_update_check().is_null()) { 667 registration()->last_update_check().is_null()) {
665 registration()->set_last_update_check(base::Time::Now()); 668 registration()->set_last_update_check(base::Time::Now());
666 669
667 if (registration()->has_installed_version()) 670 if (registration()->has_installed_version())
668 context_->storage()->UpdateLastUpdateCheckTime(registration()); 671 context_->storage()->UpdateLastUpdateCheckTime(registration());
669 } 672 }
670 } 673 }
671 674
672 } // namespace content 675 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698