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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
10 #include "content/browser/service_worker/embedded_worker_status.h" | 10 #include "content/browser/service_worker/embedded_worker_status.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { | 24 ServiceWorkerVersionInfo GetVersionInfo(ServiceWorkerVersion* version) { |
25 if (!version) | 25 if (!version) |
26 return ServiceWorkerVersionInfo(); | 26 return ServiceWorkerVersionInfo(); |
27 return version->GetInfo(); | 27 return version->GetInfo(); |
28 } | 28 } |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 ServiceWorkerRegistration::ServiceWorkerRegistration( | 32 ServiceWorkerRegistration::ServiceWorkerRegistration( |
33 const GURL& pattern, | 33 const GURL& pattern, |
| 34 bool use_cache, |
34 int64_t registration_id, | 35 int64_t registration_id, |
35 base::WeakPtr<ServiceWorkerContextCore> context) | 36 base::WeakPtr<ServiceWorkerContextCore> context) |
36 : pattern_(pattern), | 37 : pattern_(pattern), |
| 38 use_cache_(use_cache), |
37 registration_id_(registration_id), | 39 registration_id_(registration_id), |
38 is_deleted_(false), | 40 is_deleted_(false), |
39 is_uninstalling_(false), | 41 is_uninstalling_(false), |
40 is_uninstalled_(false), | 42 is_uninstalled_(false), |
41 should_activate_when_ready_(false), | 43 should_activate_when_ready_(false), |
42 resources_total_size_bytes_(0), | 44 resources_total_size_bytes_(0), |
43 context_(context), | 45 context_(context), |
44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 46 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
45 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 47 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 48 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 ChangedVersionAttributesMask mask) { | 90 ChangedVersionAttributesMask mask) { |
89 for (auto& observer : listeners_) | 91 for (auto& observer : listeners_) |
90 observer.OnVersionAttributesChanged(this, mask, GetInfo()); | 92 observer.OnVersionAttributesChanged(this, mask, GetInfo()); |
91 if (mask.active_changed() || mask.waiting_changed()) | 93 if (mask.active_changed() || mask.waiting_changed()) |
92 NotifyRegistrationFinished(); | 94 NotifyRegistrationFinished(); |
93 } | 95 } |
94 | 96 |
95 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { | 97 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
96 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 98 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
97 return ServiceWorkerRegistrationInfo( | 99 return ServiceWorkerRegistrationInfo( |
98 pattern(), registration_id_, | 100 pattern(), use_cache(), registration_id_, |
99 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED | 101 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED |
100 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, | 102 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, |
101 GetVersionInfo(active_version_.get()), | 103 GetVersionInfo(active_version_.get()), |
102 GetVersionInfo(waiting_version_.get()), | 104 GetVersionInfo(waiting_version_.get()), |
103 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); | 105 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); |
104 } | 106 } |
105 | 107 |
106 void ServiceWorkerRegistration::SetActiveVersion( | 108 void ServiceWorkerRegistration::SetActiveVersion( |
107 const scoped_refptr<ServiceWorkerVersion>& version) { | 109 const scoped_refptr<ServiceWorkerVersion>& version) { |
108 if (active_version_ == version) | 110 if (active_version_ == version) |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 if (!context_) { | 515 if (!context_) { |
514 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 516 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
515 return; | 517 return; |
516 } | 518 } |
517 context_->storage()->NotifyDoneInstallingRegistration( | 519 context_->storage()->NotifyDoneInstallingRegistration( |
518 this, version.get(), status); | 520 this, version.get(), status); |
519 callback.Run(status); | 521 callback.Run(status); |
520 } | 522 } |
521 | 523 |
522 } // namespace content | 524 } // namespace content |
OLD | NEW |