Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / child / service_worker / service_worker_handle_reference.cc
blobc42c5af8973bd33ecd2f340493e964f319f213b8
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_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<ServiceWorkerHandleReference>
13 ServiceWorkerHandleReference::Create(
14 const ServiceWorkerObjectInfo& info,
15 ThreadSafeSender* sender) {
16 DCHECK(sender);
17 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, true));
20 scoped_ptr<ServiceWorkerHandleReference> ServiceWorkerHandleReference::Adopt(
21 const ServiceWorkerObjectInfo& info,
22 ThreadSafeSender* sender) {
23 DCHECK(sender);
24 return make_scoped_ptr(new ServiceWorkerHandleReference(info, sender, false));
27 ServiceWorkerHandleReference::ServiceWorkerHandleReference(
28 const ServiceWorkerObjectInfo& info,
29 ThreadSafeSender* sender,
30 bool increment_ref_in_ctor)
31 : info_(info),
32 sender_(sender) {
33 if (increment_ref_in_ctor &&
34 info_.handle_id != kInvalidServiceWorkerHandleId) {
35 sender_->Send(
36 new ServiceWorkerHostMsg_IncrementServiceWorkerRefCount(
37 info_.handle_id));
41 ServiceWorkerHandleReference::~ServiceWorkerHandleReference() {
42 if (info_.handle_id != kInvalidServiceWorkerHandleId) {
43 sender_->Send(
44 new ServiceWorkerHostMsg_DecrementServiceWorkerRefCount(
45 info_.handle_id));
49 } // namespace content