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" |
(...skipping 25 matching lines...) Expand all Loading... |
36 if (handle_ref_->handle_id() == kInvalidServiceWorkerHandleId) | 36 if (handle_ref_->handle_id() == kInvalidServiceWorkerHandleId) |
37 return; | 37 return; |
38 ServiceWorkerDispatcher* dispatcher = | 38 ServiceWorkerDispatcher* dispatcher = |
39 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 39 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
40 if (dispatcher) | 40 if (dispatcher) |
41 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); | 41 dispatcher->RemoveServiceWorker(handle_ref_->handle_id()); |
42 } | 42 } |
43 | 43 |
44 void WebServiceWorkerImpl::OnStateChanged( | 44 void WebServiceWorkerImpl::OnStateChanged( |
45 blink::WebServiceWorkerState new_state) { | 45 blink::WebServiceWorkerState new_state) { |
46 DCHECK(proxy_); | 46 if (proxy_ && proxy_->isReady()) |
47 if (proxy_->isReady()) | |
48 CommitState(new_state); | 47 CommitState(new_state); |
49 else | 48 else |
50 queued_states_.push_back(new_state); | 49 queued_states_.push_back(new_state); |
51 } | 50 } |
52 | 51 |
53 void WebServiceWorkerImpl::setProxy(blink::WebServiceWorkerProxy* proxy) { | 52 void WebServiceWorkerImpl::setProxy(blink::WebServiceWorkerProxy* proxy) { |
54 proxy_ = proxy; | 53 proxy_ = proxy; |
55 } | 54 } |
56 | 55 |
57 blink::WebServiceWorkerProxy* WebServiceWorkerImpl::proxy() { | 56 blink::WebServiceWorkerProxy* WebServiceWorkerImpl::proxy() { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 90 } |
92 | 91 |
93 void WebServiceWorkerImpl::CommitState(blink::WebServiceWorkerState new_state) { | 92 void WebServiceWorkerImpl::CommitState(blink::WebServiceWorkerState new_state) { |
94 DCHECK(proxy_); | 93 DCHECK(proxy_); |
95 DCHECK(proxy_->isReady()); | 94 DCHECK(proxy_->isReady()); |
96 state_ = new_state; | 95 state_ = new_state; |
97 proxy_->dispatchStateChangeEvent(); | 96 proxy_->dispatchStateChangeEvent(); |
98 } | 97 } |
99 | 98 |
100 } // namespace content | 99 } // namespace content |
OLD | NEW |