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

Side by Side Diff: third_party/WebKit/Source/bindings/modules/v8/ScriptValueSerializerForModules.cpp

Issue 2087143002: [Binding] [Refactoring] Create Writer and Serializer in one method (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Debug build Created 4 years, 6 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 "bindings/modules/v8/ScriptValueSerializerForModules.h" 5 #include "bindings/modules/v8/ScriptValueSerializerForModules.h"
6 6
7 #include "bindings/core/v8/SerializationTag.h" 7 #include "bindings/core/v8/SerializationTag.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/modules/v8/V8CryptoKey.h" 9 #include "bindings/modules/v8/V8CryptoKey.h"
10 #include "bindings/modules/v8/V8DOMFileSystem.h" 10 #include "bindings/modules/v8/V8DOMFileSystem.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Maximum allowed value is 255 72 // Maximum allowed value is 255
73 }; 73 };
74 74
75 enum AssymetricCryptoKeyType { 75 enum AssymetricCryptoKeyType {
76 PublicKeyType = 1, 76 PublicKeyType = 1,
77 PrivateKeyType = 2, 77 PrivateKeyType = 2,
78 // Maximum allowed value is 2^32-1 78 // Maximum allowed value is 2^32-1
79 }; 79 };
80 80
81 81
82 ScriptValueSerializerForModules::ScriptValueSerializerForModules(SerializedScrip tValueWriter& writer, const Transferables* transferables, WebBlobInfoArray* blob Info, BlobDataHandleMap& blobDataHandles, v8::TryCatch& tryCatch, ScriptState* s criptState) 82 ScriptValueSerializerForModules::ScriptValueSerializerForModules(SerializedScrip tValueWriter& writer, const Transferables* transferables, WebBlobInfoArray* blob Info, ScriptState* scriptState)
83 : ScriptValueSerializer(writer, transferables, blobInfo, blobDataHandles, tr yCatch, scriptState) 83 : ScriptValueSerializer(writer, transferables, blobInfo, scriptState)
84 { 84 {
85 } 85 }
86 86
87 ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::writeDOMFileS ystem(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) 87 ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::writeDOMFileS ystem(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next)
88 { 88 {
89 DOMFileSystem* fs = V8DOMFileSystem::toImpl(value.As<v8::Object>()); 89 DOMFileSystem* fs = V8DOMFileSystem::toImpl(value.As<v8::Object>());
90 if (!fs) 90 if (!fs)
91 return 0; 91 return 0;
92 if (!fs->clonable()) 92 if (!fs->clonable())
93 return handleError(DataCloneError, "A FileSystem object could not be clo ned.", next); 93 return handleError(Status::DataCloneError, "A FileSystem object could no t be cloned.", next);
94 94
95 toSerializedScriptValueWriterForModules(writer()).writeDOMFileSystem(fs->typ e(), fs->name(), fs->rootURL().getString()); 95 toSerializedScriptValueWriterForModules(writer()).writeDOMFileSystem(fs->typ e(), fs->name(), fs->rootURL().getString());
96 return 0; 96 return 0;
97 } 97 }
98 98
99 bool ScriptValueSerializerForModules::writeCryptoKey(v8::Local<v8::Value> value) 99 bool ScriptValueSerializerForModules::writeCryptoKey(v8::Local<v8::Value> value)
100 { 100 {
101 CryptoKey* key = V8CryptoKey::toImpl(value.As<v8::Object>()); 101 CryptoKey* key = V8CryptoKey::toImpl(value.As<v8::Object>());
102 if (!key) 102 if (!key)
103 return false; 103 return false;
104 return toSerializedScriptValueWriterForModules(writer()).writeCryptoKey(key- >key()); 104 return toSerializedScriptValueWriterForModules(writer()).writeCryptoKey(key- >key());
105 } 105 }
106 106
107 ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::writeRTCCerti ficate(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next) 107 ScriptValueSerializer::StateBase* ScriptValueSerializerForModules::writeRTCCerti ficate(v8::Local<v8::Value> value, ScriptValueSerializer::StateBase* next)
108 { 108 {
109 RTCCertificate* certificate = V8RTCCertificate::toImpl(value.As<v8::Object>( )); 109 RTCCertificate* certificate = V8RTCCertificate::toImpl(value.As<v8::Object>( ));
110 if (!certificate) 110 if (!certificate)
111 return handleError(DataCloneError, "An RTCCertificate object could not b e cloned.", next); 111 return handleError(Status::DataCloneError, "An RTCCertificate object cou ld not be cloned.", next);
112 toSerializedScriptValueWriterForModules(writer()).writeRTCCertificate(*certi ficate); 112 toSerializedScriptValueWriterForModules(writer()).writeRTCCertificate(*certi ficate);
113 return nullptr; 113 return nullptr;
114 } 114 }
115 115
116 void SerializedScriptValueWriterForModules::writeDOMFileSystem(int type, const S tring& name, const String& url) 116 void SerializedScriptValueWriterForModules::writeDOMFileSystem(int type, const S tring& name, const String& url)
117 { 117 {
118 append(DOMFileSystemTag); 118 append(DOMFileSystemTag);
119 doWriteUint32(type); 119 doWriteUint32(type);
120 doWriteWebCoreString(name); 120 doWriteWebCoreString(name);
121 doWriteWebCoreString(url); 121 doWriteWebCoreString(url);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 { 318 {
319 DCHECK(!jsObject.IsEmpty()); 319 DCHECK(!jsObject.IsEmpty());
320 320
321 if (V8DOMFileSystem::hasInstance(jsObject, isolate())) { 321 if (V8DOMFileSystem::hasInstance(jsObject, isolate())) {
322 greyObject(jsObject); 322 greyObject(jsObject);
323 return writeDOMFileSystem(jsObject, next); 323 return writeDOMFileSystem(jsObject, next);
324 } 324 }
325 if (V8CryptoKey::hasInstance(jsObject, isolate())) { 325 if (V8CryptoKey::hasInstance(jsObject, isolate())) {
326 greyObject(jsObject); 326 greyObject(jsObject);
327 if (!writeCryptoKey(jsObject)) 327 if (!writeCryptoKey(jsObject))
328 return handleError(DataCloneError, "Couldn't serialize key data", ne xt); 328 return handleError(Status::DataCloneError, "Couldn't serialize key d ata", next);
329 return nullptr; 329 return nullptr;
330 } 330 }
331 if (V8RTCCertificate::hasInstance(jsObject, isolate())) { 331 if (V8RTCCertificate::hasInstance(jsObject, isolate())) {
332 greyObject(jsObject); 332 greyObject(jsObject);
333 return writeRTCCertificate(jsObject, next); 333 return writeRTCCertificate(jsObject, next);
334 } 334 }
335 335
336 return ScriptValueSerializer::doSerializeObject(jsObject, next); 336 return ScriptValueSerializer::doSerializeObject(jsObject, next);
337 } 337 }
338 338
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi tmapContents) 681 : ScriptValueDeserializer(reader, messagePorts, arrayBufferContents, imageBi tmapContents)
682 { 682 {
683 } 683 }
684 684
685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value) 685 bool ScriptValueDeserializerForModules::read(v8::Local<v8::Value>* value)
686 { 686 {
687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this); 687 return toSerializedScriptValueReaderForModules(reader()).read(value, *this);
688 } 688 }
689 689
690 } // namespace blink 690 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698