OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/child/service_worker/service_worker_provider_context.h" | 5 #include "content/child/service_worker/service_worker_provider_context.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "content/child/child_thread.h" | 10 #include "content/child/child_thread.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Remove this context from the dispatcher living on the main thread. | 36 // Remove this context from the dispatcher living on the main thread. |
37 dispatcher->RemoveProviderContext(this); | 37 dispatcher->RemoveProviderContext(this); |
38 } | 38 } |
39 } | 39 } |
40 | 40 |
41 ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() { | 41 ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() { |
42 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); | 42 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
43 return controller_.get(); | 43 return controller_.get(); |
44 } | 44 } |
45 | 45 |
46 ServiceWorkerRegistrationHandleReference* | 46 bool ServiceWorkerProviderContext::IsAssociatedWithRegistration() { |
47 ServiceWorkerProviderContext::registration() { | |
48 base::AutoLock lock(lock_); | 47 base::AutoLock lock(lock_); |
49 return registration_.get(); | 48 return registration_ != nullptr; |
50 } | 49 } |
51 | 50 |
52 ServiceWorkerVersionAttributes | 51 void ServiceWorkerProviderContext::GetRegistrationInfoAndVersionAttributes( |
53 ServiceWorkerProviderContext::GetVersionAttributes() { | 52 ServiceWorkerRegistrationObjectInfo* info, |
| 53 ServiceWorkerVersionAttributes* attrs) { |
54 base::AutoLock lock(lock_); | 54 base::AutoLock lock(lock_); |
55 DCHECK(registration_); | 55 DCHECK(registration_); |
56 | 56 |
57 ServiceWorkerVersionAttributes attrs; | 57 *info = registration_->info(); |
58 if (installing_) | 58 if (installing_) |
59 attrs.installing = installing_->info(); | 59 attrs->installing = installing_->info(); |
60 if (waiting_) | 60 if (waiting_) |
61 attrs.waiting = waiting_->info(); | 61 attrs->waiting = waiting_->info(); |
62 if (active_) | 62 if (active_) |
63 attrs.active = active_->info(); | 63 attrs->active = active_->info(); |
64 return attrs; | |
65 } | 64 } |
66 | 65 |
67 void ServiceWorkerProviderContext::SetVersionAttributes( | 66 void ServiceWorkerProviderContext::SetVersionAttributes( |
68 ChangedVersionAttributesMask mask, | 67 ChangedVersionAttributesMask mask, |
69 const ServiceWorkerVersionAttributes& attrs) { | 68 const ServiceWorkerVersionAttributes& attrs) { |
70 base::AutoLock lock(lock_); | 69 base::AutoLock lock(lock_); |
71 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); | 70 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
72 DCHECK(registration_); | 71 DCHECK(registration_); |
73 | 72 |
74 if (mask.installing_changed()) { | 73 if (mask.installing_changed()) { |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 186 |
188 void ServiceWorkerProviderContext::DestructOnMainThread() const { | 187 void ServiceWorkerProviderContext::DestructOnMainThread() const { |
189 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && | 188 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && |
190 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { | 189 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { |
191 return; | 190 return; |
192 } | 191 } |
193 delete this; | 192 delete this; |
194 } | 193 } |
195 | 194 |
196 } // namespace content | 195 } // namespace content |
OLD | NEW |