| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 return nullptr; | 224 return nullptr; |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 std::unique_ptr<ImageBitmapContentsArray> contents = | 228 std::unique_ptr<ImageBitmapContentsArray> contents = |
| 229 WTF::wrapUnique(new ImageBitmapContentsArray); | 229 WTF::wrapUnique(new ImageBitmapContentsArray); |
| 230 HeapHashSet<Member<ImageBitmap>> visited; | 230 HeapHashSet<Member<ImageBitmap>> visited; |
| 231 for (size_t i = 0; i < imageBitmaps.size(); ++i) { | 231 for (size_t i = 0; i < imageBitmaps.size(); ++i) { |
| 232 if (visited.contains(imageBitmaps[i])) | 232 if (visited.contains(imageBitmaps[i])) |
| 233 continue; | 233 continue; |
| 234 visited.add(imageBitmaps[i]); | 234 visited.insert(imageBitmaps[i]); |
| 235 contents->push_back(imageBitmaps[i]->transfer()); | 235 contents->push_back(imageBitmaps[i]->transfer()); |
| 236 } | 236 } |
| 237 return contents; | 237 return contents; |
| 238 } | 238 } |
| 239 | 239 |
| 240 void SerializedScriptValue::transferImageBitmaps( | 240 void SerializedScriptValue::transferImageBitmaps( |
| 241 v8::Isolate* isolate, | 241 v8::Isolate* isolate, |
| 242 const ImageBitmapArray& imageBitmaps, | 242 const ImageBitmapArray& imageBitmaps, |
| 243 ExceptionState& exceptionState) { | 243 ExceptionState& exceptionState) { |
| 244 std::unique_ptr<ImageBitmapContentsArray> contents = | 244 std::unique_ptr<ImageBitmapContentsArray> contents = |
| (...skipping 17 matching lines...) Expand all Loading... |
| 262 DataCloneError, "OffscreenCanvas at index " + String::number(i) + | 262 DataCloneError, "OffscreenCanvas at index " + String::number(i) + |
| 263 " is already detached."); | 263 " is already detached."); |
| 264 return; | 264 return; |
| 265 } | 265 } |
| 266 if (offscreenCanvases[i]->renderingContext()) { | 266 if (offscreenCanvases[i]->renderingContext()) { |
| 267 exceptionState.throwDOMException( | 267 exceptionState.throwDOMException( |
| 268 DataCloneError, "OffscreenCanvas at index " + String::number(i) + | 268 DataCloneError, "OffscreenCanvas at index " + String::number(i) + |
| 269 " has an associated context."); | 269 " has an associated context."); |
| 270 return; | 270 return; |
| 271 } | 271 } |
| 272 visited.add(offscreenCanvases[i].get()); | 272 visited.insert(offscreenCanvases[i].get()); |
| 273 offscreenCanvases[i].get()->setNeutered(); | 273 offscreenCanvases[i].get()->setNeutered(); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 void SerializedScriptValue::transferArrayBuffers( | 277 void SerializedScriptValue::transferArrayBuffers( |
| 278 v8::Isolate* isolate, | 278 v8::Isolate* isolate, |
| 279 const ArrayBufferArray& arrayBuffers, | 279 const ArrayBufferArray& arrayBuffers, |
| 280 ExceptionState& exceptionState) { | 280 ExceptionState& exceptionState) { |
| 281 m_arrayBufferContentsArray = | 281 m_arrayBufferContentsArray = |
| 282 transferArrayBufferContents(isolate, arrayBuffers, exceptionState); | 282 transferArrayBufferContents(isolate, arrayBuffers, exceptionState); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 } | 414 } |
| 415 | 415 |
| 416 std::unique_ptr<ArrayBufferContentsArray> contents = | 416 std::unique_ptr<ArrayBufferContentsArray> contents = |
| 417 WTF::wrapUnique(new ArrayBufferContentsArray(arrayBuffers.size())); | 417 WTF::wrapUnique(new ArrayBufferContentsArray(arrayBuffers.size())); |
| 418 | 418 |
| 419 HeapHashSet<Member<DOMArrayBufferBase>> visited; | 419 HeapHashSet<Member<DOMArrayBufferBase>> visited; |
| 420 for (auto it = arrayBuffers.begin(); it != arrayBuffers.end(); ++it) { | 420 for (auto it = arrayBuffers.begin(); it != arrayBuffers.end(); ++it) { |
| 421 DOMArrayBufferBase* arrayBuffer = *it; | 421 DOMArrayBufferBase* arrayBuffer = *it; |
| 422 if (visited.contains(arrayBuffer)) | 422 if (visited.contains(arrayBuffer)) |
| 423 continue; | 423 continue; |
| 424 visited.add(arrayBuffer); | 424 visited.insert(arrayBuffer); |
| 425 | 425 |
| 426 size_t index = std::distance(arrayBuffers.begin(), it); | 426 size_t index = std::distance(arrayBuffers.begin(), it); |
| 427 if (arrayBuffer->isShared()) { | 427 if (arrayBuffer->isShared()) { |
| 428 if (!arrayBuffer->shareContentsWith(contents->at(index))) { | 428 if (!arrayBuffer->shareContentsWith(contents->at(index))) { |
| 429 exceptionState.throwDOMException(DataCloneError, | 429 exceptionState.throwDOMException(DataCloneError, |
| 430 "SharedArrayBuffer at index " + | 430 "SharedArrayBuffer at index " + |
| 431 String::number(index) + | 431 String::number(index) + |
| 432 " could not be transferred."); | 432 " could not be transferred."); |
| 433 return nullptr; | 433 return nullptr; |
| 434 } | 434 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 465 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { | 465 void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() { |
| 466 if (m_externallyAllocatedMemory) | 466 if (m_externallyAllocatedMemory) |
| 467 return; | 467 return; |
| 468 | 468 |
| 469 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); | 469 m_externallyAllocatedMemory = static_cast<intptr_t>(dataLengthInBytes()); |
| 470 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( | 470 v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory( |
| 471 m_externallyAllocatedMemory); | 471 m_externallyAllocatedMemory); |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace blink | 474 } // namespace blink |
| OLD | NEW |