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

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

Issue 718383003: bindings: fixed incorrect dependency of SerializedScriptValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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/SerializedScriptValueFactory.cpp
diff --git a/Source/bindings/core/v8/SerializedScriptValueFactory.cpp b/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..93cc6c27c765a1b15f4ff1f46e3bfcddd1617adf
--- /dev/null
+++ b/Source/bindings/core/v8/SerializedScriptValueFactory.cpp
@@ -0,0 +1,71 @@
+// 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.
+
+#include "config.h"
+#include "bindings/core/v8/SerializedScriptValueFactory.h"
+
+#include "bindings/core/v8/ExceptionState.h"
+#include "bindings/core/v8/ScriptValueSerializer.h"
+#include "wtf/ByteOrder.h"
+#include "wtf/text/StringBuffer.h"
+
+namespace blink {
+
+SerializedScriptValueFactory* SerializedScriptValueFactory::m_singleton = 0;
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Handle<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate)
haraken 2014/11/17 01:27:49 Probably I'm wrong, but can we implement all of th
tasak 2014/11/17 08:42:30 I would like to ask one thing: is it possible to r
haraken 2014/11/17 08:49:52 No. That is something we want to look at in the fu
+{
+ return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, 0, exceptionState, isolate));
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createAndSwallowExceptions(v8::Isolate* isolate, v8::Handle<v8::Value> value)
+{
+ TrackExceptionState exceptionState;
+ return create(value, 0, 0, exceptionState, isolate);
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const ScriptValue& value, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState, v8::Isolate* isolate)
+{
+ ASSERT(isolate->InContext());
+ return adoptRef(new SerializedScriptValue(value.v8Value(), 0, 0, blobInfo, exceptionState, isolate));
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createFromWire(const String& data)
+{
+ return adoptRef(new SerializedScriptValue(data));
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createFromWireBytes(const Vector<uint8_t>& data)
+{
+ // Decode wire data from big endian to host byte order.
+ ASSERT(!(data.size() % sizeof(UChar)));
+ size_t length = data.size() / sizeof(UChar);
+ StringBuffer<UChar> buffer(length);
+ const UChar* src = reinterpret_cast<const UChar*>(data.data());
+ UChar* dst = buffer.characters();
+ for (size_t i = 0; i < length; i++)
+ dst[i] = ntohs(src[i]);
+
+ return createFromWire(String::adopt(buffer));
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const String& data)
+{
+ return create(data, v8::Isolate::GetCurrent());
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const String& data, v8::Isolate* isolate)
+{
+ SerializedScriptValueInternal::Writer writer;
+ writer.writeWebCoreString(data);
+ String wireData = writer.takeWireString();
+ return createFromWire(wireData);
+}
+
+PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create()
+{
+ return adoptRef(new SerializedScriptValue());
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698