Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/SerializedScriptValue.cpp

Issue 2860303002: Run SharedArrayBuffer WPT tests in virtual/sharedarraybuffer testsuite (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/SerializedScriptValue.h" 31 #include "bindings/core/v8/SerializedScriptValue.h"
32 32
33 #include <algorithm>
33 #include <memory> 34 #include <memory>
34 #include "bindings/core/v8/ExceptionState.h" 35 #include "bindings/core/v8/ExceptionState.h"
35 #include "bindings/core/v8/IDLTypes.h" 36 #include "bindings/core/v8/IDLTypes.h"
36 #include "bindings/core/v8/NativeValueTraitsImpl.h" 37 #include "bindings/core/v8/NativeValueTraitsImpl.h"
37 #include "bindings/core/v8/SerializationTag.h" 38 #include "bindings/core/v8/SerializationTag.h"
38 #include "bindings/core/v8/SerializedScriptValueFactory.h" 39 #include "bindings/core/v8/SerializedScriptValueFactory.h"
39 #include "bindings/core/v8/Transferables.h" 40 #include "bindings/core/v8/Transferables.h"
40 #include "bindings/core/v8/V8ArrayBuffer.h" 41 #include "bindings/core/v8/V8ArrayBuffer.h"
41 #include "bindings/core/v8/V8ImageBitmap.h" 42 #include "bindings/core/v8/V8ImageBitmap.h"
42 #include "bindings/core/v8/V8MessagePort.h" 43 #include "bindings/core/v8/V8MessagePort.h"
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 } else { 437 } else {
437 exception_state.ThrowTypeError("Value at index " + String::Number(i) + 438 exception_state.ThrowTypeError("Value at index " + String::Number(i) +
438 " does not have a transferable type."); 439 " does not have a transferable type.");
439 return false; 440 return false;
440 } 441 }
441 i++; 442 i++;
442 } 443 }
443 return true; 444 return true;
444 } 445 }
445 446
447 ArrayBufferArray SerializedScriptValue::ExtractNonSharedArrayBuffers(
448 Transferables& transferables) {
449 ArrayBufferArray& array_buffers = transferables.array_buffers;
450 ArrayBufferArray result;
451 auto non_shared_begin =
452 std::partition(array_buffers.begin(), array_buffers.end(),
453 [](Member<DOMArrayBufferBase>& array_buffer) {
454 return array_buffer->IsShared();
455 });
456 result.AppendRange(non_shared_begin, array_buffers.end());
457 array_buffers.erase(non_shared_begin - array_buffers.begin(),
458 array_buffers.end() - non_shared_begin);
haraken 2017/05/05 00:52:52 Do we have a test case where shared array buffers
binji 2017/05/05 18:53:39 Nope, but I just added one.
459 return result;
460 }
461
446 std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray> 462 std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray>
447 SerializedScriptValue::TransferArrayBufferContents( 463 SerializedScriptValue::TransferArrayBufferContents(
448 v8::Isolate* isolate, 464 v8::Isolate* isolate,
449 const ArrayBufferArray& array_buffers, 465 const ArrayBufferArray& array_buffers,
450 ExceptionState& exception_state) { 466 ExceptionState& exception_state) {
451 if (!array_buffers.size()) 467 if (!array_buffers.size())
452 return nullptr; 468 return nullptr;
453 469
454 for (auto it = array_buffers.begin(); it != array_buffers.end(); ++it) { 470 for (auto it = array_buffers.begin(); it != array_buffers.end(); ++it) {
455 DOMArrayBufferBase* array_buffer = *it; 471 DOMArrayBufferBase* array_buffer = *it;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 // Only (re)register allocation cost for transferables if this 544 // Only (re)register allocation cost for transferables if this
529 // SerializedScriptValue has explicitly unregistered them before. 545 // SerializedScriptValue has explicitly unregistered them before.
530 if (array_buffer_contents_array_ && 546 if (array_buffer_contents_array_ &&
531 transferables_need_external_allocation_registration_) { 547 transferables_need_external_allocation_registration_) {
532 for (auto& buffer : *array_buffer_contents_array_) 548 for (auto& buffer : *array_buffer_contents_array_)
533 buffer.RegisterExternalAllocationWithCurrentContext(); 549 buffer.RegisterExternalAllocationWithCurrentContext();
534 } 550 }
535 } 551 }
536 552
537 } // namespace blink 553 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698