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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 class MessagePort; | 48 class MessagePort; |
49 | 49 |
50 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; | 50 typedef Vector<RefPtr<MessagePort>, 1> MessagePortArray; |
51 typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; | 51 typedef Vector<RefPtr<WTF::ArrayBuffer>, 1> ArrayBufferArray; |
52 | 52 |
53 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ | 53 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ |
54 public: | 54 public: |
| 55 // Increment this for each incompatible change to the wire format. |
| 56 // Version 2: Added StringUCharTag for UChar v8 strings. |
| 57 static const uint32_t wireFormatVersion = 2; |
| 58 |
55 virtual ~SerializedScriptValue(); | 59 virtual ~SerializedScriptValue(); |
56 | 60 |
57 // If a serialization error occurs (e.g., cyclic input value) this | 61 // If a serialization error occurs (e.g., cyclic input value) this |
58 // function returns an empty representation, schedules a V8 exception to | 62 // function returns an empty representation, schedules a V8 exception to |
59 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case | 63 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case |
60 // the caller must not invoke any V8 operations until control returns to | 64 // the caller must not invoke any V8 operations until control returns to |
61 // V8. When serialization is successful, |didThrow| is false. | 65 // V8. When serialization is successful, |didThrow| is false. |
62 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); | 66 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); |
63 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::I
solate*); | 67 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::I
solate*); |
64 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); | 68 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); |
65 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); | 69 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); |
66 static PassRefPtr<SerializedScriptValue> create(const String&); | 70 static PassRefPtr<SerializedScriptValue> create(const String&); |
67 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; | 71 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; |
68 static PassRefPtr<SerializedScriptValue> create(); | 72 static PassRefPtr<SerializedScriptValue> create(); |
69 | 73 |
70 // Never throws exceptions. | 74 // Never throws exceptions. |
71 static PassRefPtr<SerializedScriptValue> createAndSwallowExceptions(v8::Hand
le<v8::Value>, v8::Isolate*); | 75 static PassRefPtr<SerializedScriptValue> createAndSwallowExceptions(v8::Hand
le<v8::Value>, v8::Isolate*); |
72 | 76 |
73 static PassRefPtr<SerializedScriptValue> nullValue(); | 77 static PassRefPtr<SerializedScriptValue> nullValue(); |
74 static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate*); | 78 static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate*); |
75 static PassRefPtr<SerializedScriptValue> undefinedValue(); | 79 static PassRefPtr<SerializedScriptValue> undefinedValue(); |
76 static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate*); | 80 static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate*); |
77 static PassRefPtr<SerializedScriptValue> booleanValue(bool); | 81 static PassRefPtr<SerializedScriptValue> booleanValue(bool); |
78 static PassRefPtr<SerializedScriptValue> booleanValue(bool, v8::Isolate*); | 82 static PassRefPtr<SerializedScriptValue> booleanValue(bool, v8::Isolate*); |
79 static PassRefPtr<SerializedScriptValue> numberValue(double); | 83 static PassRefPtr<SerializedScriptValue> numberValue(double); |
80 static PassRefPtr<SerializedScriptValue> numberValue(double, v8::Isolate*); | 84 static PassRefPtr<SerializedScriptValue> numberValue(double, v8::Isolate*); |
81 | 85 |
82 static uint32_t wireFormatVersion(); | |
83 | |
84 PassRefPtr<SerializedScriptValue> release(); | 86 PassRefPtr<SerializedScriptValue> release(); |
85 | 87 |
86 String toWireString() const { return m_data; } | 88 String toWireString() const { return m_data; } |
87 void toWireBytes(Vector<char>&) const; | 89 void toWireBytes(Vector<char>&) const; |
88 | 90 |
89 // Deserializes the value (in the current context). Returns a null value in | 91 // Deserializes the value (in the current context). Returns a null value in |
90 // case of failure. | 92 // case of failure. |
91 v8::Handle<v8::Value> deserialize(MessagePortArray* = 0); | 93 v8::Handle<v8::Value> deserialize(MessagePortArray* = 0); |
92 v8::Handle<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0); | 94 v8::Handle<v8::Value> deserialize(v8::Isolate*, MessagePortArray* = 0); |
93 | 95 |
(...skipping 26 matching lines...) Expand all Loading... |
120 | 122 |
121 String m_data; | 123 String m_data; |
122 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 124 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
123 Vector<String> m_blobURLs; | 125 Vector<String> m_blobURLs; |
124 intptr_t m_externallyAllocatedMemory; | 126 intptr_t m_externallyAllocatedMemory; |
125 }; | 127 }; |
126 | 128 |
127 } // namespace WebCore | 129 } // namespace WebCore |
128 | 130 |
129 #endif // SerializedScriptValue_h | 131 #endif // SerializedScriptValue_h |
OLD | NEW |