Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: content/child/service_worker/scoped_service_worker_reference.cc

Issue 261533003: Populate .current when navigator.serviceWorker is accessed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/scoped_service_worker_reference.h"
6
7 #include "content/child/thread_safe_sender.h"
8 #include "content/common/service_worker/service_worker_messages.h"
9
10 namespace content {
11
12 scoped_ptr<ScopedServiceWorkerReference>
13 ScopedServiceWorkerReference::Create(
14 const ServiceWorkerObjectInfo& info,
15 ThreadSafeSender* sender) {
16 DCHECK(sender);
17 return make_scoped_ptr(new ScopedServiceWorkerReference(info, sender, true));
18 }
19
20 scoped_ptr<ScopedServiceWorkerReference>
21 ScopedServiceWorkerReference::CreateForDeleter(
22 const ServiceWorkerObjectInfo& info,
23 ThreadSafeSender* sender) {
24 DCHECK(sender);
25 return make_scoped_ptr(new ScopedServiceWorkerReference(info, sender, false));
26 }
27
28 ScopedServiceWorkerReference::ScopedServiceWorkerReference(
29 const ServiceWorkerObjectInfo& info,
30 ThreadSafeSender* sender,
31 bool increment_ref_in_ctor)
32 : info_(info),
33 sender_(sender) {
34 if (increment_ref_in_ctor &&
35 info_.handle_id != kInvalidServiceWorkerHandleId) {
36 sender_->Send(
37 new ServiceWorkerHostMsg_IncrementServiceWorkerRefCount(
38 info_.handle_id));
39 }
40 }
41
42 ScopedServiceWorkerReference::~ScopedServiceWorkerReference() {
43 if (info_.handle_id != kInvalidServiceWorkerHandleId) {
44 sender_->Send(
45 new ServiceWorkerHostMsg_DecrementServiceWorkerRefCount(
46 info_.handle_id));
47 }
48 }
49
50 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698