Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / content / child / service_worker / service_worker_registration_handle_reference.cc
blob7a9e2847ae0ca23c25f5e983f864201a2d4ee978
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"
10 namespace content {
12 scoped_ptr<ServiceWorkerRegistrationHandleReference>
13 ServiceWorkerRegistrationHandleReference::Create(
14 const ServiceWorkerRegistrationObjectInfo& info,
15 ThreadSafeSender* sender) {
16 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference(
17 info, sender, true));
20 scoped_ptr<ServiceWorkerRegistrationHandleReference>
21 ServiceWorkerRegistrationHandleReference::Adopt(
22 const ServiceWorkerRegistrationObjectInfo& info,
23 ThreadSafeSender* sender) {
24 return make_scoped_ptr(new ServiceWorkerRegistrationHandleReference(
25 info, sender, false));
28 ServiceWorkerRegistrationHandleReference::
29 ServiceWorkerRegistrationHandleReference(
30 const ServiceWorkerRegistrationObjectInfo& info,
31 ThreadSafeSender* sender,
32 bool increment_ref_in_ctor)
33 : info_(info),
34 sender_(sender) {
35 DCHECK_NE(kInvalidServiceWorkerRegistrationHandleId, info_.handle_id);
36 DCHECK(sender_.get());
37 if (!increment_ref_in_ctor)
38 return;
39 sender_->Send(
40 new ServiceWorkerHostMsg_IncrementRegistrationRefCount(info_.handle_id));
43 ServiceWorkerRegistrationHandleReference::
44 ~ServiceWorkerRegistrationHandleReference() {
45 sender_->Send(
46 new ServiceWorkerHostMsg_DecrementRegistrationRefCount(info_.handle_id));
49 } // namespace content