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

Unified Diff: content/child/service_worker/service_worker_handle_reference.h

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 side-by-side diff with in-line comments
Download patch
Index: content/child/service_worker/service_worker_handle_reference.h
diff --git a/content/child/service_worker/service_worker_handle_reference.h b/content/child/service_worker/service_worker_handle_reference.h
new file mode 100644
index 0000000000000000000000000000000000000000..48f969f669b7f1eafd9243b29f6052ec35877ae5
--- /dev/null
+++ b/content/child/service_worker/service_worker_handle_reference.h
@@ -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.
+
+#ifndef CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
+#define CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/common/service_worker/service_worker_types.h"
+
+namespace content {
+
+class ThreadSafeSender;
+
+// Automatically increments and decrements ServiceWorkerHandle's ref-count
+// (in the browser side) in ctor and dtor.
+class ServiceWorkerHandleReference {
+ public:
+ // Creates a new ServiceWorkerHandleReference (and increments ref-count).
+ static scoped_ptr<ServiceWorkerHandleReference> Create(
+ const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender);
+ // This doesn't increment ref-count in ctor.
+ static scoped_ptr<ServiceWorkerHandleReference> CreateForDeleter(
+ const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender);
+
+ ~ServiceWorkerHandleReference();
+
+ const ServiceWorkerObjectInfo& info() const { return info_; }
+ int handle_id() const { return info_.handle_id; }
+ const GURL& scope() const { return info_.scope; }
+ const GURL& url() const { return info_.url; }
+ blink::WebServiceWorkerState state() const { return info_.state; }
+ void set_state(blink::WebServiceWorkerState state) { info_.state = state; }
+
+ private:
+ ServiceWorkerHandleReference(const ServiceWorkerObjectInfo& info,
+ ThreadSafeSender* sender,
+ bool increment_ref_in_ctor);
+ ServiceWorkerObjectInfo info_;
+ scoped_refptr<ThreadSafeSender> sender_;
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerHandleReference);
+};
+
+} // namespace content
+
+#endif // CONTENT_CHILD_SERVICE_WORKER_SERVICE_WORKER_HANDLE_REFERENCE_H_

Powered by Google App Engine
This is Rietveld 408576698