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

Side by Side Diff: content/browser/service_worker/service_worker_handle.cc

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/browser/service_worker/service_worker_context_core.h"
6 #include "content/browser/service_worker/service_worker_handle.h"
7 #include "content/browser/service_worker/service_worker_registration.h"
8
9 namespace content {
10
11 scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create(
12 base::WeakPtr<ServiceWorkerContextCore> context,
13 IPC::Sender* sender,
14 ServiceWorkerVersion* version) {
15 if (!context || !version)
16 return scoped_ptr<ServiceWorkerHandle>();
17 ServiceWorkerRegistration* registration =
18 context->GetLiveRegistration(version->registration_id());
19 return make_scoped_ptr(
20 new ServiceWorkerHandle(context, sender, registration, version));
21 }
22
23 ServiceWorkerHandle::ServiceWorkerHandle(
24 base::WeakPtr<ServiceWorkerContextCore> context,
25 IPC::Sender* sender,
26 ServiceWorkerRegistration* registration,
27 ServiceWorkerVersion* version)
28 : context_(context),
29 sender_(sender),
30 registration_(registration),
31 version_(version) {
32 // context_->IncrementRegistrationCacheCount(registration);
33 }
34
35 ServiceWorkerHandle::~ServiceWorkerHandle() {
36 // We can discard the registration after all documents/handles that
37 // have a reference to the registration is closed or freed up, but
38 // could also keep it alive in cache for a while with some timer so that
39 // we don't need to re-create the same registration over and over?
40 //
41 // if (context_)
42 // context_->DecrementRegistrationCacheCount(registration);
43 }
44
45 void ServiceWorkerHandle::OnVersionStateChanged() {
46 // TODO(kinuko): Implement.
47 }
48
49 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698