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

Side by Side Diff: content/browser/service_worker/service_worker_handle.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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_handle.h" 5 #include "content/browser/service_worker/service_worker_handle.h"
6 6
7 #include "content/browser/service_worker/service_worker_context_core.h" 7 #include "content/browser/service_worker/service_worker_context_core.h"
8 #include "content/browser/service_worker/service_worker_registration.h" 8 #include "content/browser/service_worker/service_worker_registration.h"
9 #include "content/common/service_worker/service_worker_messages.h" 9 #include "content/common/service_worker/service_worker_messages.h"
10 #include "ipc/ipc_sender.h" 10 #include "ipc/ipc_sender.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 ServiceWorkerHandle::ServiceWorkerHandle( 56 ServiceWorkerHandle::ServiceWorkerHandle(
57 base::WeakPtr<ServiceWorkerContextCore> context, 57 base::WeakPtr<ServiceWorkerContextCore> context,
58 IPC::Sender* sender, 58 IPC::Sender* sender,
59 int thread_id, 59 int thread_id,
60 ServiceWorkerRegistration* registration, 60 ServiceWorkerRegistration* registration,
61 ServiceWorkerVersion* version) 61 ServiceWorkerVersion* version)
62 : context_(context), 62 : context_(context),
63 sender_(sender), 63 sender_(sender),
64 thread_id_(thread_id), 64 thread_id_(thread_id),
65 handle_id_(context.get() ? context->GetNewServiceWorkerHandleId() : -1), 65 handle_id_(context.get() ? context->GetNewServiceWorkerHandleId() : -1),
66 ref_count_(1),
66 registration_(registration), 67 registration_(registration),
67 version_(version) { 68 version_(version) {
68 version_->AddListener(this); 69 version_->AddListener(this);
69 } 70 }
70 71
71 ServiceWorkerHandle::~ServiceWorkerHandle() { 72 ServiceWorkerHandle::~ServiceWorkerHandle() {
72 version_->RemoveListener(this); 73 version_->RemoveListener(this);
73 // TODO(kinuko): At this point we can discard the registration if 74 // TODO(kinuko): At this point we can discard the registration if
74 // all documents/handles that have a reference to the registration is 75 // all documents/handles that have a reference to the registration is
75 // closed or freed up, but could also keep it alive in cache 76 // closed or freed up, but could also keep it alive in cache
(...skipping 29 matching lines...) Expand all
105 106
106 ServiceWorkerObjectInfo ServiceWorkerHandle::GetObjectInfo() { 107 ServiceWorkerObjectInfo ServiceWorkerHandle::GetObjectInfo() {
107 ServiceWorkerObjectInfo info; 108 ServiceWorkerObjectInfo info;
108 info.handle_id = handle_id_; 109 info.handle_id = handle_id_;
109 info.scope = registration_->pattern(); 110 info.scope = registration_->pattern();
110 info.url = registration_->script_url(); 111 info.url = registration_->script_url();
111 info.state = GetWebServiceWorkerState(version_); 112 info.state = GetWebServiceWorkerState(version_);
112 return info; 113 return info;
113 } 114 }
114 115
116 void ServiceWorkerHandle::IncrementRefCount() {
117 DCHECK_GT(ref_count_, 0);
118 ++ref_count_;
119 }
120
121 void ServiceWorkerHandle::DecrementRefCount() {
122 DCHECK_GE(ref_count_, 0);
123 --ref_count_;
124 }
125
115 } // namespace content 126 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_handle.h ('k') | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698