OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "bindings/core/v8/SerializedScriptValueFactory.h" | |
7 | |
8 #include "bindings/core/v8/ExceptionState.h" | |
9 #include "bindings/core/v8/ScriptValueSerializer.h" | |
10 #include "wtf/ByteOrder.h" | |
11 #include "wtf/text/StringBuffer.h" | |
12 | |
13 namespace blink { | |
14 | |
15 SerializedScriptValueFactory* SerializedScriptValueFactory::m_singleton = 0; | |
16 | |
17 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(v8::Handl e<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffe rs, 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
| |
18 { | |
19 return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, 0, exceptionState, isolate)); | |
20 } | |
21 | |
22 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createAndSwallow Exceptions(v8::Isolate* isolate, v8::Handle<v8::Value> value) | |
23 { | |
24 TrackExceptionState exceptionState; | |
25 return create(value, 0, 0, exceptionState, isolate); | |
26 } | |
27 | |
28 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const Scr iptValue& value, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState, v8: :Isolate* isolate) | |
29 { | |
30 ASSERT(isolate->InContext()); | |
31 return adoptRef(new SerializedScriptValue(value.v8Value(), 0, 0, blobInfo, e xceptionState, isolate)); | |
32 } | |
33 | |
34 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createFromWire(c onst String& data) | |
35 { | |
36 return adoptRef(new SerializedScriptValue(data)); | |
37 } | |
38 | |
39 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::createFromWireBy tes(const Vector<uint8_t>& data) | |
40 { | |
41 // Decode wire data from big endian to host byte order. | |
42 ASSERT(!(data.size() % sizeof(UChar))); | |
43 size_t length = data.size() / sizeof(UChar); | |
44 StringBuffer<UChar> buffer(length); | |
45 const UChar* src = reinterpret_cast<const UChar*>(data.data()); | |
46 UChar* dst = buffer.characters(); | |
47 for (size_t i = 0; i < length; i++) | |
48 dst[i] = ntohs(src[i]); | |
49 | |
50 return createFromWire(String::adopt(buffer)); | |
51 } | |
52 | |
53 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const Str ing& data) | |
54 { | |
55 return create(data, v8::Isolate::GetCurrent()); | |
56 } | |
57 | |
58 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create(const Str ing& data, v8::Isolate* isolate) | |
59 { | |
60 SerializedScriptValueInternal::Writer writer; | |
61 writer.writeWebCoreString(data); | |
62 String wireData = writer.takeWireString(); | |
63 return createFromWire(wireData); | |
64 } | |
65 | |
66 PassRefPtr<SerializedScriptValue> SerializedScriptValueFactory::create() | |
67 { | |
68 return adoptRef(new SerializedScriptValue()); | |
69 } | |
70 | |
71 } // namespace blink | |
OLD | NEW |