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 ArrayBuffer; | 42 class ArrayBuffer; |
43 class ArrayBufferContents; | 43 class ArrayBufferContents; |
44 | 44 |
45 } | 45 } |
46 | 46 |
47 namespace WebCore { | 47 namespace WebCore { |
48 | 48 |
49 class BlobDataHandle; | 49 class BlobDataHandle; |
| 50 class ExceptionState; |
50 class MessagePort; | 51 class MessagePort; |
51 | 52 |
52 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; | 53 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; |
53 typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; | 54 typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; |
54 typedef HashMap<String, RefPtr<BlobDataHandle> > BlobDataHandleMap; | 55 typedef HashMap<String, RefPtr<BlobDataHandle> > BlobDataHandleMap; |
55 | 56 |
56 class SerializedScriptValue FINAL : public ThreadSafeRefCounted<SerializedScript
Value> { | 57 class SerializedScriptValue FINAL : public ThreadSafeRefCounted<SerializedScript
Value> { |
57 public: | 58 public: |
58 // Increment this for each incompatible change to the wire format. | 59 // Increment this for each incompatible change to the wire format. |
59 // Version 2: Added StringUCharTag for UChar v8 strings. | 60 // Version 2: Added StringUCharTag for UChar v8 strings. |
60 // Version 3: Switched to using uuids as blob data identifiers. | 61 // Version 3: Switched to using uuids as blob data identifiers. |
61 static const uint32_t wireFormatVersion = 3; | 62 static const uint32_t wireFormatVersion = 3; |
62 | 63 |
63 ~SerializedScriptValue(); | 64 ~SerializedScriptValue(); |
64 | 65 |
65 // If a serialization error occurs (e.g., cyclic input value) this | 66 // If a serialization error occurs (e.g., cyclic input value) this |
66 // function returns an empty representation, schedules a V8 exception to | 67 // function returns an empty representation, schedules a V8 exception to |
67 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case | 68 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case |
68 // the caller must not invoke any V8 operations until control returns to | 69 // the caller must not invoke any V8 operations until control returns to |
69 // V8. When serialization is successful, |didThrow| is false. | 70 // V8. When serialization is successful, |didThrow| is false. |
| 71 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, ExceptionState&, v8::Isolate*); |
70 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); | 72 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); |
71 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); | 73 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); |
72 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); | 74 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); |
73 static PassRefPtr<SerializedScriptValue> create(const String&); | 75 static PassRefPtr<SerializedScriptValue> create(const String&); |
74 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; | 76 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; |
75 static PassRefPtr<SerializedScriptValue> create(); | 77 static PassRefPtr<SerializedScriptValue> create(); |
76 | 78 |
77 static PassRefPtr<SerializedScriptValue> create(const ScriptValue&, bool& di
dThrow, ScriptState*); | 79 static PassRefPtr<SerializedScriptValue> create(const ScriptValue&, bool& di
dThrow, ScriptState*); |
78 | 80 |
79 // Never throws exceptions. | 81 // Never throws exceptions. |
(...skipping 25 matching lines...) Expand all Loading... |
105 StringValue, | 107 StringValue, |
106 WireData | 108 WireData |
107 }; | 109 }; |
108 enum ExceptionPolicy { | 110 enum ExceptionPolicy { |
109 ThrowExceptions, | 111 ThrowExceptions, |
110 DoNotThrowExceptions | 112 DoNotThrowExceptions |
111 }; | 113 }; |
112 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; | 114 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; |
113 | 115 |
114 SerializedScriptValue(); | 116 SerializedScriptValue(); |
115 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferA
rray*, bool& didThrow, v8::Isolate*, ExceptionPolicy = ThrowExceptions); | 117 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferA
rray*, bool&, ExceptionState*, v8::Isolate*, ExceptionPolicy = ThrowExceptions); |
116 explicit SerializedScriptValue(const String& wireData); | 118 explicit SerializedScriptValue(const String& wireData); |
117 | 119 |
118 static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBuffer
Array&, bool& didThrow, v8::Isolate*); | 120 static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBuffer
Array&, bool& didThrow, ExceptionState*, v8::Isolate*); |
119 | 121 |
120 String m_data; | 122 String m_data; |
121 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 123 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
122 BlobDataHandleMap m_blobDataHandles; | 124 BlobDataHandleMap m_blobDataHandles; |
123 intptr_t m_externallyAllocatedMemory; | 125 intptr_t m_externallyAllocatedMemory; |
124 }; | 126 }; |
125 | 127 |
126 } // namespace WebCore | 128 } // namespace WebCore |
127 | 129 |
128 #endif // SerializedScriptValue_h | 130 #endif // SerializedScriptValue_h |
OLD | NEW |