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 "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
8 #include "content/browser/service_worker/service_worker_info.h" | 8 #include "content/browser/service_worker/service_worker_info.h" |
9 #include "content/browser/service_worker/service_worker_register_job.h" | 9 #include "content/browser/service_worker/service_worker_register_job.h" |
10 #include "content/browser/service_worker/service_worker_utils.h" | 10 #include "content/browser/service_worker/service_worker_utils.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 int64 registration_id, | 27 int64 registration_id, |
28 base::WeakPtr<ServiceWorkerContextCore> context) | 28 base::WeakPtr<ServiceWorkerContextCore> context) |
29 : pattern_(pattern), | 29 : pattern_(pattern), |
30 registration_id_(registration_id), | 30 registration_id_(registration_id), |
31 is_deleted_(false), | 31 is_deleted_(false), |
32 is_uninstalling_(false), | 32 is_uninstalling_(false), |
33 is_uninstalled_(false), | 33 is_uninstalled_(false), |
34 should_activate_when_ready_(false), | 34 should_activate_when_ready_(false), |
35 resources_total_size_bytes_(0), | 35 resources_total_size_bytes_(0), |
36 context_(context) { | 36 context_(context) { |
37 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 37 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
38 DCHECK(context_); | 38 DCHECK(context_); |
39 context_->AddLiveRegistration(this); | 39 context_->AddLiveRegistration(this); |
40 } | 40 } |
41 | 41 |
42 ServiceWorkerRegistration::~ServiceWorkerRegistration() { | 42 ServiceWorkerRegistration::~ServiceWorkerRegistration() { |
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 43 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
44 DCHECK(!listeners_.might_have_observers()); | 44 DCHECK(!listeners_.might_have_observers()); |
45 if (context_) | 45 if (context_) |
46 context_->RemoveLiveRegistration(registration_id_); | 46 context_->RemoveLiveRegistration(registration_id_); |
47 if (active_version()) | 47 if (active_version()) |
48 active_version()->RemoveListener(this); | 48 active_version()->RemoveListener(this); |
49 } | 49 } |
50 | 50 |
51 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() const { | 51 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() const { |
52 if (installing_version()) | 52 if (installing_version()) |
53 return installing_version(); | 53 return installing_version(); |
(...skipping 12 matching lines...) Expand all Loading... |
66 | 66 |
67 void ServiceWorkerRegistration::NotifyRegistrationFailed() { | 67 void ServiceWorkerRegistration::NotifyRegistrationFailed() { |
68 FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this)); | 68 FOR_EACH_OBSERVER(Listener, listeners_, OnRegistrationFailed(this)); |
69 } | 69 } |
70 | 70 |
71 void ServiceWorkerRegistration::NotifyUpdateFound() { | 71 void ServiceWorkerRegistration::NotifyUpdateFound() { |
72 FOR_EACH_OBSERVER(Listener, listeners_, OnUpdateFound(this)); | 72 FOR_EACH_OBSERVER(Listener, listeners_, OnUpdateFound(this)); |
73 } | 73 } |
74 | 74 |
75 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { | 75 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 76 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
77 return ServiceWorkerRegistrationInfo( | 77 return ServiceWorkerRegistrationInfo( |
78 pattern(), | 78 pattern(), |
79 registration_id_, | 79 registration_id_, |
80 GetVersionInfo(active_version_.get()), | 80 GetVersionInfo(active_version_.get()), |
81 GetVersionInfo(waiting_version_.get()), | 81 GetVersionInfo(waiting_version_.get()), |
82 GetVersionInfo(installing_version_.get()), | 82 GetVersionInfo(installing_version_.get()), |
83 resources_total_size_bytes_); | 83 resources_total_size_bytes_); |
84 } | 84 } |
85 | 85 |
86 void ServiceWorkerRegistration::SetActiveVersion( | 86 void ServiceWorkerRegistration::SetActiveVersion( |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (registration && | 415 if (registration && |
416 (registration->is_uninstalling() || registration->is_uninstalled())) | 416 (registration->is_uninstalling() || registration->is_uninstalled())) |
417 continue; | 417 continue; |
418 if (matcher.MatchLongest(info.pattern)) | 418 if (matcher.MatchLongest(info.pattern)) |
419 return false; | 419 return false; |
420 } | 420 } |
421 return true; | 421 return true; |
422 } | 422 } |
423 | 423 |
424 } // namespace content | 424 } // namespace content |
OLD | NEW |