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 ServiceWorkerDispatcher* dispatcher = | |
19 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | |
20 DCHECK(dispatcher); | |
21 dispatcher->AddServiceWorkerRegistration(handle_ref_->handle_id(), this); | |
14 } | 22 } |
15 | 23 |
16 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { | 24 WebServiceWorkerRegistrationImpl::~WebServiceWorkerRegistrationImpl() { |
25 if (handle_ref_->handle_id() == kInvalidServiceWorkerRegistrationHandleId) | |
michaeln
2014/08/13 04:18:17
the is no similar check for kinvalid in the ctor w
falken
2014/08/13 08:27:06
good catch, this probably can be done better. of c
nhiroki
2014/08/13 13:15:05
Done.
| |
26 return; | |
27 ServiceWorkerDispatcher* dispatcher = | |
28 ServiceWorkerDispatcher::GetThreadSpecificInstance(); | |
29 if (dispatcher) | |
30 dispatcher->RemoveServiceWorkerRegistration(handle_ref_->handle_id()); | |
31 } | |
32 | |
33 void WebServiceWorkerRegistrationImpl::OnUpdateFound() { | |
34 DCHECK(proxy_); | |
35 proxy_->dispatchUpdateFoundEvent(); | |
36 } | |
37 | |
38 void WebServiceWorkerRegistrationImpl::setProxy( | |
39 blink::WebServiceWorkerRegistrationProxy* proxy) { | |
40 proxy_ = proxy; | |
41 } | |
42 | |
43 void WebServiceWorkerRegistrationImpl::setInstalling( | |
44 blink::WebServiceWorker* service_worker) { | |
45 DCHECK(proxy_); | |
46 proxy_->setInstalling(service_worker); | |
47 } | |
48 | |
49 void WebServiceWorkerRegistrationImpl::setWaiting( | |
50 blink::WebServiceWorker* service_worker) { | |
51 DCHECK(proxy_); | |
52 proxy_->setWaiting(service_worker); | |
53 } | |
54 | |
55 void WebServiceWorkerRegistrationImpl::setActive( | |
56 blink::WebServiceWorker* service_worker) { | |
57 DCHECK(proxy_); | |
58 proxy_->setActive(service_worker); | |
17 } | 59 } |
18 | 60 |
19 blink::WebURL WebServiceWorkerRegistrationImpl::scope() const { | 61 blink::WebURL WebServiceWorkerRegistrationImpl::scope() const { |
20 return scope_; | 62 return handle_ref_->scope(); |
21 } | 63 } |
22 | 64 |
23 } // namespace content | 65 } // namespace content |
OLD | NEW |