Commit 68254386 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[messaging][cleanup] Avoid of ArrayBufferContents::DataHandle

Instead we can allocate ArrayBufferContents directly. I also added a
check if allocation failed.

I also changed the allocation to not initialize the memory. It is
overwritten immediately afterwards anyways.

R=jbroman

Bug: chromium:1008840
Change-Id: I046c30f499f67ff437e481c907efdd38fa0d0045
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864788Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706852}
parent bbf50dd4
......@@ -82,10 +82,12 @@ BlinkTransferableMessage ToBlinkTransferableMessage(
for (auto& item : message.array_buffer_contents_array) {
mojo_base::BigBuffer& big_buffer = item->contents;
auto handle = WTF::ArrayBufferContents::CreateDataHandle(
big_buffer.size(), WTF::ArrayBufferContents::kZeroInitialize);
WTF::ArrayBufferContents contents(std::move(handle),
WTF::ArrayBufferContents::kNotShared);
WTF::ArrayBufferContents contents(
big_buffer.size(), 1, WTF::ArrayBufferContents::kNotShared,
WTF::ArrayBufferContents::kDontInitialize);
// Check if we allocated the backing store of the ArrayBufferContents
// correctly.
CHECK_EQ(contents.DataLength(), big_buffer.size());
memcpy(contents.Data(), big_buffer.data(), big_buffer.size());
array_buffer_contents_array.push_back(std::move(contents));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment