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

Unified 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, 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/child/service_worker/scoped_service_worker_reference.cc
diff --git a/content/child/service_worker/scoped_service_worker_reference.cc b/content/child/service_worker/scoped_service_worker_reference.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0f626782fc75425eb5fb19cc5e9d83eeadb69fe5
--- /dev/null
+++ b/content/child/service_worker/scoped_service_worker_reference.cc
@@ -0,0 +1,50 @@
+// 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/child/service_worker/scoped_service_worker_reference.h"
+
+#include "content/child/thread_safe_sender.h"
+#include "content/common/service_worker/service_worker_messages.h"
+
+namespace content {
+
+scoped_ptr<ScopedServiceWorkerReference>
+ScopedServiceWorkerReference::Create(
+ const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender) {
+ DCHECK(sender);
+ return make_scoped_ptr(new ScopedServiceWorkerReference(info, sender, true));
+}
+
+scoped_ptr<ScopedServiceWorkerReference>
+ScopedServiceWorkerReference::CreateForDeleter(
+ const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender) {
+ DCHECK(sender);
+ return make_scoped_ptr(new ScopedServiceWorkerReference(info, sender, false));
+}
+
+ScopedServiceWorkerReference::ScopedServiceWorkerReference(
+ const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender,
+ bool increment_ref_in_ctor)
+ : info_(info),
+ sender_(sender) {
+ if (increment_ref_in_ctor &&
+ info_.handle_id != kInvalidServiceWorkerHandleId) {
+ sender_->Send(
+ new ServiceWorkerHostMsg_IncrementServiceWorkerRefCount(
+ info_.handle_id));
+ }
+}
+
+ScopedServiceWorkerReference::~ScopedServiceWorkerReference() {
+ if (info_.handle_id != kInvalidServiceWorkerHandleId) {
+ sender_->Send(
+ new ServiceWorkerHostMsg_DecrementServiceWorkerRefCount(
+ info_.handle_id));
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698