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