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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 const ImageBitmapArray&, | 129 const ImageBitmapArray&, |
130 ExceptionState&); | 130 ExceptionState&); |
131 | 131 |
132 // Informs V8 about external memory allocated and owned by this object. | 132 // Informs V8 about external memory allocated and owned by this object. |
133 // Large values should contribute to GC counters to eventually trigger a GC, | 133 // Large values should contribute to GC counters to eventually trigger a GC, |
134 // otherwise flood of postMessage() can cause OOM. | 134 // otherwise flood of postMessage() can cause OOM. |
135 // Ok to invoke multiple times (only adds memory once). | 135 // Ok to invoke multiple times (only adds memory once). |
136 // The memory registration is revoked automatically in destructor. | 136 // The memory registration is revoked automatically in destructor. |
137 void registerMemoryAllocatedWithCurrentScriptContext(); | 137 void registerMemoryAllocatedWithCurrentScriptContext(); |
138 | 138 |
139 // Upon passing a serialized value from one context to another (via a | 139 // The dual, unregistering / subtracting the external memory allocation costs |
140 // postMessage()), the allocation amounts it has registered with the | 140 // of this SerializedScriptValue with the current context. This includes |
141 // 'origining' context must be discharged, as the 'target' context will assume | 141 // discounting the cost of the transferables. |
142 // ownership of value. This method takes care of the first part of the | 142 // |
143 // external allocation bookkeeping, the above registration method the other | 143 // The value is updated and marked as having no allocations registered, |
144 // half. | 144 // hence subsequent calls will be no-ops. |
145 void unregisterMemoryAllocatedByCurrentScriptContext(); | 145 void unregisterMemoryAllocatedWithCurrentScriptContext(); |
146 | 146 |
147 const uint8_t* data() const { return m_dataBuffer.get(); } | 147 const uint8_t* data() const { return m_dataBuffer.get(); } |
148 size_t dataLengthInBytes() const { return m_dataBufferSize; } | 148 size_t dataLengthInBytes() const { return m_dataBufferSize; } |
149 | 149 |
150 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 150 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
151 ArrayBufferContentsArray* getArrayBufferContentsArray() { | 151 ArrayBufferContentsArray* getArrayBufferContentsArray() { |
152 return m_arrayBufferContentsArray.get(); | 152 return m_arrayBufferContentsArray.get(); |
153 } | 153 } |
154 ImageBitmapContentsArray* getImageBitmapContentsArray() { | 154 ImageBitmapContentsArray* getImageBitmapContentsArray() { |
155 return m_imageBitmapContentsArray.get(); | 155 return m_imageBitmapContentsArray.get(); |
(...skipping 25 matching lines...) Expand all Loading... |
181 void transferOffscreenCanvas(v8::Isolate*, | 181 void transferOffscreenCanvas(v8::Isolate*, |
182 const OffscreenCanvasArray&, | 182 const OffscreenCanvasArray&, |
183 ExceptionState&); | 183 ExceptionState&); |
184 | 184 |
185 DataBufferPtr m_dataBuffer; | 185 DataBufferPtr m_dataBuffer; |
186 size_t m_dataBufferSize = 0; | 186 size_t m_dataBufferSize = 0; |
187 | 187 |
188 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 188 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
189 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; | 189 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; |
190 BlobDataHandleMap m_blobDataHandles; | 190 BlobDataHandleMap m_blobDataHandles; |
191 size_t m_externallyAllocatedMemory; | 191 |
192 bool m_adjustTransferableExternalAllocationOnContextTransfer; | 192 bool m_hasRegisteredExternalAllocation; |
| 193 bool m_transferablesNeedExternalAllocationRegistration; |
193 }; | 194 }; |
194 | 195 |
195 template <> | 196 template <> |
196 struct NativeValueTraits<SerializedScriptValue> | 197 struct NativeValueTraits<SerializedScriptValue> |
197 : public NativeValueTraitsBase<SerializedScriptValue> { | 198 : public NativeValueTraitsBase<SerializedScriptValue> { |
198 CORE_EXPORT static inline PassRefPtr<SerializedScriptValue> nativeValue( | 199 CORE_EXPORT static inline PassRefPtr<SerializedScriptValue> nativeValue( |
199 v8::Isolate* isolate, | 200 v8::Isolate* isolate, |
200 v8::Local<v8::Value> value, | 201 v8::Local<v8::Value> value, |
201 ExceptionState& exceptionState) { | 202 ExceptionState& exceptionState) { |
202 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, | 203 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, |
203 exceptionState); | 204 exceptionState); |
204 } | 205 } |
205 }; | 206 }; |
206 | 207 |
207 } // namespace blink | 208 } // namespace blink |
208 | 209 |
209 #endif // SerializedScriptValue_h | 210 #endif // SerializedScriptValue_h |
OLD | NEW |