OLD | NEW |
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void RunSoon(const base::Closure& closure) { | 61 void RunSoon(const base::Closure& closure) { |
62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 62 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
63 } | 63 } |
64 | 64 |
65 } // namespace | 65 } // namespace |
66 | 66 |
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& pattern, | 71 const GURL& script_url, |
72 const GURL& script_url) | 72 const ServiceWorkerRegistrationOptions& options) |
73 : context_(context), | 73 : context_(context), |
74 job_type_(REGISTRATION_JOB), | 74 job_type_(REGISTRATION_JOB), |
75 pattern_(pattern), | 75 pattern_(options.scope), |
76 script_url_(script_url), | 76 script_url_(script_url), |
77 phase_(INITIAL), | 77 phase_(INITIAL), |
78 doom_installing_worker_(false), | 78 doom_installing_worker_(false), |
79 is_promise_resolved_(false), | 79 is_promise_resolved_(false), |
80 should_uninstall_on_failure_(false), | 80 should_uninstall_on_failure_(false), |
81 force_bypass_cache_(false), | 81 force_bypass_cache_(false), |
82 skip_script_comparison_(false), | 82 skip_script_comparison_(false), |
83 promise_resolved_status_(SERVICE_WORKER_OK), | 83 promise_resolved_status_(SERVICE_WORKER_OK), |
84 weak_factory_(this) {} | 84 weak_factory_(this) {} |
85 | 85 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 // Creates a new ServiceWorkerRegistration. | 312 // Creates a new ServiceWorkerRegistration. |
313 void ServiceWorkerRegisterJob::RegisterAndContinue() { | 313 void ServiceWorkerRegisterJob::RegisterAndContinue() { |
314 SetPhase(REGISTER); | 314 SetPhase(REGISTER); |
315 | 315 |
316 int64_t registration_id = context_->storage()->NewRegistrationId(); | 316 int64_t registration_id = context_->storage()->NewRegistrationId(); |
317 if (registration_id == kInvalidServiceWorkerRegistrationId) { | 317 if (registration_id == kInvalidServiceWorkerRegistrationId) { |
318 Complete(SERVICE_WORKER_ERROR_ABORT); | 318 Complete(SERVICE_WORKER_ERROR_ABORT); |
319 return; | 319 return; |
320 } | 320 } |
321 | 321 |
322 set_registration( | 322 set_registration(new ServiceWorkerRegistration( |
323 new ServiceWorkerRegistration(pattern_, registration_id, context_)); | 323 ServiceWorkerRegistrationOptions(pattern_), registration_id, context_)); |
324 AddRegistrationToMatchingProviderHosts(registration()); | 324 AddRegistrationToMatchingProviderHosts(registration()); |
325 UpdateAndContinue(); | 325 UpdateAndContinue(); |
326 } | 326 } |
327 | 327 |
328 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration( | 328 void ServiceWorkerRegisterJob::ContinueWithUninstallingRegistration( |
329 scoped_refptr<ServiceWorkerRegistration> existing_registration, | 329 scoped_refptr<ServiceWorkerRegistration> existing_registration, |
330 ServiceWorkerStatusCode status) { | 330 ServiceWorkerStatusCode status) { |
331 if (status != SERVICE_WORKER_OK) { | 331 if (status != SERVICE_WORKER_OK) { |
332 Complete(status); | 332 Complete(status); |
333 return; | 333 return; |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 new_version()->force_bypass_cache_for_scripts() || | 672 new_version()->force_bypass_cache_for_scripts() || |
673 registration()->last_update_check().is_null()) { | 673 registration()->last_update_check().is_null()) { |
674 registration()->set_last_update_check(base::Time::Now()); | 674 registration()->set_last_update_check(base::Time::Now()); |
675 | 675 |
676 if (registration()->has_installed_version()) | 676 if (registration()->has_installed_version()) |
677 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 677 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
678 } | 678 } |
679 } | 679 } |
680 | 680 |
681 } // namespace content | 681 } // namespace content |
OLD | NEW |