| 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> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/child/service_worker/service_worker_dispatcher.h" | 10 #include "content/child/service_worker/service_worker_dispatcher.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 scoped_refptr<WebServiceWorkerImpl> worker_; | 36 scoped_refptr<WebServiceWorkerImpl> worker_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(HandleImpl); | 38 DISALLOW_COPY_AND_ASSIGN(HandleImpl); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 void SendPostMessageToWorkerOnMainThread( | 41 void SendPostMessageToWorkerOnMainThread( |
| 42 ThreadSafeSender* thread_safe_sender, | 42 ThreadSafeSender* thread_safe_sender, |
| 43 int handle_id, | 43 int handle_id, |
| 44 const base::string16& message, | 44 const base::string16& message, |
| 45 scoped_ptr<WebMessagePortChannelArray> channels) { | 45 scoped_ptr<WebMessagePortChannelArray> channels) { |
| 46 thread_safe_sender->Send(new ServiceWorkerHostMsg_PostMessageToWorker( | 46 // TODO(nhiroki): Switch to PostMessageToClient message after |
| 47 handle_id, message, | 47 // ExtendableMessageEvent is implemented (crbug.com/543198). |
| 48 WebMessagePortChannelImpl::ExtractMessagePortIDs(std::move(channels)))); | 48 thread_safe_sender->Send( |
| 49 new ServiceWorkerHostMsg_DeprecatedPostMessageToWorker( |
| 50 handle_id, message, WebMessagePortChannelImpl::ExtractMessagePortIDs( |
| 51 std::move(channels)))); |
| 49 } | 52 } |
| 50 | 53 |
| 51 } // namespace | 54 } // namespace |
| 52 | 55 |
| 53 WebServiceWorkerImpl::WebServiceWorkerImpl( | 56 WebServiceWorkerImpl::WebServiceWorkerImpl( |
| 54 scoped_ptr<ServiceWorkerHandleReference> handle_ref, | 57 scoped_ptr<ServiceWorkerHandleReference> handle_ref, |
| 55 ThreadSafeSender* thread_safe_sender) | 58 ThreadSafeSender* thread_safe_sender) |
| 56 : handle_ref_(std::move(handle_ref)), | 59 : handle_ref_(std::move(handle_ref)), |
| 57 state_(handle_ref_->state()), | 60 state_(handle_ref_->state()), |
| 58 thread_safe_sender_(thread_safe_sender), | 61 thread_safe_sender_(thread_safe_sender), |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 } | 127 } |
| 125 | 128 |
| 126 WebServiceWorkerImpl::~WebServiceWorkerImpl() { | 129 WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
| 127 ServiceWorkerDispatcher* dispatcher = | 130 ServiceWorkerDispatcher* dispatcher = |
| 128 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 131 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 129 if (dispatcher) | 132 if (dispatcher) |
| 130 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); | 133 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); |
| 131 } | 134 } |
| 132 | 135 |
| 133 } // namespace content | 136 } // namespace content |
| OLD | NEW |