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 30 matching lines...) Expand all Loading... | |
41 | 41 |
42 class ArrayBufferContents; | 42 class ArrayBufferContents; |
43 | 43 |
44 } | 44 } |
45 | 45 |
46 namespace blink { | 46 namespace blink { |
47 | 47 |
48 class BlobDataHandle; | 48 class BlobDataHandle; |
49 class DOMArrayBufferBase; | 49 class DOMArrayBufferBase; |
50 class ExceptionState; | 50 class ExceptionState; |
51 class ImageBitmap; | |
51 class MessagePort; | 52 class MessagePort; |
52 class WebBlobInfo; | 53 class WebBlobInfo; |
53 | 54 |
54 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray; | 55 typedef HeapVector<Member<MessagePort>, 1> MessagePortArray; |
55 typedef Vector<RefPtr<DOMArrayBufferBase>, 1> ArrayBufferArray; | 56 typedef Vector<RefPtr<DOMArrayBufferBase>, 1> ArrayBufferArray; |
56 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap; | 57 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap; |
57 typedef Vector<WebBlobInfo> WebBlobInfoArray; | 58 typedef Vector<WebBlobInfo> WebBlobInfoArray; |
59 typedef WillBeHeapVector<RefPtrWillBeMember<ImageBitmap>, 1> ImageBitmapArray; | |
58 | 60 |
59 class CORE_EXPORT SerializedScriptValue : public ThreadSafeRefCounted<Serialized ScriptValue> { | 61 class CORE_EXPORT SerializedScriptValue : public ThreadSafeRefCounted<Serialized ScriptValue> { |
60 public: | 62 public: |
61 // Increment this for each incompatible change to the wire format. | 63 // Increment this for each incompatible change to the wire format. |
62 // Version 2: Added StringUCharTag for UChar v8 strings. | 64 // Version 2: Added StringUCharTag for UChar v8 strings. |
63 // Version 3: Switched to using uuids as blob data identifiers. | 65 // Version 3: Switched to using uuids as blob data identifiers. |
64 // Version 4: Extended File serialization to be complete. | 66 // Version 4: Extended File serialization to be complete. |
65 // Version 5: Added CryptoKeyTag for Key objects. | 67 // Version 5: Added CryptoKeyTag for Key objects. |
66 // Version 6: Added indexed serialization for File, Blob, and FileList. | 68 // Version 6: Added indexed serialization for File, Blob, and FileList. |
67 // Version 7: Extended File serialization with user visibility. | 69 // Version 7: Extended File serialization with user visibility. |
(...skipping 14 matching lines...) Expand all Loading... | |
82 | 84 |
83 // Deserializes the value (in the current context). Returns a null value in | 85 // Deserializes the value (in the current context). Returns a null value in |
84 // case of failure. | 86 // case of failure. |
85 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); | 87 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); |
86 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const WebBlobInfoArray* = 0); | 88 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const WebBlobInfoArray* = 0); |
87 | 89 |
88 // Helper function which pulls the values out of a JS sequence and into a Me ssagePortArray. | 90 // Helper function which pulls the values out of a JS sequence and into a Me ssagePortArray. |
89 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 | 91 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 |
90 // of the HTML5 spec and generates exceptions as appropriate. | 92 // of the HTML5 spec and generates exceptions as appropriate. |
91 // Returns true if the array was filled, or false if the passed value was no t of an appropriate type. | 93 // Returns true if the array was filled, or false if the passed value was no t of an appropriate type. |
92 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me ssagePortArray&, ArrayBufferArray&, ExceptionState&); | 94 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me ssagePortArray&, ArrayBufferArray&, ImageBitmapArray&, ExceptionState&); |
93 | 95 |
94 // Informs the V8 about external memory allocated and owned by this object. Large values should contribute | 96 // Informs the V8 about external memory allocated and owned by this object. Large values should contribute |
95 // to GC counters to eventually trigger a GC, otherwise flood of postMessage () can cause OOM. | 97 // to GC counters to eventually trigger a GC, otherwise flood of postMessage () can cause OOM. |
96 // Ok to invoke multiple times (only adds memory once). | 98 // Ok to invoke multiple times (only adds memory once). |
97 // The memory registration is revoked automatically in destructor. | 99 // The memory registration is revoked automatically in destructor. |
98 void registerMemoryAllocatedWithCurrentScriptContext(); | 100 void registerMemoryAllocatedWithCurrentScriptContext(); |
99 | 101 |
100 // Returns true if the value contains a transferable ArrayBuffer. | 102 // Returns true if the value contains a transferable ArrayBuffer. |
101 bool containsTransferableArrayBuffer() const; | 103 bool containsTransferableArrayBuffer() const; |
102 | 104 |
103 private: | 105 private: |
104 // The followings are private, but used by SerializedScriptValueFactory. | 106 // The followings are private, but used by SerializedScriptValueFactory. |
105 enum StringDataMode { | 107 enum StringDataMode { |
106 StringValue, | 108 StringValue, |
107 WireData | 109 WireData |
108 }; | 110 }; |
109 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; | 111 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; |
110 | 112 |
111 SerializedScriptValue(); | 113 SerializedScriptValue(); |
112 explicit SerializedScriptValue(const String& wireData); | 114 explicit SerializedScriptValue(const String& wireData); |
113 | 115 |
114 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 116 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
115 String& data() { return m_data; } | 117 String& data() { return m_data; } |
116 void setData(const String& data) { m_data = data; } | 118 void setData(const String& data) { m_data = data; } |
117 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); | 119 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); |
120 void transferImageBitmaps(v8::Isolate*, ImageBitmapArray&, ExceptionState&); | |
118 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC ontentsArray.get(); } | 121 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC ontentsArray.get(); } |
122 ImageBitmapArray* imageBitmapArray() { return m_imageBitmapsArray.get(); } | |
119 | 123 |
120 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); | 124 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); |
125 static PassOwnPtr<ImageBitmapArray> createImageBitmaps(v8::Isolate*, ImageBi tmapArray&, ExceptionState&); | |
121 | 126 |
122 private: | 127 private: |
123 String m_data; | 128 String m_data; |
124 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 129 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
130 OwnPtr<ImageBitmapArray> m_imageBitmapsArray; | |
Justin Novosad
2015/10/23 19:39:57
Because SerializedScriptValue is ref counted (As o
| |
125 BlobDataHandleMap m_blobDataHandles; | 131 BlobDataHandleMap m_blobDataHandles; |
126 intptr_t m_externallyAllocatedMemory; | 132 intptr_t m_externallyAllocatedMemory; |
127 | 133 |
128 friend class SerializedScriptValueFactory; | 134 friend class SerializedScriptValueFactory; |
129 }; | 135 }; |
130 | 136 |
131 } // namespace blink | 137 } // namespace blink |
132 | 138 |
133 #endif // SerializedScriptValue_h | 139 #endif // SerializedScriptValue_h |
OLD | NEW |