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