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.
5 #include "content/child/service_worker/service_worker_registration_handle_reference.h"
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"
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));
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));
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),
40 DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, handle_id_);
42 if (increment_ref_in_ctor)
45 new ServiceWorkerHostMsg_IncrementRegistrationRefCount(handle_id_));
48 ServiceWorkerRegistrationHandleReference::
49 ~ServiceWorkerRegistrationHandleReference() {
51 new ServiceWorkerHostMsg_DecrementRegistrationRefCount(handle_id_));
54 } // namespace content