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 29 matching lines...) Expand all Loading... |
40 namespace WTF { | 40 namespace WTF { |
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 DOMArrayBuffer; | 49 class DOMArrayBuffer; |
| 50 class DOMSharedArrayBuffer; |
50 class ExceptionState; | 51 class ExceptionState; |
51 class MessagePort; | 52 class MessagePort; |
52 class WebBlobInfo; | 53 class WebBlobInfo; |
53 | 54 |
54 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; | 55 typedef WillBeHeapVector<RefPtrWillBeMember<MessagePort>, 1> MessagePortArray; |
55 typedef Vector<RefPtr<DOMArrayBuffer>, 1> ArrayBufferArray; | 56 typedef Vector<RefPtr<DOMArrayBuffer>, 1> ArrayBufferArray; |
| 57 typedef Vector<RefPtr<DOMSharedArrayBuffer>, 1> SharedArrayBufferArray; |
56 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap; | 58 typedef HashMap<String, RefPtr<BlobDataHandle>> BlobDataHandleMap; |
57 typedef Vector<WebBlobInfo> WebBlobInfoArray; | 59 typedef Vector<WebBlobInfo> WebBlobInfoArray; |
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. |
(...skipping 15 matching lines...) Expand all Loading... |
81 | 83 |
82 // Deserializes the value (in the current context). Returns a null value in | 84 // Deserializes the value (in the current context). Returns a null value in |
83 // case of failure. | 85 // case of failure. |
84 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); | 86 v8::Local<v8::Value> deserialize(MessagePortArray* = 0); |
85 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const
WebBlobInfoArray* = 0); | 87 v8::Local<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0, const
WebBlobInfoArray* = 0); |
86 | 88 |
87 // Helper function which pulls the values out of a JS sequence and into a Me
ssagePortArray. | 89 // Helper function which pulls the values out of a JS sequence and into a Me
ssagePortArray. |
88 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL
spec and section 8.3.3 | 90 // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL
spec and section 8.3.3 |
89 // of the HTML5 spec and generates exceptions as appropriate. | 91 // of the HTML5 spec and generates exceptions as appropriate. |
90 // Returns true if the array was filled, or false if the passed value was no
t of an appropriate type. | 92 // Returns true if the array was filled, or false if the passed value was no
t of an appropriate type. |
91 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me
ssagePortArray&, ArrayBufferArray&, ExceptionState&); | 93 static bool extractTransferables(v8::Isolate*, v8::Local<v8::Value>, int, Me
ssagePortArray&, ArrayBufferArray&, SharedArrayBufferArray&, ExceptionState&); |
92 | 94 |
93 // Informs the V8 about external memory allocated and owned by this object.
Large values should contribute | 95 // Informs the V8 about external memory allocated and owned by this object.
Large values should contribute |
94 // to GC counters to eventually trigger a GC, otherwise flood of postMessage
() can cause OOM. | 96 // to GC counters to eventually trigger a GC, otherwise flood of postMessage
() can cause OOM. |
95 // Ok to invoke multiple times (only adds memory once). | 97 // Ok to invoke multiple times (only adds memory once). |
96 // The memory registration is revoked automatically in destructor. | 98 // The memory registration is revoked automatically in destructor. |
97 void registerMemoryAllocatedWithCurrentScriptContext(); | 99 void registerMemoryAllocatedWithCurrentScriptContext(); |
98 | 100 |
99 private: | 101 private: |
100 // The followings are private, but used by SerializedScriptValueFactory. | 102 // The followings are private, but used by SerializedScriptValueFactory. |
101 enum StringDataMode { | 103 enum StringDataMode { |
102 StringValue, | 104 StringValue, |
103 WireData | 105 WireData |
104 }; | 106 }; |
105 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; | 107 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; |
106 | 108 |
107 SerializedScriptValue(); | 109 SerializedScriptValue(); |
108 explicit SerializedScriptValue(const String& wireData); | 110 explicit SerializedScriptValue(const String& wireData); |
109 | 111 |
110 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 112 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
111 String& data() { return m_data; } | 113 String& data() { return m_data; } |
112 void setData(const String& data) { m_data = data; } | 114 void setData(const String& data) { m_data = data; } |
113 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, ExceptionState&); | 115 void transferArrayBuffers(v8::Isolate*, ArrayBufferArray&, SharedArrayBuffer
Array&, ExceptionState&); |
114 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC
ontentsArray.get(); } | 116 ArrayBufferContentsArray* arrayBufferContentsArray() { return m_arrayBufferC
ontentsArray.get(); } |
115 | 117 |
116 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*,
ArrayBufferArray&, ExceptionState&); | 118 static PassOwnPtr<ArrayBufferContentsArray> createArrayBuffers(v8::Isolate*,
ArrayBufferArray&, SharedArrayBufferArray&, ExceptionState&); |
117 | 119 |
118 private: | 120 private: |
119 String m_data; | 121 String m_data; |
120 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 122 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
121 BlobDataHandleMap m_blobDataHandles; | 123 BlobDataHandleMap m_blobDataHandles; |
122 intptr_t m_externallyAllocatedMemory; | 124 intptr_t m_externallyAllocatedMemory; |
123 | 125 |
124 friend class SerializedScriptValueFactory; | 126 friend class SerializedScriptValueFactory; |
125 }; | 127 }; |
126 | 128 |
127 } // namespace blink | 129 } // namespace blink |
128 | 130 |
129 #endif // SerializedScriptValue_h | 131 #endif // SerializedScriptValue_h |
OLD | NEW |