OLD | NEW |
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 ScriptValueSerializer_h | 5 #ifndef ScriptValueSerializer_h |
6 #define ScriptValueSerializer_h | 6 #define ScriptValueSerializer_h |
7 | 7 |
8 #include "bindings/core/v8/SerializationTag.h" | 8 #include "bindings/core/v8/SerializationTag.h" |
9 #include "bindings/core/v8/SerializedScriptValue.h" | 9 #include "bindings/core/v8/SerializedScriptValue.h" |
10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 STACK_ALLOCATED(); | 103 STACK_ALLOCATED(); |
104 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriter); | 104 WTF_MAKE_NONCOPYABLE(SerializedScriptValueWriter); |
105 public: | 105 public: |
106 typedef UChar BufferValueType; | 106 typedef UChar BufferValueType; |
107 | 107 |
108 SerializedScriptValueWriter() | 108 SerializedScriptValueWriter() |
109 : m_position(0) | 109 : m_position(0) |
110 { | 110 { |
111 } | 111 } |
112 | 112 |
| 113 // TODO(peria): Protect this mehtod. |
| 114 String takeWireString(); |
| 115 |
| 116 protected: |
| 117 friend class ScriptValueSerializer; |
| 118 |
113 // Write functions for primitive types. | 119 // Write functions for primitive types. |
114 | |
115 void writeUndefined(); | 120 void writeUndefined(); |
116 void writeNull(); | 121 void writeNull(); |
117 void writeTrue(); | 122 void writeTrue(); |
118 void writeFalse(); | 123 void writeFalse(); |
119 void writeBooleanObject(bool value); | 124 void writeBooleanObject(bool value); |
120 void writeOneByteString(v8::Local<v8::String>&); | 125 void writeOneByteString(v8::Local<v8::String>&); |
121 void writeUCharString(v8::Local<v8::String>&); | 126 void writeUCharString(v8::Local<v8::String>&); |
122 void writeStringObject(const char* data, int length); | 127 void writeStringObject(const char* data, int length); |
123 void writeWebCoreString(const String&); | 128 void writeWebCoreString(const String&); |
124 void writeVersion(); | 129 void writeVersion(); |
(...skipping 17 matching lines...) Expand all Loading... |
142 void writeRegExp(v8::Local<v8::String> pattern, v8::RegExp::Flags); | 147 void writeRegExp(v8::Local<v8::String> pattern, v8::RegExp::Flags); |
143 void writeTransferredMessagePort(uint32_t index); | 148 void writeTransferredMessagePort(uint32_t index); |
144 void writeTransferredArrayBuffer(uint32_t index); | 149 void writeTransferredArrayBuffer(uint32_t index); |
145 void writeTransferredImageBitmap(uint32_t index); | 150 void writeTransferredImageBitmap(uint32_t index); |
146 void writeTransferredOffscreenCanvas(uint32_t index, uint32_t width, uint32_
t height, uint32_t id); | 151 void writeTransferredOffscreenCanvas(uint32_t index, uint32_t width, uint32_
t height, uint32_t id); |
147 void writeTransferredSharedArrayBuffer(uint32_t index); | 152 void writeTransferredSharedArrayBuffer(uint32_t index); |
148 void writeObjectReference(uint32_t reference); | 153 void writeObjectReference(uint32_t reference); |
149 void writeObject(uint32_t numProperties); | 154 void writeObject(uint32_t numProperties); |
150 void writeSparseArray(uint32_t numProperties, uint32_t length); | 155 void writeSparseArray(uint32_t numProperties, uint32_t length); |
151 void writeDenseArray(uint32_t numProperties, uint32_t length); | 156 void writeDenseArray(uint32_t numProperties, uint32_t length); |
152 String takeWireString(); | |
153 void writeReferenceCount(uint32_t numberOfReferences); | 157 void writeReferenceCount(uint32_t numberOfReferences); |
154 void writeGenerateFreshObject(); | 158 void writeGenerateFreshObject(); |
155 void writeGenerateFreshSparseArray(uint32_t length); | 159 void writeGenerateFreshSparseArray(uint32_t length); |
156 void writeGenerateFreshDenseArray(uint32_t length); | 160 void writeGenerateFreshDenseArray(uint32_t length); |
157 void writeGenerateFreshMap(); | 161 void writeGenerateFreshMap(); |
158 void writeGenerateFreshSet(); | 162 void writeGenerateFreshSet(); |
159 void writeMap(uint32_t length); | 163 void writeMap(uint32_t length); |
160 void writeSet(uint32_t length); | 164 void writeSet(uint32_t length); |
161 | 165 |
162 protected: | |
163 void doWriteFile(const File&); | 166 void doWriteFile(const File&); |
164 void doWriteArrayBuffer(const DOMArrayBuffer&); | 167 void doWriteArrayBuffer(const DOMArrayBuffer&); |
165 void doWriteString(const char* data, int length); | 168 void doWriteString(const char* data, int length); |
166 void doWriteWebCoreString(const String&); | 169 void doWriteWebCoreString(const String&); |
167 int bytesNeededToWireEncode(uint32_t value); | 170 int bytesNeededToWireEncode(uint32_t value); |
168 | 171 |
169 template<class T> | 172 template<class T> |
170 void doWriteUintHelper(T value) | 173 void doWriteUintHelper(T value) |
171 { | 174 { |
172 while (true) { | 175 while (true) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 JSException | 212 JSException |
210 }; | 213 }; |
211 | 214 |
212 ScriptValueSerializer(SerializedScriptValueWriter&, const Transferables*, We
bBlobInfoArray*, BlobDataHandleMap& blobDataHandles, v8::TryCatch&, ScriptState*
); | 215 ScriptValueSerializer(SerializedScriptValueWriter&, const Transferables*, We
bBlobInfoArray*, BlobDataHandleMap& blobDataHandles, v8::TryCatch&, ScriptState*
); |
213 v8::Isolate* isolate() { return m_scriptState->isolate(); } | 216 v8::Isolate* isolate() { return m_scriptState->isolate(); } |
214 v8::Local<v8::Context> context() { return m_scriptState->context(); } | 217 v8::Local<v8::Context> context() { return m_scriptState->context(); } |
215 | 218 |
216 Status serialize(v8::Local<v8::Value>); | 219 Status serialize(v8::Local<v8::Value>); |
217 String errorMessage() { return m_errorMessage; } | 220 String errorMessage() { return m_errorMessage; } |
218 | 221 |
| 222 static String serializeWTFString(const String&); |
| 223 static String serializeNullValue(); |
| 224 |
219 protected: | 225 protected: |
220 class StateBase { | 226 class StateBase { |
221 USING_FAST_MALLOC(StateBase); | 227 USING_FAST_MALLOC(StateBase); |
222 WTF_MAKE_NONCOPYABLE(StateBase); | 228 WTF_MAKE_NONCOPYABLE(StateBase); |
223 public: | 229 public: |
224 virtual ~StateBase() { } | 230 virtual ~StateBase() { } |
225 | 231 |
226 // Link to the next state to form a stack. | 232 // Link to the next state to form a stack. |
227 StateBase* nextState() { return m_next; } | 233 StateBase* nextState() { return m_next; } |
228 | 234 |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 ArrayBufferContentsArray* m_arrayBufferContents; | 623 ArrayBufferContentsArray* m_arrayBufferContents; |
618 ImageBitmapContentsArray* m_imageBitmapContents; | 624 ImageBitmapContentsArray* m_imageBitmapContents; |
619 Vector<v8::Local<v8::Value>> m_arrayBuffers; | 625 Vector<v8::Local<v8::Value>> m_arrayBuffers; |
620 Vector<v8::Local<v8::Value>> m_imageBitmaps; | 626 Vector<v8::Local<v8::Value>> m_imageBitmaps; |
621 uint32_t m_version; | 627 uint32_t m_version; |
622 }; | 628 }; |
623 | 629 |
624 } // namespace blink | 630 } // namespace blink |
625 | 631 |
626 #endif // ScriptValueSerializer_h | 632 #endif // ScriptValueSerializer_h |
OLD | NEW |