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

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

Issue 2438653002: Support serializable DOMFileSystem on the V8-based structured clone path. (Closed)
Patch Set: Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/serialization/V8ScriptValueSerializerForModules.h" 5 #include "bindings/modules/v8/serialization/V8ScriptValueSerializerForModules.h"
6 6
7 #include "bindings/core/v8/ScriptWrappable.h" 7 #include "bindings/core/v8/ScriptWrappable.h"
8 #include "bindings/modules/v8/V8CryptoKey.h" 8 #include "bindings/modules/v8/V8CryptoKey.h"
9 #include "bindings/modules/v8/V8DOMFileSystem.h"
9 #include "bindings/modules/v8/V8RTCCertificate.h" 10 #include "bindings/modules/v8/V8RTCCertificate.h"
10 #include "bindings/modules/v8/serialization/WebCryptoSubTags.h" 11 #include "bindings/modules/v8/serialization/WebCryptoSubTags.h"
12 #include "platform/FileSystemType.h"
11 #include "public/platform/Platform.h" 13 #include "public/platform/Platform.h"
12 #include "public/platform/WebCrypto.h" 14 #include "public/platform/WebCrypto.h"
13 #include "public/platform/WebCryptoKey.h" 15 #include "public/platform/WebCryptoKey.h"
14 #include "public/platform/WebCryptoKeyAlgorithm.h" 16 #include "public/platform/WebCryptoKeyAlgorithm.h"
15 17
16 namespace blink { 18 namespace blink {
17 19
18 bool V8ScriptValueSerializerForModules::writeDOMObject( 20 bool V8ScriptValueSerializerForModules::writeDOMObject(
19 ScriptWrappable* wrappable, 21 ScriptWrappable* wrappable,
20 ExceptionState& exceptionState) { 22 ExceptionState& exceptionState) {
21 // Give the core/ implementation a chance to try first. 23 // Give the core/ implementation a chance to try first.
22 // If it didn't recognize the kind of wrapper, try the modules types. 24 // If it didn't recognize the kind of wrapper, try the modules types.
23 if (V8ScriptValueSerializer::writeDOMObject(wrappable, exceptionState)) 25 if (V8ScriptValueSerializer::writeDOMObject(wrappable, exceptionState))
24 return true; 26 return true;
25 if (exceptionState.hadException()) 27 if (exceptionState.hadException())
26 return false; 28 return false;
27 29
28 const WrapperTypeInfo* wrapperTypeInfo = wrappable->wrapperTypeInfo(); 30 const WrapperTypeInfo* wrapperTypeInfo = wrappable->wrapperTypeInfo();
29 if (wrapperTypeInfo == &V8CryptoKey::wrapperTypeInfo) { 31 if (wrapperTypeInfo == &V8CryptoKey::wrapperTypeInfo) {
30 return writeCryptoKey(wrappable->toImpl<CryptoKey>()->key(), 32 return writeCryptoKey(wrappable->toImpl<CryptoKey>()->key(),
31 exceptionState); 33 exceptionState);
32 } 34 }
35 if (wrapperTypeInfo == &V8DOMFileSystem::wrapperTypeInfo) {
36 DOMFileSystem* fs = wrappable->toImpl<DOMFileSystem>();
37 if (!fs->clonable()) {
38 exceptionState.throwDOMException(
39 DataCloneError, "A FileSystem object could not be cloned.");
40 return false;
41 }
42 writeTag(DOMFileSystemTag);
43 // This locks in the values of the FileSystemType enumerators.
44 writeUint32(static_cast<uint32_t>(fs->type()));
45 writeUTF8String(fs->name());
46 writeUTF8String(fs->rootURL().getString());
47 return true;
48 }
33 if (wrapperTypeInfo == &V8RTCCertificate::wrapperTypeInfo) { 49 if (wrapperTypeInfo == &V8RTCCertificate::wrapperTypeInfo) {
34 RTCCertificate* certificate = wrappable->toImpl<RTCCertificate>(); 50 RTCCertificate* certificate = wrappable->toImpl<RTCCertificate>();
35 WebRTCCertificatePEM pem = certificate->certificate().toPEM(); 51 WebRTCCertificatePEM pem = certificate->certificate().toPEM();
36 writeTag(RTCCertificateTag); 52 writeTag(RTCCertificateTag);
37 writeUTF8String(pem.privateKey()); 53 writeUTF8String(pem.privateKey());
38 writeUTF8String(pem.certificate()); 54 writeUTF8String(pem.certificate());
39 return true; 55 return true;
40 } 56 }
41 return false; 57 return false;
42 } 58 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 "A CryptoKey object could not be cloned."); 215 "A CryptoKey object could not be cloned.");
200 return false; 216 return false;
201 } 217 }
202 writeUint32(keyData.size()); 218 writeUint32(keyData.size());
203 writeRawBytes(keyData.data(), keyData.size()); 219 writeRawBytes(keyData.data(), keyData.size());
204 220
205 return true; 221 return true;
206 } 222 }
207 223
208 } // namespace blink 224 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698