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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SerializationTag.h

Issue 2386173002: reflow comments in Source/bindings/core/v8 (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 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 #ifndef SerializationTag_h 5 #ifndef SerializationTag_h
6 #define SerializationTag_h 6 #define SerializationTag_h
7 7
8 namespace blink { 8 namespace blink {
9 9
10 // Serialization format is a sequence of tags followed by zero or more data argu ments. 10 // Serialization format is a sequence of tags followed by zero or more data
11 // Tags always take exactly one byte. A serialized stream first begins with 11 // arguments. Tags always take exactly one byte. A serialized stream first
12 // a complete VersionTag. If the stream does not begin with a VersionTag, we ass ume that 12 // begins with a complete VersionTag. If the stream does not begin with a
13 // the stream is in format 0. 13 // VersionTag, we assume that the stream is in format 0.
14 14
15 // This format is private to the implementation of SerializedScriptValue. Do not rely on it 15 // This format is private to the implementation of SerializedScriptValue. Do not
16 // externally. It is safe to persist a SerializedScriptValue as a binary blob, b ut this 16 // rely on it externally. It is safe to persist a SerializedScriptValue as a
17 // code should always be used to interpret it. 17 // binary blob, but this code should always be used to interpret it.
18 18
19 // WebCoreStrings are read as (length:uint32_t, string:UTF8[length]). 19 // WebCoreStrings are read as (length:uint32_t, string:UTF8[length]).
20 // RawStrings are read as (length:uint32_t, string:UTF8[length]). 20 // RawStrings are read as (length:uint32_t, string:UTF8[length]).
21 // RawUCharStrings are read as (length:uint32_t, string:UChar[length/sizeof(UCha r)]). 21 // RawUCharStrings are read as
22 // RawFiles are read as (path:WebCoreString, url:WebCoreStrng, type:WebCoreStrin g). 22 // (length:uint32_t, string:UChar[length/sizeof(UChar)]).
23 // There is a reference table that maps object references (uint32_t) to v8::Valu es. 23 // RawFiles are read as
24 // Tokens marked with (ref) are inserted into the reference table and given the next object reference ID after decoding. 24 // (path:WebCoreString, url:WebCoreStrng, type:WebCoreString).
25 // All tags except InvalidTag, PaddingTag, ReferenceCountTag, VersionTag, Genera teFreshObjectTag 25 // There is a reference table that maps object references (uint32_t) to
26 // and GenerateFreshArrayTag push their results to the deserialization stack . 26 // v8::Values.
27 // There is also an 'open' stack that is used to resolve circular references. Ob jects or arrays may 27 // Tokens marked with (ref) are inserted into the reference table and given the
28 // contain self-references. Before we begin to deserialize the contents of t hese values, they 28 // next object reference ID after decoding.
29 // are first given object reference IDs (by GenerateFreshObjectTag/GenerateF reshArrayTag); 29 // All tags except InvalidTag, PaddingTag, ReferenceCountTag, VersionTag,
30 // these reference IDs are then used with ObjectReferenceTag to tie the recu rsive knot. 30 // GenerateFreshObjectTag and GenerateFreshArrayTag push their results to the
31 // deserialization stack.
32 // There is also an 'open' stack that is used to resolve circular references.
33 // Objects or arrays may contain self-references. Before we begin to deserialize
34 // the contents of these values, they are first given object reference IDs (by
35 // GenerateFreshObjectTag/GenerateFreshArrayTag); these reference IDs are then
36 // used with ObjectReferenceTag to tie the recursive knot.
31 enum SerializationTag { 37 enum SerializationTag {
32 InvalidTag = '!', // Causes deserialization to fail. 38 InvalidTag = '!', // Causes deserialization to fail.
33 PaddingTag = '\0', // Is ignored (but consumed). 39 PaddingTag = '\0', // Is ignored (but consumed).
34 UndefinedTag = '_', // -> <undefined> 40 UndefinedTag = '_', // -> <undefined>
35 NullTag = '0', // -> <null> 41 NullTag = '0', // -> <null>
36 TrueTag = 'T', // -> <true> 42 TrueTag = 'T', // -> <true>
37 FalseTag = 'F', // -> <false> 43 FalseTag = 'F', // -> <false>
38 StringTag = 'S', // string:RawString -> string 44 StringTag = 'S', // string:RawString -> string
39 StringUCharTag = 'c', // string:RawUCharString -> string 45 StringUCharTag = 'c', // string:RawUCharString -> string
40 Int32Tag = 'I', // value:ZigZag-encoded int32 -> Integer 46 Int32Tag = 'I', // value:ZigZag-encoded int32 -> Integer
41 Uint32Tag = 'U', // value:uint32_t -> Integer 47 Uint32Tag = 'U', // value:uint32_t -> Integer
42 DateTag = 'D', // value:double -> Date (ref) 48 DateTag = 'D', // value:double -> Date (ref)
43 MessagePortTag = 49 MessagePortTag = 'M', // index:int -> MessagePort. Fills the result with
44 'M', // index:int -> MessagePort. Fills the result with transferred Messa gePort. 50 // transferred MessagePort.
45 NumberTag = 'N', // value:double -> Number 51 NumberTag = 'N', // value:double -> Number
46 BlobTag = 52 BlobTag = 'b', // uuid:WebCoreString, type:WebCoreString, size:uint64_t ->
47 'b', // uuid:WebCoreString, type:WebCoreString, size:uint64_t -> Blob (re f) 53 // Blob (ref)
48 BlobIndexTag = 'i', // index:int32_t -> Blob (ref) 54 BlobIndexTag = 'i', // index:int32_t -> Blob (ref)
49 FileTag = 'f', // file:RawFile -> File (ref) 55 FileTag = 'f', // file:RawFile -> File (ref)
50 FileIndexTag = 'e', // index:int32_t -> File (ref) 56 FileIndexTag = 'e', // index:int32_t -> File (ref)
51 DOMFileSystemTag = 57 DOMFileSystemTag = 'd', // type:int32_t, name:WebCoreString,
52 'd', // type:int32_t, name:WebCoreString, uuid:WebCoreString -> FileSyste m (ref) 58 // uuid:WebCoreString -> FileSystem (ref)
53 FileListTag = 59 FileListTag =
54 'l', // length:uint32_t, files:RawFile[length] -> FileList (ref) 60 'l', // length:uint32_t, files:RawFile[length] -> FileList (ref)
55 FileListIndexTag = 61 FileListIndexTag =
56 'L', // length:uint32_t, files:int32_t[length] -> FileList (ref) 62 'L', // length:uint32_t, files:int32_t[length] -> FileList (ref)
57 ImageDataTag = 63 ImageDataTag = '#', // width:uint32_t, height:uint32_t,
58 '#', // width:uint32_t, height:uint32_t, pixelDataLength:uint32_t, data:b yte[pixelDataLength] -> ImageData (ref) 64 // pixelDataLength:uint32_t, data:byte[pixelDataLength]
59 ObjectTag = 65 // -> ImageData (ref)
60 '{', // numProperties:uint32_t -> pops the last object from the open stac k; 66 // numProperties:uint32_t -> pops the last object from the open stack; fills
61 // fills it with the last numProperties name,value pairs pushed onto the deserialization stack 67 // it with the last numProperties name,value pairs pushed onto the
62 SparseArrayTag = 68 // deserialization stack
63 '@', // numProperties:uint32_t, length:uint32_t -> pops the last object f rom the open stack; 69 ObjectTag = '{',
64 // fills it with the last numProperties name,value pairs pushed onto the deserialization stack 70 // numProperties:uint32_t, length:uint32_t -> pops the last object from the
65 DenseArrayTag = 71 // open stack; fills it with the last numProperties name,value pairs pushed
66 '$', // numProperties:uint32_t, length:uint32_t -> pops the last object f rom the open stack; 72 // onto the deserialization stack
67 // fills it with t he last length elements and numProperties name,value pairs pushed onto deseriali zation stack 73 SparseArrayTag = '@',
74 // numProperties:uint32_t, length:uint32_t -> pops the last object from the
75 // open stack; fills it with the last length elements and numProperties
76 // name,value pairs pushed onto deserialization stack
77 DenseArrayTag = '$',
68 RegExpTag = 'R', // pattern:RawString, flags:uint32_t -> RegExp (ref) 78 RegExpTag = 'R', // pattern:RawString, flags:uint32_t -> RegExp (ref)
69 ArrayBufferTag = 79 ArrayBufferTag =
70 'B', // byteLength:uint32_t, data:byte[byteLength] -> ArrayBuffer (ref) 80 'B', // byteLength:uint32_t, data:byte[byteLength] -> ArrayBuffer (ref)
71 ArrayBufferTransferTag = 81 ArrayBufferTransferTag =
72 't', // index:uint32_t -> ArrayBuffer. For ArrayBuffer transfer 82 't', // index:uint32_t -> ArrayBuffer. For ArrayBuffer transfer
73 ImageBitmapTag = 'g', // size:uint32_t, data:byte[size] -> ImageBitmap (ref) 83 ImageBitmapTag = 'g', // size:uint32_t, data:byte[size] -> ImageBitmap (ref)
74 ImageBitmapTransferTag = 84 ImageBitmapTransferTag =
75 'G', // index:uint32_t -> ImageBitmap. For ImageBitmap transfer 85 'G', // index:uint32_t -> ImageBitmap. For ImageBitmap transfer
76 OffscreenCanvasTransferTag = 86 OffscreenCanvasTransferTag = 'H', // index, width, height, id:uint32_t ->
77 'H', // index, width, height, id:uint32_t -> OffscreenCanvas. For Offscre enCanvas transfer 87 // OffscreenCanvas. For OffscreenCanvas
78 ArrayBufferViewTag = 88 // transfer
79 'V', // subtag:byte, byteOffset:uint32_t, byteLength:uint32_t -> ArrayBuf ferView (ref). Consumes an ArrayBuffer from the top of the deserialization stack . 89 // subtag:byte, byteOffset:uint32_t, byteLength:uint32_t -> ArrayBufferView
80 SharedArrayBufferTransferTag = 90 // (ref). Consumes an ArrayBuffer from the top of the deserialization stack.
81 'u', // index:uint32_t -> SharedArrayBuffer. For SharedArrayBuffer transf er 91 ArrayBufferViewTag = 'V',
92 SharedArrayBufferTransferTag = 'u', // index:uint32_t -> SharedArrayBuffer.
93 // For SharedArrayBuffer transfer
82 WasmModuleTag = 'W', 94 WasmModuleTag = 'W',
83 CryptoKeyTag = 95 CryptoKeyTag = 'K', // subtag:byte, props, usages:uint32_t,
84 'K', // subtag:byte, props, usages:uint32_t, keyDataLength:uint32_t, keyD ata:byte[keyDataLength] 96 // keyDataLength:uint32_t, keyData:byte[keyDataLength]
85 // If subtag=AesKeyTag: 97 // If subtag=AesKeyTag:
86 // props = keyLengthBytes:uint32_t, algorithmId:uint32_t 98 // props = keyLengthBytes:uint32_t, algorithmId:uint32_t
87 // If subtag=HmacKeyTag: 99 // If subtag=HmacKeyTag:
88 // props = keyLengthBytes:uint32_t, hashId:uint32_t 100 // props = keyLengthBytes:uint32_t, hashId:uint32_t
89 // If subtag=RsaHashedKeyTag: 101 // If subtag=RsaHashedKeyTag:
90 // props = algorithmId:uint32_t, type:uint32_t, modulusLen gthBits:uint32_t, publicExponentLength:uint32_t, publicExponent:byte[publicExpon entLength], hashId:uint32_t 102 // props = algorithmId:uint32_t, type:uint32_t,
103 // modulusLengthBits:uint32_t,
104 // publicExponentLength:uint32_t,
105 // publicExponent:byte[publicExponentLength],
106 // hashId:uint32_t
91 // If subtag=EcKeyTag: 107 // If subtag=EcKeyTag:
92 // props = algorithmId:uint32_t, type:uint32_t, namedCurve :uint32_t 108 // props = algorithmId:uint32_t, type:uint32_t,
93 RTCCertificateTag = 109 // namedCurve:uint32_t
94 'k', // length:uint32_t, pemPrivateKey:WebCoreString, pemCertificate:WebC oreString 110 RTCCertificateTag = 'k', // length:uint32_t, pemPrivateKey:WebCoreString,
111 // pemCertificate:WebCoreString
95 ObjectReferenceTag = '^', // ref:uint32_t -> reference table[ref] 112 ObjectReferenceTag = '^', // ref:uint32_t -> reference table[ref]
96 GenerateFreshObjectTag = 113 GenerateFreshObjectTag = 'o', // -> empty object allocated an object ID and
97 'o', // -> empty object allocated an object ID and pushed onto the open s tack (ref) 114 // pushed onto the open stack (ref)
98 GenerateFreshSparseArrayTag = 115 GenerateFreshSparseArrayTag = 'a', // length:uint32_t -> empty array[length]
99 'a', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref) 116 // allocated an object ID and pushed onto
100 GenerateFreshDenseArrayTag = 117 // the open stack (ref)
101 'A', // length:uint32_t -> empty array[length] allocated an object ID and pushed onto the open stack (ref) 118 GenerateFreshDenseArrayTag = 'A', // length:uint32_t -> empty array[length]
102 ReferenceCountTag = 119 // allocated an object ID and pushed onto
103 '?', // refTableSize:uint32_t -> If the reference table is not refTableSize big, fails. 120 // the open stack (ref)
104 StringObjectTag = 's', // string:RawString -> new String(string) (ref) 121 ReferenceCountTag = '?', // refTableSize:uint32_t -> If the reference table
105 NumberObjectTag = 'n', // value:double -> new Number(value) (ref) 122 // is not refTableSize big, fails.
106 TrueObjectTag = 'y', // new Boolean(true) (ref) 123 StringObjectTag = 's', // string:RawString -> new String(string) (ref)
107 FalseObjectTag = 'x', // new Boolean(false) (ref) 124 NumberObjectTag = 'n', // value:double -> new Number(value) (ref)
125 TrueObjectTag = 'y', // new Boolean(true) (ref)
126 FalseObjectTag = 'x', // new Boolean(false) (ref)
108 CompositorProxyTag = 127 CompositorProxyTag =
109 'C', // elementId:uint64_t, bitfields:uint32_t -> CompositorProxy (ref) 128 'C', // elementId:uint64_t, bitfields:uint32_t -> CompositorProxy (ref)
110 MapTag = 129 MapTag = ':', // length:uint32_t -> pops the last object from the open stack
111 ':', // length:uint32_t -> pops the last object from the open stack (it w ill be a Map); 130 // (it will be a Map);
112 // fills it with the last length elements pushed onto the deserialization stack, treating them as key/value pairs and passing the m to Map::Set; 131 // fills it with the last length elements pushed
132 // onto the deserialization stack, treating them
133 // as key/value pairs and passing them to
134 // Map::Set;
113 // length must be an even number. 135 // length must be an even number.
114 SetTag = 136 SetTag = ',', // length:uint32_t -> pops the last object from the open stack
115 ',', // length:uint32_t -> pops the last object from the open stack (it w ill be a Set); 137 // (it will be a Set);
116 // fills it with the last length elements pushed onto the deserialization stack, using Set::Add 138 // fills it with the last length elements pushed
117 GenerateFreshMapTag = 139 // onto the deserialization stack, using Set::Add
118 ';', // -> empty Map allocated an object ID and pushed onto the open stac k (ref) 140 GenerateFreshMapTag = ';', // -> empty Map allocated an object ID and pushed
119 GenerateFreshSetTag = 141 // onto the open stack (ref)
120 '\'', // -> empty Set allocated an object ID and pushed onto the open sta ck (ref) 142 GenerateFreshSetTag = '\'', // -> empty Set allocated an object ID and pushed
143 // onto the open stack (ref)
121 VersionTag = 0xFF // version:uint32_t -> Uses this as the file version. 144 VersionTag = 0xFF // version:uint32_t -> Uses this as the file version.
122 }; 145 };
123 146
124 enum ArrayBufferViewSubTag { 147 enum ArrayBufferViewSubTag {
125 ByteArrayTag = 'b', 148 ByteArrayTag = 'b',
126 UnsignedByteArrayTag = 'B', 149 UnsignedByteArrayTag = 'B',
127 UnsignedByteClampedArrayTag = 'C', 150 UnsignedByteClampedArrayTag = 'C',
128 ShortArrayTag = 'w', 151 ShortArrayTag = 'w',
129 UnsignedShortArrayTag = 'W', 152 UnsignedShortArrayTag = 'W',
130 IntArrayTag = 'd', 153 IntArrayTag = 'd',
131 UnsignedIntArrayTag = 'D', 154 UnsignedIntArrayTag = 'D',
132 FloatArrayTag = 'f', 155 FloatArrayTag = 'f',
133 DoubleArrayTag = 'F', 156 DoubleArrayTag = 'F',
134 DataViewTag = '?' 157 DataViewTag = '?'
135 }; 158 };
136 159
137 } // namespace blink 160 } // namespace blink
138 161
139 #endif 162 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698