[V8] Pass Isolate around in SerializedScriptValue.cpp (Part1)
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 17:01:26 +0000 (17:01 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 17:01:26 +0000 (17:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84663

Reviewed by Nate Chapin.

The objective is to pass Isolate to toV8() in SerializedScriptValue.cpp.

Part1: Add an Isolate argument to SerializedScriptValue::create(),
SerializedScriptValue::deserialize(), etc.
Part2: Add an m_isolate member to SerializedScriptValue::Writer()
and SerializedScriptValue::Reader().
Part3: Pass Isolate to toV8().

This patch fixes Part1.

No tests. No change in behavior.

* bindings/v8/SerializedScriptValue.cpp:
(WebCore::SerializedScriptValue::create):
(WebCore::SerializedScriptValue::undefinedValue):
(WebCore::SerializedScriptValue::booleanValue):
(WebCore::SerializedScriptValue::numberValue):
(WebCore::SerializedScriptValue::SerializedScriptValue):
(WebCore::SerializedScriptValue::deserialize):
(WebCore::SerializedScriptValue::deserializeForInspector):
* bindings/v8/SerializedScriptValue.h:
(SerializedScriptValue):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@115077 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/SerializedScriptValue.cpp
Source/WebCore/bindings/v8/SerializedScriptValue.h

index bb07c9a..da9352c 100644 (file)
@@ -1,5 +1,35 @@
 2012-04-24  Kentaro Hara  <haraken@chromium.org>
 
 2012-04-24  Kentaro Hara  <haraken@chromium.org>
 
+        [V8] Pass Isolate around in SerializedScriptValue.cpp (Part1)
+        https://bugs.webkit.org/show_bug.cgi?id=84663
+
+        Reviewed by Nate Chapin.
+
+        The objective is to pass Isolate to toV8() in SerializedScriptValue.cpp.
+
+        Part1: Add an Isolate argument to SerializedScriptValue::create(),
+        SerializedScriptValue::deserialize(), etc.
+        Part2: Add an m_isolate member to SerializedScriptValue::Writer()
+        and SerializedScriptValue::Reader().
+        Part3: Pass Isolate to toV8().
+
+        This patch fixes Part1.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/SerializedScriptValue.cpp:
+        (WebCore::SerializedScriptValue::create):
+        (WebCore::SerializedScriptValue::undefinedValue):
+        (WebCore::SerializedScriptValue::booleanValue):
+        (WebCore::SerializedScriptValue::numberValue):
+        (WebCore::SerializedScriptValue::SerializedScriptValue):
+        (WebCore::SerializedScriptValue::deserialize):
+        (WebCore::SerializedScriptValue::deserializeForInspector):
+        * bindings/v8/SerializedScriptValue.h:
+        (SerializedScriptValue):
+
+2012-04-24  Kentaro Hara  <haraken@chromium.org>
+
         [V8][Refactoring] Remove deserializeAndSetProperty()
         from SerializedScriptValue.cpp
         https://bugs.webkit.org/show_bug.cgi?id=84662
         [V8][Refactoring] Remove deserializeAndSetProperty()
         from SerializedScriptValue.cpp
         https://bugs.webkit.org/show_bug.cgi?id=84662
index d4bd132..251f349 100644 (file)
@@ -2062,15 +2062,16 @@ private:
 
 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value,
                                                                 MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
 
 PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value,
                                                                 MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
-                                                                bool& didThrow)
+                                                                bool& didThrow,
+                                                                v8::Isolate* isolate)
 {
 {
-    return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, didThrow));
+    return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, didThrow, isolate));
 }
 
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value)
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(v8::Handle<v8::Value> value, v8::Isolate* isolate)
 {
     bool didThrow;
 {
     bool didThrow;
-    return adoptRef(new SerializedScriptValue(value, 0, 0, didThrow));
+    return adoptRef(new SerializedScriptValue(value, 0, 0, didThrow, isolate));
 }
 
 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const String& data)
 }
 
 PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const String& data)
@@ -2078,7 +2079,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::createFromWire(const St
     return adoptRef(new SerializedScriptValue(data));
 }
 
     return adoptRef(new SerializedScriptValue(data));
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& data)
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::create(const String& data, v8::Isolate* isolate)
 {
     Writer writer;
     writer.writeWebCoreString(data);
 {
     Writer writer;
     writer.writeWebCoreString(data);
@@ -2105,7 +2106,7 @@ SerializedScriptValue* SerializedScriptValue::nullValue()
     return nullValue.get();
 }
 
     return nullValue.get();
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue()
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue(v8::Isolate* isolate)
 {
     Writer writer;
     writer.writeUndefined();
 {
     Writer writer;
     writer.writeUndefined();
@@ -2113,7 +2114,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::undefinedValue()
     return adoptRef(new SerializedScriptValue(wireData));
 }
 
     return adoptRef(new SerializedScriptValue(wireData));
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value)
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value, v8::Isolate* isolate)
 {
     Writer writer;
     if (value)
 {
     Writer writer;
     if (value)
@@ -2124,7 +2125,7 @@ PassRefPtr<SerializedScriptValue> SerializedScriptValue::booleanValue(bool value
     return adoptRef(new SerializedScriptValue(wireData));
 }
 
     return adoptRef(new SerializedScriptValue(wireData));
 }
 
-PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double value)
+PassRefPtr<SerializedScriptValue> SerializedScriptValue::numberValue(double value, v8::Isolate* isolate)
 {
     Writer writer;
     writer.writeNumber(value);
 {
     Writer writer;
     writer.writeNumber(value);
@@ -2189,7 +2190,8 @@ PassOwnPtr<SerializedScriptValue::ArrayBufferContentsArray> SerializedScriptValu
 
 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, 
                                              MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
 
 SerializedScriptValue::SerializedScriptValue(v8::Handle<v8::Value> value, 
                                              MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers,
-                                             bool& didThrow)
+                                             bool& didThrow,
+                                             v8::Isolate* isolate)
 {
     didThrow = false;
     Writer writer;
 {
     didThrow = false;
     Writer writer;
@@ -2240,7 +2242,7 @@ SerializedScriptValue::SerializedScriptValue(const String& wireData)
     m_data = wireData.isolatedCopy();
 }
 
     m_data = wireData.isolatedCopy();
 }
 
-v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messagePorts)
+v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messagePorts, v8::Isolate* isolate)
 {
     if (!m_data.impl())
         return v8::Null();
 {
     if (!m_data.impl())
         return v8::Null();
@@ -2251,12 +2253,12 @@ v8::Handle<v8::Value> SerializedScriptValue::deserialize(MessagePortArray* messa
 }
 
 #if ENABLE(INSPECTOR)
 }
 
 #if ENABLE(INSPECTOR)
-ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptState)
+ScriptValue SerializedScriptValue::deserializeForInspector(ScriptState* scriptState, v8::Isolate* isolate)
 {
     v8::HandleScope handleScope;
     v8::Context::Scope contextScope(scriptState->context());
 
 {
     v8::HandleScope handleScope;
     v8::Context::Scope contextScope(scriptState->context());
 
-    return ScriptValue(deserialize());
+    return ScriptValue(deserialize(0, isolate));
 }
 #endif
 
 }
 #endif
 
index 7fc668d..1847fd2 100644 (file)
@@ -52,16 +52,16 @@ public:
     // V8. When serialization is successful, |didThrow| is false.
     static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>,
                                                     MessagePortArray*, ArrayBufferArray*,
     // V8. When serialization is successful, |didThrow| is false.
     static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>,
                                                     MessagePortArray*, ArrayBufferArray*,
-                                                    bool& didThrow);
-    static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>);
+                                                    bool& didThrow, v8::Isolate* = 0);
+    static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::Isolate* = 0);
     static PassRefPtr<SerializedScriptValue> createFromWire(const String& data);
     static PassRefPtr<SerializedScriptValue> createFromWire(const String& data);
-    static PassRefPtr<SerializedScriptValue> create(const String& data);
+    static PassRefPtr<SerializedScriptValue> create(const String& data, v8::Isolate* = 0);
     static PassRefPtr<SerializedScriptValue> create();
 
     static SerializedScriptValue* nullValue();
     static PassRefPtr<SerializedScriptValue> create();
 
     static SerializedScriptValue* nullValue();
-    static PassRefPtr<SerializedScriptValue> undefinedValue();
-    static PassRefPtr<SerializedScriptValue> booleanValue(bool value);
-    static PassRefPtr<SerializedScriptValue> numberValue(double value);
+    static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate* = 0);
+    static PassRefPtr<SerializedScriptValue> booleanValue(bool value, v8::Isolate* = 0);
+    static PassRefPtr<SerializedScriptValue> numberValue(double value, v8::Isolate* = 0);
 
     PassRefPtr<SerializedScriptValue> release();
 
 
     PassRefPtr<SerializedScriptValue> release();
 
@@ -69,10 +69,10 @@ public:
 
     // Deserializes the value (in the current context). Returns a null value in
     // case of failure.
 
     // Deserializes the value (in the current context). Returns a null value in
     // case of failure.
-    v8::Handle<v8::Value> deserialize(MessagePortArray* = 0);
+    v8::Handle<v8::Value> deserialize(MessagePortArray* = 0, v8::Isolate* = 0);
 
 #if ENABLE(INSPECTOR)
 
 #if ENABLE(INSPECTOR)
-    ScriptValue deserializeForInspector(ScriptState*);
+    ScriptValue deserializeForInspector(ScriptState*, v8::Isolate* = 0);
 #endif
 
     const Vector<String>& blobURLs() const { return m_blobURLs; }
 #endif
 
     const Vector<String>& blobURLs() const { return m_blobURLs; }
@@ -85,7 +85,7 @@ private:
     typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray;
 
     SerializedScriptValue();
     typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray;
 
     SerializedScriptValue();
-    SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferArray*, bool& didThrow);
+    SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*);
     explicit SerializedScriptValue(const String& wireData);
 
     static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBufferArray&, bool& didThrow);
     explicit SerializedScriptValue(const String& wireData);
 
     static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBufferArray&, bool& didThrow);