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 24 matching lines...) Expand all Loading... |
35 return version->GetInfo(); | 35 return version->GetInfo(); |
36 } | 36 } |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 ServiceWorkerRegistration::ServiceWorkerRegistration( | 40 ServiceWorkerRegistration::ServiceWorkerRegistration( |
41 const ServiceWorkerRegistrationOptions& options, | 41 const ServiceWorkerRegistrationOptions& options, |
42 int64_t registration_id, | 42 int64_t registration_id, |
43 base::WeakPtr<ServiceWorkerContextCore> context) | 43 base::WeakPtr<ServiceWorkerContextCore> context) |
44 : pattern_(options.scope), | 44 : pattern_(options.scope), |
| 45 update_via_cache_(options.update_via_cache), |
45 registration_id_(registration_id), | 46 registration_id_(registration_id), |
46 is_deleted_(false), | 47 is_deleted_(false), |
47 is_uninstalling_(false), | 48 is_uninstalling_(false), |
48 is_uninstalled_(false), | 49 is_uninstalled_(false), |
49 should_activate_when_ready_(false), | 50 should_activate_when_ready_(false), |
50 resources_total_size_bytes_(0), | 51 resources_total_size_bytes_(0), |
51 context_(context), | 52 context_(context), |
52 task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 53 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
53 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 54 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
54 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 55 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 ChangedVersionAttributesMask mask) { | 97 ChangedVersionAttributesMask mask) { |
97 for (auto& observer : listeners_) | 98 for (auto& observer : listeners_) |
98 observer.OnVersionAttributesChanged(this, mask, GetInfo()); | 99 observer.OnVersionAttributesChanged(this, mask, GetInfo()); |
99 if (mask.active_changed() || mask.waiting_changed()) | 100 if (mask.active_changed() || mask.waiting_changed()) |
100 NotifyRegistrationFinished(); | 101 NotifyRegistrationFinished(); |
101 } | 102 } |
102 | 103 |
103 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { | 104 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
104 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 105 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
105 return ServiceWorkerRegistrationInfo( | 106 return ServiceWorkerRegistrationInfo( |
106 pattern(), registration_id_, | 107 pattern(), update_via_cache(), registration_id_, |
107 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED | 108 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED |
108 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, | 109 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, |
109 GetVersionInfo(active_version_.get()), | 110 GetVersionInfo(active_version_.get()), |
110 GetVersionInfo(waiting_version_.get()), | 111 GetVersionInfo(waiting_version_.get()), |
111 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); | 112 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); |
112 } | 113 } |
113 | 114 |
114 void ServiceWorkerRegistration::SetActiveVersion( | 115 void ServiceWorkerRegistration::SetActiveVersion( |
115 const scoped_refptr<ServiceWorkerVersion>& version) { | 116 const scoped_refptr<ServiceWorkerVersion>& version) { |
116 if (active_version_ == version) | 117 if (active_version_ == version) |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 if (!context_) { | 567 if (!context_) { |
567 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 568 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
568 return; | 569 return; |
569 } | 570 } |
570 context_->storage()->NotifyDoneInstallingRegistration( | 571 context_->storage()->NotifyDoneInstallingRegistration( |
571 this, version.get(), status); | 572 this, version.get(), status); |
572 callback.Run(status); | 573 callback.Run(status); |
573 } | 574 } |
574 | 575 |
575 } // namespace content | 576 } // namespace content |
OLD | NEW |