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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ | 52 class SerializedScriptValue : public ThreadSafeRefCounted<SerializedScriptValue>
{ |
53 public: | 53 public: |
54 virtual ~SerializedScriptValue(); | 54 virtual ~SerializedScriptValue(); |
55 | 55 |
56 // If a serialization error occurs (e.g., cyclic input value) this | 56 // If a serialization error occurs (e.g., cyclic input value) this |
57 // function returns an empty representation, schedules a V8 exception to | 57 // function returns an empty representation, schedules a V8 exception to |
58 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case | 58 // be thrown using v8::ThrowException(), and sets |didThrow|. In this case |
59 // the caller must not invoke any V8 operations until control returns to | 59 // the caller must not invoke any V8 operations until control returns to |
60 // V8. When serialization is successful, |didThrow| is false. | 60 // V8. When serialization is successful, |didThrow| is false. |
61 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool&); | 61 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool& didThrow, v8::Isolate*); |
62 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, Messa
gePortArray*, ArrayBufferArray*, bool&, v8::Isolate*); | |
63 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>); | |
64 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::I
solate*); | 62 static PassRefPtr<SerializedScriptValue> create(v8::Handle<v8::Value>, v8::I
solate*); |
65 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); | 63 static PassRefPtr<SerializedScriptValue> createFromWire(const String&); |
66 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); | 64 static PassRefPtr<SerializedScriptValue> createFromWireBytes(const Vector<ui
nt8_t>&); |
67 static PassRefPtr<SerializedScriptValue> create(const String&); | 65 static PassRefPtr<SerializedScriptValue> create(const String&); |
68 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; | 66 static PassRefPtr<SerializedScriptValue> create(const String&, v8::Isolate*)
; |
69 static PassRefPtr<SerializedScriptValue> create(); | 67 static PassRefPtr<SerializedScriptValue> create(); |
70 | 68 |
| 69 // Never throws exceptions. |
| 70 static PassRefPtr<SerializedScriptValue> createAndSwallowExceptions(v8::Hand
le<v8::Value>, v8::Isolate*); |
| 71 |
71 static PassRefPtr<SerializedScriptValue> nullValue(); | 72 static PassRefPtr<SerializedScriptValue> nullValue(); |
72 static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate*); | 73 static PassRefPtr<SerializedScriptValue> nullValue(v8::Isolate*); |
73 static PassRefPtr<SerializedScriptValue> undefinedValue(); | 74 static PassRefPtr<SerializedScriptValue> undefinedValue(); |
74 static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate*); | 75 static PassRefPtr<SerializedScriptValue> undefinedValue(v8::Isolate*); |
75 static PassRefPtr<SerializedScriptValue> booleanValue(bool); | 76 static PassRefPtr<SerializedScriptValue> booleanValue(bool); |
76 static PassRefPtr<SerializedScriptValue> booleanValue(bool, v8::Isolate*); | 77 static PassRefPtr<SerializedScriptValue> booleanValue(bool, v8::Isolate*); |
77 static PassRefPtr<SerializedScriptValue> numberValue(double); | 78 static PassRefPtr<SerializedScriptValue> numberValue(double); |
78 static PassRefPtr<SerializedScriptValue> numberValue(double, v8::Isolate*); | 79 static PassRefPtr<SerializedScriptValue> numberValue(double, v8::Isolate*); |
79 | 80 |
80 static uint32_t wireFormatVersion(); | 81 static uint32_t wireFormatVersion(); |
(...skipping 16 matching lines...) Expand all Loading... |
97 // 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. |
98 // Ok to invoke multiple times (only adds memory once). | 99 // Ok to invoke multiple times (only adds memory once). |
99 // The memory registration is revoked automatically in destructor. | 100 // The memory registration is revoked automatically in destructor. |
100 void registerMemoryAllocatedWithCurrentScriptContext(); | 101 void registerMemoryAllocatedWithCurrentScriptContext(); |
101 | 102 |
102 private: | 103 private: |
103 enum StringDataMode { | 104 enum StringDataMode { |
104 StringValue, | 105 StringValue, |
105 WireData | 106 WireData |
106 }; | 107 }; |
| 108 enum ExceptionPolicy { |
| 109 ThrowExceptions, |
| 110 DoNotThrowExceptions |
| 111 }; |
107 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; | 112 typedef Vector<WTF::ArrayBufferContents, 1> ArrayBufferContentsArray; |
108 | 113 |
109 SerializedScriptValue(); | 114 SerializedScriptValue(); |
110 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferA
rray*, bool& didThrow, v8::Isolate*); | 115 SerializedScriptValue(v8::Handle<v8::Value>, MessagePortArray*, ArrayBufferA
rray*, bool& didThrow, v8::Isolate*, ExceptionPolicy = ThrowExceptions); |
111 explicit SerializedScriptValue(const String& wireData); | 116 explicit SerializedScriptValue(const String& wireData); |
112 | 117 |
113 static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBuffer
Array&, bool& didThrow, v8::Isolate*); | 118 static PassOwnPtr<ArrayBufferContentsArray> transferArrayBuffers(ArrayBuffer
Array&, bool& didThrow, v8::Isolate*); |
114 | 119 |
115 String m_data; | 120 String m_data; |
116 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 121 OwnPtr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
117 Vector<String> m_blobURLs; | 122 Vector<String> m_blobURLs; |
118 intptr_t m_externallyAllocatedMemory; | 123 intptr_t m_externallyAllocatedMemory; |
119 }; | 124 }; |
120 | 125 |
121 } // namespace WebCore | 126 } // namespace WebCore |
122 | 127 |
123 #endif // SerializedScriptValue_h | 128 #endif // SerializedScriptValue_h |
OLD | NEW |