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

Unified Diff: Source/bindings/v8/ScriptValue.h

Issue 146523002: Limit the usage of SharedPersistent to ScriptValue only (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/bindings/v8/ScriptController.cpp ('k') | Source/bindings/v8/SharedPersistent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptValue.h
diff --git a/Source/bindings/v8/ScriptValue.h b/Source/bindings/v8/ScriptValue.h
index 124ea110c3a81f88e4a2aef6efb7731469c3ec17..1f9e74aa956565dd7375c159ace96bd79e4c8124 100644
--- a/Source/bindings/v8/ScriptValue.h
+++ b/Source/bindings/v8/ScriptValue.h
@@ -31,8 +31,8 @@
#ifndef ScriptValue_h
#define ScriptValue_h
-#include "bindings/v8/SharedPersistent.h"
-#include "wtf/PassRefPtr.h"
+#include "bindings/v8/ScopedPersistent.h"
+#include "wtf/RefCounted.h"
#include "wtf/RefPtr.h"
#include "wtf/text/WTFString.h"
#include <v8.h>
@@ -42,6 +42,32 @@ namespace WebCore {
class JSONValue;
class ScriptState;
+template <typename T>
+class SharedPersistent : public RefCounted<SharedPersistent<T> > {
jochen (gone - plz use gerrit) 2014/01/24 12:19:21 doesn't need to be a template anymore, does it? y
haraken 2014/01/24 12:31:06 Good point, fixed.
+ WTF_MAKE_NONCOPYABLE(SharedPersistent);
+public:
+ static PassRefPtr<SharedPersistent<T> > create(v8::Handle<T> value, v8::Isolate* isolate)
+ {
+ return adoptRef(new SharedPersistent<T>(value, isolate));
+ }
+
+ v8::Local<T> newLocal(v8::Isolate* isolate) const
+ {
+ return m_value.newLocal(isolate);
+ }
+
+ bool isEmpty() { return m_value.isEmpty(); }
+
+ bool operator==(const SharedPersistent<T>& other)
+ {
+ return m_value == other.m_value;
+ }
+
+private:
+ SharedPersistent(v8::Handle<T> value, v8::Isolate* isolate) : m_value(isolate, value) { }
+ ScopedPersistent<T> m_value;
+};
+
class ScriptValue {
public:
ScriptValue()
« no previous file with comments | « Source/bindings/v8/ScriptController.cpp ('k') | Source/bindings/v8/SharedPersistent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698