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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_handle.cc
diff --git a/content/browser/service_worker/service_worker_handle.cc b/content/browser/service_worker/service_worker_handle.cc
new file mode 100644
index 0000000000000000000000000000000000000000..61b4bc9c869bfdc6fb05cff331aa779137880103
--- /dev/null
+++ b/content/browser/service_worker/service_worker_handle.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/service_worker/service_worker_context_core.h"
+#include "content/browser/service_worker/service_worker_handle.h"
+#include "content/browser/service_worker/service_worker_registration.h"
+
+namespace content {
+
+scoped_ptr<ServiceWorkerHandle> ServiceWorkerHandle::Create(
+ base::WeakPtr<ServiceWorkerContextCore> context,
+ IPC::Sender* sender,
+ ServiceWorkerVersion* version) {
+ if (!context || !version)
+ return scoped_ptr<ServiceWorkerHandle>();
+ ServiceWorkerRegistration* registration =
+ context->GetLiveRegistration(version->registration_id());
+ return make_scoped_ptr(
+ new ServiceWorkerHandle(context, sender, registration, version));
+}
+
+ServiceWorkerHandle::ServiceWorkerHandle(
+ base::WeakPtr<ServiceWorkerContextCore> context,
+ IPC::Sender* sender,
+ ServiceWorkerRegistration* registration,
+ ServiceWorkerVersion* version)
+ : context_(context),
+ sender_(sender),
+ registration_(registration),
+ version_(version) {
+ // context_->IncrementRegistrationCacheCount(registration);
+}
+
+ServiceWorkerHandle::~ServiceWorkerHandle() {
+ // We can discard the registration after all documents/handles that
+ // have a reference to the registration is closed or freed up, but
+ // could also keep it alive in cache for a while with some timer so that
+ // we don't need to re-create the same registration over and over?
+ //
+ // if (context_)
+ // context_->DecrementRegistrationCacheCount(registration);
+}
+
+void ServiceWorkerHandle::OnVersionStateChanged() {
+ // TODO(kinuko): Implement.
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698