| 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 "content/child/service_worker/service_worker_dispatcher.h" |
| 8 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
| 7 #include "content/common/service_worker/service_worker_types.h" | 9 #include "content/common/service_worker/service_worker_types.h" |
| 10 #include "third_party/WebKit/public/platform/WebServiceWorkerRegistrationProxy.h
" |
| 8 | 11 |
| 9 namespace content { | 12 namespace content { |
| 10 | 13 |
| 11 WebServiceWorkerRegistrationImpl::WebServiceWorkerRegistrationImpl( | 14 WebServiceWorkerRegistrationImpl::WebServiceWorkerRegistrationImpl( |
| 12 const ServiceWorkerObjectInfo& info) | 15 scoped_ptr<ServiceWorkerRegistrationHandleReference> handle_ref) |
| 13 : scope_(info.scope) { | 16 : handle_ref_(handle_ref.Pass()), |
| 17 proxy_(NULL) { |
| 18 DCHECK(handle_ref_); |
| 19 DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, |
| 20 handle_ref_->handle_id()); |
| 21 ServiceWorkerDispatcher* dispatcher = |
| 22 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 23 DCHECK(dispatcher); |
| 24 dispatcher->AddServiceWorkerRegistration(handle_ref_->handle_id(), this); |
| 14 } | 25 } |
| 15 | 26 |
| 16 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 27 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
| 28 ServiceWorkerDispatcher* dispatcher = |
| 29 ServiceWorkerDispatcher::GetThreadSpecificInstance(); |
| 30 if (dispatcher) |
| 31 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); |
| 32 } |
| 33 |
| 34 void WebServiceWorkerRegistrationImpl::OnUpdateFound() { |
| 35 DCHECK(proxy_); |
| 36 proxy_->dispatchUpdateFoundEvent(); |
| 37 } |
| 38 |
| 39 void WebServiceWorkerRegistrationImpl::setProxy( |
| 40 blink::WebServiceWorkerRegistrationProxy* proxy) { |
| 41 proxy_ = proxy; |
| 42 } |
| 43 |
| 44 void WebServiceWorkerRegistrationImpl::setInstalling( |
| 45 blink::WebServiceWorker* service_worker) { |
| 46 DCHECK(proxy_); |
| 47 proxy_->setInstalling(service_worker); |
| 48 } |
| 49 |
| 50 void WebServiceWorkerRegistrationImpl::setWaiting( |
| 51 blink::WebServiceWorker* service_worker) { |
| 52 DCHECK(proxy_); |
| 53 proxy_->setWaiting(service_worker); |
| 54 } |
| 55 |
| 56 void WebServiceWorkerRegistrationImpl::setActive( |
| 57 blink::WebServiceWorker* service_worker) { |
| 58 DCHECK(proxy_); |
| 59 proxy_->setActive(service_worker); |
| 17 } | 60 } |
| 18 | 61 |
| 19 blink::WebURL WebServiceWorkerRegistrationImpl::scope() const { | 62 blink::WebURL WebServiceWorkerRegistrationImpl::scope() const { |
| 20 return scope_; | 63 return handle_ref_->scope(); |
| 21 } | 64 } |
| 22 | 65 |
| 23 } // namespace content | 66 } // namespace content |
| OLD | NEW |