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

Side by Side Diff: Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.cpp

Issue 1117753005: Replace v8::Handle with v8::Local in Source/bindings/* (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "bindings/modules/v8/SerializedScriptValueForModulesFactory.h" 6 #include "bindings/modules/v8/SerializedScriptValueForModulesFactory.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/SerializedScriptValue.h" 9 #include "bindings/core/v8/SerializedScriptValue.h"
10 #include "bindings/modules/v8/ScriptValueSerializerForModules.h" 10 #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
11 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
12 12
13 namespace blink { 13 namespace blink {
14 14
15 PassRefPtr<SerializedScriptValue> SerializedScriptValueForModulesFactory::create (v8::Handle<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState, v8::Is olate* isolate) 15 PassRefPtr<SerializedScriptValue> SerializedScriptValueForModulesFactory::create (v8::Local<v8::Value> value, MessagePortArray* messagePorts, ArrayBufferArray* a rrayBuffers, WebBlobInfoArray* blobInfo, ExceptionState& exceptionState, v8::Iso late* isolate)
16 { 16 {
17 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory ::create(); 17 RefPtr<SerializedScriptValue> serializedValue = SerializedScriptValueFactory ::create();
18 SerializedScriptValueWriterForModules writer; 18 SerializedScriptValueWriterForModules writer;
19 ScriptValueSerializer::Status status; 19 ScriptValueSerializer::Status status;
20 String errorMessage; 20 String errorMessage;
21 { 21 {
22 v8::TryCatch tryCatch; 22 v8::TryCatch tryCatch;
23 status = SerializedScriptValueFactory::doSerialize(value, writer, messag ePorts, arrayBuffers, blobInfo, serializedValue.get(), tryCatch, errorMessage, i solate); 23 status = SerializedScriptValueFactory::doSerialize(value, writer, messag ePorts, arrayBuffers, blobInfo, serializedValue.get(), tryCatch, errorMessage, i solate);
24 if (status == ScriptValueSerializer::JSException) { 24 if (status == ScriptValueSerializer::JSException) {
25 // If there was a JS exception thrown, re-throw it. 25 // If there was a JS exception thrown, re-throw it.
(...skipping 18 matching lines...) Expand all
44 } 44 }
45 45
46 PassRefPtr<SerializedScriptValue> SerializedScriptValueForModulesFactory::create (const String& data, v8::Isolate* isolate) 46 PassRefPtr<SerializedScriptValue> SerializedScriptValueForModulesFactory::create (const String& data, v8::Isolate* isolate)
47 { 47 {
48 SerializedScriptValueWriterForModules writer; 48 SerializedScriptValueWriterForModules writer;
49 writer.writeWebCoreString(data); 49 writer.writeWebCoreString(data);
50 String wireData = writer.takeWireString(); 50 String wireData = writer.takeWireString();
51 return createFromWire(wireData); 51 return createFromWire(wireData);
52 } 52 }
53 53
54 ScriptValueSerializer::Status SerializedScriptValueForModulesFactory::doSerializ e(v8::Handle<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortA rray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, String& errorMessage , v8::Isolate* isolate) 54 ScriptValueSerializer::Status SerializedScriptValueForModulesFactory::doSerializ e(v8::Local<v8::Value> value, SerializedScriptValueWriter& writer, MessagePortAr ray* messagePorts, ArrayBufferArray* arrayBuffers, WebBlobInfoArray* blobInfo, B lobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, String& errorMessage, v8::Isolate* isolate)
55 { 55 {
56 ScriptValueSerializerForModules serializer(writer, messagePorts, arrayBuffer s, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate)); 56 ScriptValueSerializerForModules serializer(writer, messagePorts, arrayBuffer s, blobInfo, blobDataHandles, tryCatch, ScriptState::current(isolate));
57 ScriptValueSerializer::Status status = serializer.serialize(value); 57 ScriptValueSerializer::Status status = serializer.serialize(value);
58 errorMessage = serializer.errorMessage(); 58 errorMessage = serializer.errorMessage();
59 return status; 59 return status;
60 } 60 }
61 61
62 v8::Handle<v8::Value> SerializedScriptValueForModulesFactory::deserialize(String & data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBuffe rContentsArray, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebB lobInfoArray* blobInfo) 62 v8::Local<v8::Value> SerializedScriptValueForModulesFactory::deserialize(String& data, BlobDataHandleMap& blobDataHandles, ArrayBufferContentsArray* arrayBuffer ContentsArray, v8::Isolate* isolate, MessagePortArray* messagePorts, const WebBl obInfoArray* blobInfo)
63 { 63 {
64 if (!data.impl()) 64 if (!data.impl())
65 return v8::Null(isolate); 65 return v8::Null(isolate);
66 static_assert(sizeof(SerializedScriptValueWriter::BufferValueType) == 2, "Bu fferValueType should be 2 bytes"); 66 static_assert(sizeof(SerializedScriptValueWriter::BufferValueType) == 2, "Bu fferValueType should be 2 bytes");
67 data.ensure16Bit(); 67 data.ensure16Bit();
68 // FIXME: SerializedScriptValue shouldn't use String for its underlying 68 // FIXME: SerializedScriptValue shouldn't use String for its underlying
69 // storage. Instead, it should use SharedBuffer or Vector<uint8_t>. The 69 // storage. Instead, it should use SharedBuffer or Vector<uint8_t>. The
70 // information stored in m_data isn't even encoded in UTF-16. Instead, 70 // information stored in m_data isn't even encoded in UTF-16. Instead,
71 // unicode characters are encoded as UTF-8 with two code units per UChar. 71 // unicode characters are encoded as UTF-8 with two code units per UChar.
72 SerializedScriptValueReaderForModules reader(reinterpret_cast<const uint8_t* >(data.impl()->characters16()), 2 * data.length(), blobInfo, blobDataHandles, Sc riptState::current(isolate)); 72 SerializedScriptValueReaderForModules reader(reinterpret_cast<const uint8_t* >(data.impl()->characters16()), 2 * data.length(), blobInfo, blobDataHandles, Sc riptState::current(isolate));
73 ScriptValueDeserializerForModules deserializer(reader, messagePorts, arrayBu fferContentsArray); 73 ScriptValueDeserializerForModules deserializer(reader, messagePorts, arrayBu fferContentsArray);
74 return deserializer.deserialize(); 74 return deserializer.deserialize();
75 } 75 }
76 76
77 } // namespace blink 77 } // namespace blink
78 78
OLDNEW
« no previous file with comments | « Source/bindings/modules/v8/SerializedScriptValueForModulesFactory.h ('k') | Source/bindings/modules/v8/ToV8ForModules.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698