| 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::GetRegistrationInfoAndVersionAttributes( |
| 47 ServiceWorkerProviderContext::registration() { | 47 ServiceWorkerRegistrationObjectInfo* info, |
| 48 ServiceWorkerVersionAttributes* attrs) { |
| 48 base::AutoLock lock(lock_); | 49 base::AutoLock lock(lock_); |
| 49 return registration_.get(); | 50 if (!registration_) |
| 50 } | 51 return false; |
| 51 | 52 |
| 52 ServiceWorkerVersionAttributes | 53 *info = registration_->info(); |
| 53 ServiceWorkerProviderContext::GetVersionAttributes() { | |
| 54 base::AutoLock lock(lock_); | |
| 55 DCHECK(registration_); | |
| 56 | |
| 57 ServiceWorkerVersionAttributes attrs; | |
| 58 if (installing_) | 54 if (installing_) |
| 59 attrs.installing = installing_->info(); | 55 attrs->installing = installing_->info(); |
| 60 if (waiting_) | 56 if (waiting_) |
| 61 attrs.waiting = waiting_->info(); | 57 attrs->waiting = waiting_->info(); |
| 62 if (active_) | 58 if (active_) |
| 63 attrs.active = active_->info(); | 59 attrs->active = active_->info(); |
| 64 return attrs; | 60 return true; |
| 65 } | 61 } |
| 66 | 62 |
| 67 void ServiceWorkerProviderContext::SetVersionAttributes( | 63 void ServiceWorkerProviderContext::SetVersionAttributes( |
| 68 ChangedVersionAttributesMask mask, | 64 ChangedVersionAttributesMask mask, |
| 69 const ServiceWorkerVersionAttributes& attrs) { | 65 const ServiceWorkerVersionAttributes& attrs) { |
| 70 base::AutoLock lock(lock_); | 66 base::AutoLock lock(lock_); |
| 71 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); | 67 DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
| 72 DCHECK(registration_); | 68 DCHECK(registration_); |
| 73 | 69 |
| 74 if (mask.installing_changed()) { | 70 if (mask.installing_changed()) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 183 |
| 188 void ServiceWorkerProviderContext::DestructOnMainThread() const { | 184 void ServiceWorkerProviderContext::DestructOnMainThread() const { |
| 189 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && | 185 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && |
| 190 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { | 186 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { |
| 191 return; | 187 return; |
| 192 } | 188 } |
| 193 delete this; | 189 delete this; |
| 194 } | 190 } |
| 195 | 191 |
| 196 } // namespace content | 192 } // namespace content |
| OLD | NEW |