OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_registration_impl.h" | 5 #include "content/child/service_worker/web_service_worker_registration_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 void WebServiceWorkerRegistrationImpl::SetActive( | 81 void WebServiceWorkerRegistrationImpl::SetActive( |
82 const scoped_refptr<WebServiceWorkerImpl>& service_worker) { | 82 const scoped_refptr<WebServiceWorkerImpl>& service_worker) { |
83 if (proxy_) | 83 if (proxy_) |
84 proxy_->SetActive(WebServiceWorkerImpl::CreateHandle(service_worker)); | 84 proxy_->SetActive(WebServiceWorkerImpl::CreateHandle(service_worker)); |
85 else | 85 else |
86 queued_tasks_.push_back(QueuedTask(ACTIVE, service_worker)); | 86 queued_tasks_.push_back(QueuedTask(ACTIVE, service_worker)); |
87 } | 87 } |
88 | 88 |
| 89 void WebServiceWorkerRegistrationImpl::SetRegistrationHandleReference( |
| 90 std::unique_ptr<ServiceWorkerRegistrationHandleReference> handle_ref) { |
| 91 handle_ref_ = std::move(handle_ref); |
| 92 } |
| 93 |
89 void WebServiceWorkerRegistrationImpl::OnUpdateFound() { | 94 void WebServiceWorkerRegistrationImpl::OnUpdateFound() { |
90 if (proxy_) | 95 if (proxy_) |
91 proxy_->DispatchUpdateFoundEvent(); | 96 proxy_->DispatchUpdateFoundEvent(); |
92 else | 97 else |
93 queued_tasks_.push_back(QueuedTask(UPDATE_FOUND, nullptr)); | 98 queued_tasks_.push_back(QueuedTask(UPDATE_FOUND, nullptr)); |
94 } | 99 } |
95 | 100 |
96 void WebServiceWorkerRegistrationImpl::SetProxy( | 101 void WebServiceWorkerRegistrationImpl::SetProxy( |
97 blink::WebServiceWorkerRegistrationProxy* proxy) { | 102 blink::WebServiceWorkerRegistrationProxy* proxy) { |
98 proxy_ = proxy; | 103 proxy_ = proxy; |
(...skipping 17 matching lines...) Expand all Loading... |
116 | 121 |
117 blink::WebServiceWorkerRegistrationProxy* | 122 blink::WebServiceWorkerRegistrationProxy* |
118 WebServiceWorkerRegistrationImpl::Proxy() { | 123 WebServiceWorkerRegistrationImpl::Proxy() { |
119 return proxy_; | 124 return proxy_; |
120 } | 125 } |
121 | 126 |
122 blink::WebURL WebServiceWorkerRegistrationImpl::Scope() const { | 127 blink::WebURL WebServiceWorkerRegistrationImpl::Scope() const { |
123 return handle_ref_->scope(); | 128 return handle_ref_->scope(); |
124 } | 129 } |
125 | 130 |
| 131 blink::WebServiceWorkerUpdateViaCache |
| 132 WebServiceWorkerRegistrationImpl::UpdateViaCache() const { |
| 133 return handle_ref_->update_via_cache(); |
| 134 } |
| 135 |
126 void WebServiceWorkerRegistrationImpl::Update( | 136 void WebServiceWorkerRegistrationImpl::Update( |
127 blink::WebServiceWorkerProvider* provider, | 137 blink::WebServiceWorkerProvider* provider, |
128 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { | 138 std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) { |
129 WebServiceWorkerProviderImpl* provider_impl = | 139 WebServiceWorkerProviderImpl* provider_impl = |
130 static_cast<WebServiceWorkerProviderImpl*>(provider); | 140 static_cast<WebServiceWorkerProviderImpl*>(provider); |
131 ServiceWorkerDispatcher* dispatcher = | 141 ServiceWorkerDispatcher* dispatcher = |
132 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 142 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
133 DCHECK(dispatcher); | 143 DCHECK(dispatcher); |
134 dispatcher->UpdateServiceWorker(provider_impl->provider_id(), | 144 dispatcher->UpdateServiceWorker(provider_impl->provider_id(), |
135 RegistrationId(), std::move(callbacks)); | 145 RegistrationId(), std::move(callbacks)); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 211 } |
202 | 212 |
203 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 213 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
204 ServiceWorkerDispatcher* dispatcher = | 214 ServiceWorkerDispatcher* dispatcher = |
205 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | 215 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
206 if (dispatcher) | 216 if (dispatcher) |
207 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | 217 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
208 } | 218 } |
209 | 219 |
210 } // namespace content | 220 } // namespace content |
OLD | NEW |