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/thread_safe_sender.h" | 8 #include "content/child/thread_safe_sender.h" |
9 #include "content/child/webmessageportchannel_impl.h" | 9 #include "content/child/webmessageportchannel_impl.h" |
10 #include "content/common/service_worker/service_worker_messages.h" | 10 #include "content/common/service_worker/service_worker_messages.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 if (handle_id_ == kInvalidServiceWorkerHandleId) | 37 if (handle_id_ == kInvalidServiceWorkerHandleId) |
38 return; | 38 return; |
39 thread_safe_sender_->Send( | 39 thread_safe_sender_->Send( |
40 new ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed(handle_id_)); | 40 new ServiceWorkerHostMsg_ServiceWorkerObjectDestroyed(handle_id_)); |
41 ServiceWorkerDispatcher* dispatcher = | 41 ServiceWorkerDispatcher* dispatcher = |
42 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 42 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
43 if (dispatcher) | 43 if (dispatcher) |
44 dispatcher->RemoveServiceWorker(handle_id_); | 44 dispatcher->RemoveServiceWorker(handle_id_); |
45 } | 45 } |
46 | 46 |
47 void WebServiceWorkerImpl::SetState(blink::WebServiceWorkerState new_state) { | |
48 state_ = new_state; | |
49 if (!proxy_) | |
50 return; | |
51 proxy_->dispatchStateChangeEvent(); | |
52 } | |
53 | |
54 void WebServiceWorkerImpl::setProxy(blink::WebServiceWorkerProxy* proxy) { | 47 void WebServiceWorkerImpl::setProxy(blink::WebServiceWorkerProxy* proxy) { |
55 proxy_ = proxy; | 48 proxy_ = proxy; |
56 } | 49 } |
57 | 50 |
| 51 void WebServiceWorkerImpl::setState(blink::WebServiceWorkerState new_state) { |
| 52 state_ = new_state; |
| 53 } |
| 54 |
58 blink::WebURL WebServiceWorkerImpl::scope() const { | 55 blink::WebURL WebServiceWorkerImpl::scope() const { |
59 return scope_; | 56 return scope_; |
60 } | 57 } |
61 | 58 |
62 blink::WebURL WebServiceWorkerImpl::url() const { | 59 blink::WebURL WebServiceWorkerImpl::url() const { |
63 return url_; | 60 return url_; |
64 } | 61 } |
65 | 62 |
66 blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { | 63 blink::WebServiceWorkerState WebServiceWorkerImpl::state() const { |
67 return state_; | 64 return state_; |
68 } | 65 } |
69 | 66 |
70 void WebServiceWorkerImpl::postMessage(const WebString& message, | 67 void WebServiceWorkerImpl::postMessage(const WebString& message, |
71 WebMessagePortChannelArray* channels) { | 68 WebMessagePortChannelArray* channels) { |
72 thread_safe_sender_->Send(new ServiceWorkerHostMsg_PostMessage( | 69 thread_safe_sender_->Send(new ServiceWorkerHostMsg_PostMessage( |
73 handle_id_, | 70 handle_id_, |
74 message, | 71 message, |
75 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); | 72 WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); |
76 } | 73 } |
77 | 74 |
| 75 void WebServiceWorkerImpl::OnStateChanged( |
| 76 blink::WebServiceWorkerState new_state) { |
| 77 DCHECK(proxy_); |
| 78 proxy_->onStateChanged(new_state); |
| 79 } |
| 80 |
78 } // namespace content | 81 } // namespace content |
OLD | NEW |