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/service_worker_registration_handle_refere
nce.h" | 5 #include "content/child/service_worker/service_worker_registration_handle_refere
nce.h" |
6 | 6 |
7 #include "content/child/thread_safe_sender.h" | 7 #include "content/child/thread_safe_sender.h" |
8 #include "content/common/service_worker/service_worker_messages.h" | 8 #include "content/common/service_worker/service_worker_messages.h" |
9 #include "content/common/service_worker/service_worker_types.h" | |
10 | 9 |
11 namespace content { | 10 namespace content { |
12 | 11 |
13 scoped_ptr<ServiceWorkerRegistrationHandleReference> | 12 scoped_ptr<ServiceWorkerRegistrationHandleReference> |
14 ServiceWorkerRegistrationHandleReference::Create( | 13 ServiceWorkerRegistrationHandleReference::Create( |
15 int registration_handle_id, | 14 const ServiceWorkerRegistrationObjectInfo& info, |
16 const ServiceWorkerObjectInfo& info, | |
17 ThreadSafeSender* sender) { | 15 ThreadSafeSender* sender) { |
18 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( | 16 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( |
19 registration_handle_id, info, sender, true)); | 17 info, sender, true)); |
20 } | 18 } |
21 | 19 |
22 scoped_ptr<ServiceWorkerRegistrationHandleReference> | 20 scoped_ptr<ServiceWorkerRegistrationHandleReference> |
23 ServiceWorkerRegistrationHandleReference::Adopt( | 21 ServiceWorkerRegistrationHandleReference::Adopt( |
24 int registration_handle_id, | 22 const ServiceWorkerRegistrationObjectInfo& info, |
25 const ServiceWorkerObjectInfo& info, | |
26 ThreadSafeSender* sender) { | 23 ThreadSafeSender* sender) { |
27 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( | 24 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( |
28 registration_handle_id, info, sender, false)); | 25 info, sender, false)); |
29 } | 26 } |
30 | 27 |
31 ServiceWorkerRegistrationHandleReference:: | 28 ServiceWorkerRegistrationHandleReference:: |
32 ServiceWorkerRegistrationHandleReference( | 29 ServiceWorkerRegistrationHandleReference( |
33 int registration_handle_id, | 30 const ServiceWorkerRegistrationObjectInfo& info, |
34 const ServiceWorkerObjectInfo& info, | |
35 ThreadSafeSender* sender, | 31 ThreadSafeSender* sender, |
36 bool increment_ref_in_ctor) | 32 bool increment_ref_in_ctor) |
37 : handle_id_(registration_handle_id), | 33 : info_(info), |
38 scope_(info.scope), | |
39 sender_(sender) { | 34 sender_(sender) { |
40 DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, handle_id_); | 35 DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, info_.handle_id); |
41 DCHECK(sender_); | 36 DCHECK(sender_); |
42 if (increment_ref_in_ctor) | 37 if (increment_ref_in_ctor) |
43 return; | 38 return; |
44 sender_->Send( | 39 sender_->Send( |
45 new ServiceWorkerHostMsg_IncrementRegistrationRefCount(handle_id_)); | 40 new ServiceWorkerHostMsg_IncrementRegistrationRefCount(info_.handle_id)); |
46 } | 41 } |
47 | 42 |
48 ServiceWorkerRegistrationHandleReference:: | 43 ServiceWorkerRegistrationHandleReference:: |
49 ~ServiceWorkerRegistrationHandleReference() { | 44 ~ServiceWorkerRegistrationHandleReference() { |
50 sender_->Send( | 45 sender_->Send( |
51 new ServiceWorkerHostMsg_DecrementRegistrationRefCount(handle_id_)); | 46 new ServiceWorkerHostMsg_DecrementRegistrationRefCount(info_.handle_id)); |
52 } | 47 } |
53 | 48 |
54 } // namespace content | 49 } // namespace content |
OLD | NEW |