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 "content/child/service_worker/service_worker_dispatcher.h" | 7 #include "content/child/service_worker/service_worker_dispatcher.h" |
8 #include "content/child/service_worker/service_worker_handle_reference.h" | 8 #include "content/child/service_worker/service_worker_handle_reference.h" |
9 #include "content/child/thread_safe_sender.h" | 9 #include "content/child/thread_safe_sender.h" |
10 #include "content/child/webmessageportchannel_impl.h" | 10 #include "content/child/webmessageportchannel_impl.h" |
11 #include "content/common/service_worker/service_worker_messages.h" | 11 #include "content/common/service_worker/service_worker_messages.h" |
12 #include "third_party/WebKit/public/platform/WebServiceWorkerProxy.h" | 12 #include "third_party/WebKit/public/platform/WebServiceWorkerProxy.h" |
13 #include "third_party/WebKit/public/platform/WebString.h" | 13 #include "third_party/WebKit/public/platform/WebString.h" |
14 | 14 |
15 using blink::WebMessagePortChannel; | 15 using blink::WebMessagePortChannel; |
16 using blink::WebMessagePortChannelArray; | 16 using blink::WebMessagePortChannelArray; |
17 using blink::WebMessagePortChannelClient; | 17 using blink::WebMessagePortChannelClient; |
18 using blink::WebString; | 18 using blink::WebString; |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 | 21 |
22 WebServiceWorkerImpl::WebServiceWorkerImpl( | 22 WebServiceWorkerImpl::WebServiceWorkerImpl( |
23 scoped_ptr<ServiceWorkerHandleReference> handle_ref, | 23 scoped_ptr<ServiceWorkerHandleReference> handle_ref, |
| 24 int provider_id, |
24 ThreadSafeSender* thread_safe_sender) | 25 ThreadSafeSender* thread_safe_sender) |
25 : handle_ref_(handle_ref.Pass()), | 26 : handle_ref_(handle_ref.Pass()), |
26 state_(handle_ref_->state()), | 27 state_(handle_ref_->state()), |
| 28 provider_id_(provider_id), |
27 thread_safe_sender_(thread_safe_sender), | 29 thread_safe_sender_(thread_safe_sender), |
28 proxy_(NULL) { | 30 proxy_(NULL) { |
29 ServiceWorkerDispatcher* dispatcher = | 31 ServiceWorkerDispatcher* dispatcher = |
30 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 32 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
31 DCHECK(dispatcher); | 33 DCHECK(dispatcher); |
32 dispatcher->AddServiceWorker(handle_ref_->handle_id(), this); | 34 dispatcher->AddServiceWorker(handle_ref_->handle_id(), this); |
33 } | 35 } |
34 | 36 |
35 WebServiceWorkerImpl::~WebServiceWorkerImpl() { | 37 WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
36 if (handle_ref_->handle_id() == kInvalidServiceWorkerHandleId) | 38 if (handle_ref_->handle_id() == kInvalidServiceWorkerHandleId) |
(...skipping 22 matching lines...) Expand all Loading... |
59 return handle_ref_->url(); | 61 return handle_ref_->url(); |
60 } | 62 } |
61 | 63 |
62 blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { | 64 blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { |
63 return state_; | 65 return state_; |
64 } | 66 } |
65 | 67 |
66 void WebServiceWorkerImpl::postMessage(const WebString& message, | 68 void WebServiceWorkerImpl::postMessage(const WebString& message, |
67 WebMessagePortChannelArray* channels) { | 69 WebMessagePortChannelArray* channels) { |
68 thread_safe_sender_->Send(new ServiceWorkerHostMsg_PostMessageToWorker( | 70 thread_safe_sender_->Send(new ServiceWorkerHostMsg_PostMessageToWorker( |
69 handle_ref_->handle_id(), | 71 handle_ref_->handle_id(), provider_id_, message, |
70 message, | |
71 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); | 72 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); |
72 } | 73 } |
73 | 74 |
74 void WebServiceWorkerImpl::terminate() { | 75 void WebServiceWorkerImpl::terminate() { |
75 thread_safe_sender_->Send( | 76 thread_safe_sender_->Send( |
76 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); | 77 new ServiceWorkerHostMsg_TerminateWorker(handle_ref_->handle_id())); |
77 } | 78 } |
78 | 79 |
79 } // namespace content | 80 } // namespace content |
OLD | NEW |