| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBufferContents( | 122 static std::unique_ptr<ArrayBufferContentsArray> transferArrayBufferContents( |
| 123 v8::Isolate*, | 123 v8::Isolate*, |
| 124 const ArrayBufferArray&, | 124 const ArrayBufferArray&, |
| 125 ExceptionState&); | 125 ExceptionState&); |
| 126 | 126 |
| 127 static std::unique_ptr<ImageBitmapContentsArray> transferImageBitmapContents( | 127 static std::unique_ptr<ImageBitmapContentsArray> transferImageBitmapContents( |
| 128 v8::Isolate*, | 128 v8::Isolate*, |
| 129 const ImageBitmapArray&, | 129 const ImageBitmapArray&, |
| 130 ExceptionState&); | 130 ExceptionState&); |
| 131 | 131 |
| 132 // Informs the 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 |
| 140 // postMessage()), the allocation amounts it has registered with the |
| 141 // 'origining' context must be discharged, as the 'target' context will assume |
| 142 // ownership of value. This method takes care of the first part of the |
| 143 // external allocation bookkeeping, the above registration method the other |
| 144 // half. |
| 145 void unregisterMemoryAllocatedByCurrentScriptContext(); |
| 146 |
| 139 const uint8_t* data() const { return m_dataBuffer.get(); } | 147 const uint8_t* data() const { return m_dataBuffer.get(); } |
| 140 size_t dataLengthInBytes() const { return m_dataBufferSize; } | 148 size_t dataLengthInBytes() const { return m_dataBufferSize; } |
| 141 | 149 |
| 142 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } | 150 BlobDataHandleMap& blobDataHandles() { return m_blobDataHandles; } |
| 143 ArrayBufferContentsArray* getArrayBufferContentsArray() { | 151 ArrayBufferContentsArray* getArrayBufferContentsArray() { |
| 144 return m_arrayBufferContentsArray.get(); | 152 return m_arrayBufferContentsArray.get(); |
| 145 } | 153 } |
| 146 ImageBitmapContentsArray* getImageBitmapContentsArray() { | 154 ImageBitmapContentsArray* getImageBitmapContentsArray() { |
| 147 return m_imageBitmapContentsArray.get(); | 155 return m_imageBitmapContentsArray.get(); |
| 148 } | 156 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 void transferOffscreenCanvas(v8::Isolate*, | 181 void transferOffscreenCanvas(v8::Isolate*, |
| 174 const OffscreenCanvasArray&, | 182 const OffscreenCanvasArray&, |
| 175 ExceptionState&); | 183 ExceptionState&); |
| 176 | 184 |
| 177 DataBufferPtr m_dataBuffer; | 185 DataBufferPtr m_dataBuffer; |
| 178 size_t m_dataBufferSize = 0; | 186 size_t m_dataBufferSize = 0; |
| 179 | 187 |
| 180 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; | 188 std::unique_ptr<ArrayBufferContentsArray> m_arrayBufferContentsArray; |
| 181 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; | 189 std::unique_ptr<ImageBitmapContentsArray> m_imageBitmapContentsArray; |
| 182 BlobDataHandleMap m_blobDataHandles; | 190 BlobDataHandleMap m_blobDataHandles; |
| 183 intptr_t m_externallyAllocatedMemory; | 191 size_t m_externallyAllocatedMemory; |
| 192 bool m_adjustTransferableExternalAllocationOnContextTransfer; |
| 184 }; | 193 }; |
| 185 | 194 |
| 186 template <> | 195 template <> |
| 187 struct NativeValueTraits<SerializedScriptValue> | 196 struct NativeValueTraits<SerializedScriptValue> |
| 188 : public NativeValueTraitsBase<SerializedScriptValue> { | 197 : public NativeValueTraitsBase<SerializedScriptValue> { |
| 189 CORE_EXPORT static inline PassRefPtr<SerializedScriptValue> nativeValue( | 198 CORE_EXPORT static inline PassRefPtr<SerializedScriptValue> nativeValue( |
| 190 v8::Isolate* isolate, | 199 v8::Isolate* isolate, |
| 191 v8::Local<v8::Value> value, | 200 v8::Local<v8::Value> value, |
| 192 ExceptionState& exceptionState) { | 201 ExceptionState& exceptionState) { |
| 193 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, | 202 return SerializedScriptValue::serialize(isolate, value, nullptr, nullptr, |
| 194 exceptionState); | 203 exceptionState); |
| 195 } | 204 } |
| 196 }; | 205 }; |
| 197 | 206 |
| 198 } // namespace blink | 207 } // namespace blink |
| 199 | 208 |
| 200 #endif // SerializedScriptValue_h | 209 #endif // SerializedScriptValue_h |
| OLD | NEW |