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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp

Issue 2860303002: Run SharedArrayBuffer WPT tests in virtual/sharedarraybuffer testsuite (Closed)
Patch Set: add comment to ExtractNonSharedArrayBuffers and merge HEAD 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp b/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp
index e32d2618de97c87eae75ff8b55c52a9efb07ab0c..48b8aedf5ba36e77960666c4f3c70efe9e0393a1 100644
--- a/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/serialization/SerializedScriptValue.cpp
@@ -30,6 +30,7 @@
#include "bindings/core/v8/serialization/SerializedScriptValue.h"
+#include <algorithm>
#include <memory>
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/IDLTypes.h"
@@ -443,6 +444,25 @@ bool SerializedScriptValue::ExtractTransferables(
return true;
}
+ArrayBufferArray SerializedScriptValue::ExtractNonSharedArrayBuffers(
+ Transferables& transferables) {
+ ArrayBufferArray& array_buffers = transferables.array_buffers;
+ ArrayBufferArray result;
+ // Partition array_buffers into [shared..., non_shared...], maintaining
+ // relative ordering of elements with the same predicate value.
+ auto non_shared_begin =
+ std::stable_partition(array_buffers.begin(), array_buffers.end(),
+ [](Member<DOMArrayBufferBase>& array_buffer) {
+ return array_buffer->IsShared();
+ });
+ // Copy the non-shared array buffers into result, and remove them from
+ // array_buffers.
+ result.AppendRange(non_shared_begin, array_buffers.end());
+ array_buffers.erase(non_shared_begin - array_buffers.begin(),
+ array_buffers.end() - non_shared_begin);
+ return result;
+}
+
std::unique_ptr<SerializedScriptValue::ArrayBufferContentsArray>
SerializedScriptValue::TransferArrayBufferContents(
v8::Isolate* isolate,

Powered by Google App Engine
This is Rietveld 408576698