| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 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 ServiceWorkerRegistrationOptions& options, |
| 34 int64_t registration_id, | 34 int64_t registration_id, |
| 35 base::WeakPtr<ServiceWorkerContextCore> context) | 35 base::WeakPtr<ServiceWorkerContextCore> context) |
| 36 : pattern_(pattern), | 36 : pattern_(options.scope), |
| 37 update_via_cache_(options.update_via_cache), |
| 37 registration_id_(registration_id), | 38 registration_id_(registration_id), |
| 38 is_deleted_(false), | 39 is_deleted_(false), |
| 39 is_uninstalling_(false), | 40 is_uninstalling_(false), |
| 40 is_uninstalled_(false), | 41 is_uninstalled_(false), |
| 41 should_activate_when_ready_(false), | 42 should_activate_when_ready_(false), |
| 42 resources_total_size_bytes_(0), | 43 resources_total_size_bytes_(0), |
| 43 context_(context), | 44 context_(context), |
| 44 task_runner_(base::ThreadTaskRunnerHandle::Get()) { | 45 task_runner_(base::ThreadTaskRunnerHandle::Get()) { |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 46 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 46 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); | 47 DCHECK_NE(kInvalidServiceWorkerRegistrationId, registration_id); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 ChangedVersionAttributesMask mask) { | 89 ChangedVersionAttributesMask mask) { |
| 89 for (auto& observer : listeners_) | 90 for (auto& observer : listeners_) |
| 90 observer.OnVersionAttributesChanged(this, mask, GetInfo()); | 91 observer.OnVersionAttributesChanged(this, mask, GetInfo()); |
| 91 if (mask.active_changed() || mask.waiting_changed()) | 92 if (mask.active_changed() || mask.waiting_changed()) |
| 92 NotifyRegistrationFinished(); | 93 NotifyRegistrationFinished(); |
| 93 } | 94 } |
| 94 | 95 |
| 95 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { | 96 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
| 96 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 97 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 97 return ServiceWorkerRegistrationInfo( | 98 return ServiceWorkerRegistrationInfo( |
| 98 pattern(), registration_id_, | 99 pattern(), update_via_cache(), registration_id_, |
| 99 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED | 100 is_deleted_ ? ServiceWorkerRegistrationInfo::IS_DELETED |
| 100 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, | 101 : ServiceWorkerRegistrationInfo::IS_NOT_DELETED, |
| 101 GetVersionInfo(active_version_.get()), | 102 GetVersionInfo(active_version_.get()), |
| 102 GetVersionInfo(waiting_version_.get()), | 103 GetVersionInfo(waiting_version_.get()), |
| 103 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); | 104 GetVersionInfo(installing_version_.get()), resources_total_size_bytes_); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void ServiceWorkerRegistration::SetActiveVersion( | 107 void ServiceWorkerRegistration::SetActiveVersion( |
| 107 const scoped_refptr<ServiceWorkerVersion>& version) { | 108 const scoped_refptr<ServiceWorkerVersion>& version) { |
| 108 if (active_version_ == version) | 109 if (active_version_ == version) |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 if (!context_) { | 514 if (!context_) { |
| 514 callback.Run(SERVICE_WORKER_ERROR_ABORT); | 515 callback.Run(SERVICE_WORKER_ERROR_ABORT); |
| 515 return; | 516 return; |
| 516 } | 517 } |
| 517 context_->storage()->NotifyDoneInstallingRegistration( | 518 context_->storage()->NotifyDoneInstallingRegistration( |
| 518 this, version.get(), status); | 519 this, version.get(), status); |
| 519 callback.Run(status); | 520 callback.Run(status); |
| 520 } | 521 } |
| 521 | 522 |
| 522 } // namespace content | 523 } // namespace content |
| OLD | NEW |