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

Unified Diff: Source/bindings/core/v8/ScriptValue.cpp

Issue 1130763006: IDL: Add any support to IDL dictionary and use it in CustomEventInit (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 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: 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());
+ ASSERT(!targetScriptState->world().isWorkerWorld());
haraken 2015/05/20 00:43:42 Are these isWorkerWorld checks useful?
bashi 2015/05/20 00:52:22 I thought someone may misuse v8ValueFor() in worke
+ 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())

Powered by Google App Engine
This is Rietveld 408576698