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_impl.h" |
11 #include "content/child/service_worker/service_worker_dispatcher.h" | 11 #include "content/child/service_worker/service_worker_dispatcher.h" |
12 #include "content/child/service_worker/service_worker_handle_reference.h" | 12 #include "content/child/service_worker/service_worker_handle_reference.h" |
13 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" | 13 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
14 #include "content/child/thread_safe_sender.h" | 14 #include "content/child/thread_safe_sender.h" |
15 #include "content/child/worker_task_runner.h" | 15 #include "content/child/worker_task_runner.h" |
16 #include "content/common/service_worker/service_worker_messages.h" | 16 #include "content/common/service_worker/service_worker_messages.h" |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
20 ServiceWorkerProviderContext::ServiceWorkerProviderContext(int provider_id) | 20 ServiceWorkerProviderContext::ServiceWorkerProviderContext(int provider_id) |
21 : provider_id_(provider_id), | 21 : provider_id_(provider_id), |
22 main_thread_loop_proxy_(base::MessageLoopProxy::current()) { | 22 main_thread_loop_proxy_(base::MessageLoopProxy::current()) { |
23 if (!ChildThread::current()) | 23 if (!ChildThreadImpl::current()) |
24 return; // May be null in some tests. | 24 return; // May be null in some tests. |
25 thread_safe_sender_ = ChildThread::current()->thread_safe_sender(); | 25 thread_safe_sender_ = ChildThreadImpl::current()->thread_safe_sender(); |
26 ServiceWorkerDispatcher* dispatcher = | 26 ServiceWorkerDispatcher* dispatcher = |
27 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( | 27 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance( |
28 thread_safe_sender_.get()); | 28 thread_safe_sender_.get()); |
29 DCHECK(dispatcher); | 29 DCHECK(dispatcher); |
30 dispatcher->AddProviderContext(this); | 30 dispatcher->AddProviderContext(this); |
31 } | 31 } |
32 | 32 |
33 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { | 33 ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { |
34 if (ServiceWorkerDispatcher* dispatcher = | 34 if (ServiceWorkerDispatcher* dispatcher = |
35 ServiceWorkerDispatcher::GetThreadSpecificInstance()) { | 35 ServiceWorkerDispatcher::GetThreadSpecificInstance()) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 183 |
184 void ServiceWorkerProviderContext::DestructOnMainThread() const { | 184 void ServiceWorkerProviderContext::DestructOnMainThread() const { |
185 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && | 185 if (!main_thread_loop_proxy_->RunsTasksOnCurrentThread() && |
186 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { | 186 main_thread_loop_proxy_->DeleteSoon(FROM_HERE, this)) { |
187 return; | 187 return; |
188 } | 188 } |
189 delete this; | 189 delete this; |
190 } | 190 } |
191 | 191 |
192 } // namespace content | 192 } // namespace content |
OLD | NEW |