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/child/service_worker/web_service_worker_impl.h" | 5 #include "content/child/service_worker/web_service_worker_impl.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "content/child/service_worker/service_worker_dispatcher.h" | 10 #include "content/child/service_worker/service_worker_dispatcher.h" |
9 #include "content/child/service_worker/service_worker_handle_reference.h" | 11 #include "content/child/service_worker/service_worker_handle_reference.h" |
10 #include "content/child/thread_safe_sender.h" | 12 #include "content/child/thread_safe_sender.h" |
11 #include "content/child/webmessageportchannel_impl.h" | 13 #include "content/child/webmessageportchannel_impl.h" |
12 #include "content/common/service_worker/service_worker_messages.h" | 14 #include "content/common/service_worker/service_worker_messages.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 15 #include "third_party/WebKit/public/platform/WebString.h" |
14 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerProxy.h" | 16 #include "third_party/WebKit/public/platform/modules/serviceworker/WebServiceWor
kerProxy.h" |
15 | 17 |
16 using blink::WebMessagePortChannel; | 18 using blink::WebMessagePortChannel; |
(...skipping 19 matching lines...) Expand all Loading... |
36 DISALLOW_COPY_AND_ASSIGN(HandleImpl); | 38 DISALLOW_COPY_AND_ASSIGN(HandleImpl); |
37 }; | 39 }; |
38 | 40 |
39 void SendPostMessageToWorkerOnMainThread( | 41 void SendPostMessageToWorkerOnMainThread( |
40 ThreadSafeSender* thread_safe_sender, | 42 ThreadSafeSender* thread_safe_sender, |
41 int handle_id, | 43 int handle_id, |
42 const base::string16& message, | 44 const base::string16& message, |
43 scoped_ptr<WebMessagePortChannelArray> channels) { | 45 scoped_ptr<WebMessagePortChannelArray> channels) { |
44 thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker( | 46 thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker( |
45 handle_id, message, | 47 handle_id, message, |
46 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels.Pass()))); | 48 WebMessagePortChannelImpl::ExtractMessagePortIDs(std::move(channels)))); |
47 } | 49 } |
48 | 50 |
49 } // namespace | 51 } // namespace |
50 | 52 |
51 WebServiceWorkerImpl::WebServiceWorkerImpl( | 53 WebServiceWorkerImpl::WebServiceWorkerImpl( |
52 scoped_ptr<ServiceWorkerHandleReference> handle_ref, | 54 scoped_ptr<ServiceWorkerHandleReference> handle_ref, |
53 ThreadSafeSender* thread_safe_sender) | 55 ThreadSafeSender* thread_safe_sender) |
54 : handle_ref_(handle_ref.Pass()), | 56 : handle_ref_(std::move(handle_ref)), |
55 state_(handle_ref_->state()), | 57 state_(handle_ref_->state()), |
56 thread_safe_sender_(thread_safe_sender), | 58 thread_safe_sender_(thread_safe_sender), |
57 proxy_(nullptr) { | 59 proxy_(nullptr) { |
58 DCHECK_NE(kInvalidServiceWorkerHandleId, handle_ref_->handle_id()); | 60 DCHECK_NE(kInvalidServiceWorkerHandleId, handle_ref_->handle_id()); |
59 ServiceWorkerDispatcher* dispatcher = | 61 ServiceWorkerDispatcher* dispatcher = |
60 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 62 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
61 DCHECK(dispatcher); | 63 DCHECK(dispatcher); |
62 dispatcher->AddServiceWorker(handle_ref_->handle_id(), this); | 64 dispatcher->AddServiceWorker(handle_ref_->handle_id(), this); |
63 } | 65 } |
64 | 66 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 } | 124 } |
123 | 125 |
124 WebServiceWorkerImpl::~WebServiceWorkerImpl() { | 126 WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
125 ServiceWorkerDispatcher* dispatcher = | 127 ServiceWorkerDispatcher* dispatcher = |
126 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 128 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
127 if (dispatcher) | 129 if (dispatcher) |
128 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); | 130 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); |
129 } | 131 } |
130 | 132 |
131 } // namespace content | 133 } // namespace content |
OLD | NEW |