OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 using ArrayBufferContentsArray = Vector<WTF::ArrayBufferContents, 1>; | 57 using ArrayBufferContentsArray = Vector<WTF::ArrayBufferContents, 1>; |
58 using ImageBitmapContentsArray = Vector<RefPtr<StaticBitmapImage>, 1>; | 58 using ImageBitmapContentsArray = Vector<RefPtr<StaticBitmapImage>, 1>; |
59 | 59 |
60 // Increment this for each incompatible change to the wire format. | 60 // Increment this for each incompatible change to the wire format. |
61 // Version 2: Added StringUCharTag for UChar v8 strings. | 61 // Version 2: Added StringUCharTag for UChar v8 strings. |
62 // Version 3: Switched to using uuids as blob data identifiers. | 62 // Version 3: Switched to using uuids as blob data identifiers. |
63 // Version 4: Extended File serialization to be complete. | 63 // Version 4: Extended File serialization to be complete. |
64 // Version 5: Added CryptoKeyTag for Key objects. | 64 // Version 5: Added CryptoKeyTag for Key objects. |
65 // Version 6: Added indexed serialization for File, Blob, and FileList. | 65 // Version 6: Added indexed serialization for File, Blob, and FileList. |
66 // Version 7: Extended File serialization with user visibility. | 66 // Version 7: Extended File serialization with user visibility. |
67 // Version 8: File.lastModified in milliseconds (seconds-based in earlier vers
ions.) | 67 // Version 8: File.lastModified in milliseconds (seconds-based in earlier |
| 68 // versions.) |
68 // Version 9: Added Map and Set support. | 69 // Version 9: Added Map and Set support. |
69 static const uint32_t wireFormatVersion = 9; | 70 static const uint32_t wireFormatVersion = 9; |
70 | 71 |
71 // VarInt encoding constants. | 72 // VarInt encoding constants. |
72 static const int varIntShift = 7; | 73 static const int varIntShift = 7; |
73 static const int varIntMask = (1 << varIntShift) - 1; | 74 static const int varIntMask = (1 << varIntShift) - 1; |
74 | 75 |
75 static PassRefPtr<SerializedScriptValue> serialize(v8::Isolate*, | 76 static PassRefPtr<SerializedScriptValue> serialize(v8::Isolate*, |
76 v8::Local<v8::Value>, | 77 v8::Local<v8::Value>, |
77 Transferables*, | 78 Transferables*, |
(...skipping 16 matching lines...) Expand all Loading... |
94 String toWireString() const { return m_data; } | 95 String toWireString() const { return m_data; } |
95 void toWireBytes(Vector<char>&) const; | 96 void toWireBytes(Vector<char>&) const; |
96 | 97 |
97 // Deserializes the value (in the current context). Returns a null value in | 98 // Deserializes the value (in the current context). Returns a null value in |
98 // case of failure. | 99 // case of failure. |
99 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); | 100 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); |
100 v8::Local<v8::Value> deserialize(v8::Isolate*, | 101 v8::Local<v8::Value> deserialize(v8::Isolate*, |
101 MessagePortArray* = 0, | 102 MessagePortArray* = 0, |
102 const WebBlobInfoArray* = 0); | 103 const WebBlobInfoArray* = 0); |
103 | 104 |
104 // Helper function which pulls the values out of a JS sequence and into a Mess
agePortArray. | 105 // Helper function which pulls the values out of a JS sequence and into a |
105 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL sp
ec and section 8.3.3 | 106 // MessagePortArray. Also validates the elements per sections 4.1.13 and |
106 // of the HTML5 spec and generates exceptions as appropriate. | 107 // 4.1.15 of the WebIDL spec and section 8.3.3 of the HTML5 spec and generates |
107 // Returns true if the array was filled, or false if the passed value was not
of an appropriate type. | 108 // exceptions as appropriate. |
| 109 // Returns true if the array was filled, or false if the passed value was not |
| 110 // of an appropriate type. |
108 static bool extractTransferables(v8::Isolate*, | 111 static bool extractTransferables(v8::Isolate*, |
109 v8::Local<v8::Value>, | 112 v8::Local<v8::Value>, |
110 int, | 113 int, |
111 Transferables&, | 114 Transferables&, |
112 ExceptionState&); | 115 ExceptionState&); |
113 | 116 |
114 // Informs the V8 about external memory allocated and owned by this object. La
rge values should contribute | 117 // Informs the V8 about external memory allocated and owned by this object. |
115 // to GC counters to eventually trigger a GC, otherwise flood of postMessage()
can cause OOM. | 118 // Large values should contribute to GC counters to eventually trigger a GC, |
| 119 // otherwise flood of postMessage() can cause OOM. |
116 // Ok to invoke multiple times (only adds memory once). | 120 // Ok to invoke multiple times (only adds memory once). |
117 // The memory registration is revoked automatically in destructor. | 121 // The memory registration is revoked automatically in destructor. |
118 void registerMemoryAllocatedWithCurrentScriptContext(); | 122 void registerMemoryAllocatedWithCurrentScriptContext(); |
119 | 123 |
120 // Returns true if the value contains a transferable ArrayBuffer. | 124 // Returns true if the value contains a transferable ArrayBuffer. |
121 bool containsTransferableArrayBuffer() const; | 125 bool containsTransferableArrayBuffer() const; |
122 | 126 |
123 String& data() { return m_data; } | 127 String& data() { return m_data; } |
124 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 128 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
125 ArrayBufferContentsArray* getArrayBufferContentsArray() { | 129 ArrayBufferContentsArray* getArrayBufferContentsArray() { |
(...skipping 26 matching lines...) Expand all Loading... |
152 String m_data; | 156 String m_data; |
153 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 157 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
154 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; | 158 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; |
155 BlobDataHandleMap m_blobDataHandles; | 159 BlobDataHandleMap m_blobDataHandles; |
156 intptr_t m_externallyAllocatedMemory; | 160 intptr_t m_externallyAllocatedMemory; |
157 }; | 161 }; |
158 | 162 |
159 } // namespace blink | 163 } // namespace blink |
160 | 164 |
161 #endif // SerializedScriptValue_h | 165 #endif // SerializedScriptValue_h |
OLD | NEW |