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