Chromium Code Reviews| Index: Source/bindings/core/v8/ScriptValue.cpp |
| diff --git a/Source/bindings/core/v8/ScriptValue.cpp b/Source/bindings/core/v8/ScriptValue.cpp |
| index 0371f67bad8694b2590b9413eea650bd6309864b..956286b5197fe8d6ce0f5e6918fbba9a2d3d718e 100644 |
| --- a/Source/bindings/core/v8/ScriptValue.cpp |
| +++ b/Source/bindings/core/v8/ScriptValue.cpp |
| @@ -32,6 +32,7 @@ |
| #include "bindings/core/v8/ScriptValue.h" |
| #include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/SerializedScriptValueFactory.h" |
| #include "bindings/core/v8/V8Binding.h" |
| #include "platform/JSONValues.h" |
| @@ -61,6 +62,22 @@ v8::Local<v8::Value> ScriptValue::v8ValueUnsafe() const |
| return m_value->newLocal(isolate()); |
| } |
| +v8::Local<v8::Value> ScriptValue::v8ValueFor(ScriptState* targetScriptState) |
| +{ |
| + if (isEmpty()) |
| + return v8::Local<v8::Value>(); |
| + v8::Isolate* isolate = targetScriptState->isolate(); |
| + if (&m_scriptState->world() == &targetScriptState->world()) |
| + return m_value->newLocal(isolate); |
| + |
| + ASSERT(isolate->InContext()); |
| + ASSERT(!m_scriptState->world().isWorkerWorld()); |
|
bashi
2015/05/13 09:44:34
I thought it's not safe to compare world between w
|
| + ASSERT(!targetScriptState->world().isWorkerWorld()); |
| + v8::Local<v8::Value> value = m_value->newLocal(isolate); |
| + RefPtr<SerializedScriptValue> serialized = SerializedScriptValueFactory::instance().createAndSwallowExceptions(isolate, value); |
| + return serialized->deserialize(); |
| +} |
| + |
| bool ScriptValue::toString(String& result) const |
| { |
| if (isEmpty()) |