| 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_handle_reference.h" | 5 #include "content/child/service_worker/service_worker_handle_reference.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 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 scoped_ptr<ServiceWorkerHandleReference> | 12 scoped_ptr<ServiceWorkerHandleReference> |
| 13 ServiceWorkerHandleReference::Create( | 13 ServiceWorkerHandleReference::Create( |
| 14 const ServiceWorkerObjectInfo& info, | 14 const ServiceWorkerObjectInfo& info, |
| 15 ThreadSafeSender* sender) { | 15 ThreadSafeSender* sender) { |
| 16 DCHECK(sender); | 16 DCHECK(sender); |
| 17 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, true)); | 17 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, true)); |
| 18 } | 18 } |
| 19 | 19 |
| 20 scoped_ptr<ServiceWorkerHandleReference> | 20 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerHandleReference::Adopt( |
| 21 ServiceWorkerHandleReference::CreateForDeleter( | |
| 22 const ServiceWorkerObjectInfo& info, | 21 const ServiceWorkerObjectInfo& info, |
| 23 ThreadSafeSender* sender) { | 22 ThreadSafeSender* sender) { |
| 24 DCHECK(sender); | 23 DCHECK(sender); |
| 25 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, false)); | 24 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, false)); |
| 26 } | 25 } |
| 27 | 26 |
| 28 ServiceWorkerHandleReference::ServiceWorkerHandleReference( | 27 ServiceWorkerHandleReference::ServiceWorkerHandleReference( |
| 29 const ServiceWorkerObjectInfo& info, | 28 const ServiceWorkerObjectInfo& info, |
| 30 ThreadSafeSender* sender, | 29 ThreadSafeSender* sender, |
| 31 bool increment_ref_in_ctor) | 30 bool increment_ref_in_ctor) |
| 32 : info_(info), | 31 : info_(info), |
| 33 sender_(sender) { | 32 sender_(sender) { |
| 34 if (increment_ref_in_ctor && | 33 if (increment_ref_in_ctor && |
| 35 info_.handle_id != kInvalidServiceWorkerHandleId) { | 34 info_.handle_id != kInvalidServiceWorkerHandleId) { |
| 36 sender_->Send( | 35 sender_->Send( |
| 37 new ServiceWorkerHostMsg_IncrementServiceWorkerRefCount( | 36 new ServiceWorkerHostMsg_IncrementServiceWorkerRefCount( |
| 38 info_.handle_id)); | 37 info_.handle_id)); |
| 39 } | 38 } |
| 40 } | 39 } |
| 41 | 40 |
| 42 ServiceWorkerHandleReference::~ServiceWorkerHandleReference() { | 41 ServiceWorkerHandleReference::~ServiceWorkerHandleReference() { |
| 43 if (info_.handle_id != kInvalidServiceWorkerHandleId) { | 42 if (info_.handle_id != kInvalidServiceWorkerHandleId) { |
| 44 sender_->Send( | 43 sender_->Send( |
| 45 new ServiceWorkerHostMsg_DecrementServiceWorkerRefCount( | 44 new ServiceWorkerHostMsg_DecrementServiceWorkerRefCount( |
| 46 info_.handle_id)); | 45 info_.handle_id)); |
| 47 } | 46 } |
| 48 } | 47 } |
| 49 | 48 |
| 50 } // namespace content | 49 } // namespace content |
| OLD | NEW |