Chromium Code Reviews| 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 DCHECK(sender); | |
| 19 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( | |
| 20 registration_handle_id, info, sender, true)); | |
| 21 } | |
| 22 | |
| 23 scoped_ptr<ServiceWorkerRegistrationHandleReference> | |
| 24 ServiceWorkerRegistrationHandleReference::Adopt( | |
| 25 int registration_handle_id, | |
| 26 const ServiceWorkerObjectInfo& info, | |
| 27 ThreadSafeSender* sender) { | |
| 28 DCHECK(sender); | |
| 29 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference( | |
| 30 registration_handle_id, info, sender, false)); | |
| 31 } | |
| 32 | |
| 33 ServiceWorkerRegistrationHandleReference:: | |
| 34 ServiceWorkerRegistrationHandleReference( | |
| 35 int registration_handle_id, | |
| 36 const ServiceWorkerObjectInfo& info, | |
| 37 ThreadSafeSender* sender, | |
| 38 bool increment_ref_in_ctor) | |
| 39 : handle_id_(registration_handle_id), | |
| 40 scope_(info.scope), | |
| 41 sender_(sender) { | |
| 42 if (increment_ref_in_ctor && | |
| 43 handle_id_ != kInvalidServiceWorkerRegistrationHandleId) { | |
|
michaeln
2014/08/13 04:18:17
do we need an instance when handled_id_ is kInvali
nhiroki
2014/08/13 13:15:05
I don't think we need to make an instance for kInv
| |
| 44 sender_->Send( | |
| 45 new ServiceWorkerHostMsg_IncrementRegistrationRefCount(handle_id_)); | |
| 46 } | |
| 47 } | |
| 48 | |
| 49 ServiceWorkerRegistrationHandleReference:: | |
| 50 ~ServiceWorkerRegistrationHandleReference() { | |
| 51 if (handle_id_ != kInvalidServiceWorkerRegistrationHandleId) { | |
| 52 sender_->Send( | |
| 53 new ServiceWorkerHostMsg_DecrementRegistrationRefCount(handle_id_)); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 } // namespace content | |
| OLD | NEW |