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 |