Commit 4ce86a61 authored by Matthew Cary's avatar Matthew Cary Committed by Commit Bot

wayland fuzzer: upgrade SharedMemory api

The fuzzer uses the shared memory API to create a file descriptor
(Harness::GetFileDescriptor). This change updates that creation from
the legacy shared memory API to the new one. There is no functional
change.

Bug: 795291
Change-Id: I186fc316c15c19fea08b04b76d8c663cdb673eb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1695410Reviewed-by: default avatarNic Hollingum <hollingum@google.com>
Commit-Queue: Matthew Cary (CET) <mattcary@chromium.org>
Cr-Commit-Position: refs/heads/master@{#676303}
parent a51d306b
......@@ -211,12 +211,14 @@ void Harness::Run(const actions::action& current_step) {
int Harness::GetFileDescriptor(int id) {
if (shared_memory_map_.count(id) == 0) {
auto shared_mem = std::make_unique<base::SharedMemory>();
shared_mem->CreateAndMapAnonymous(1);
shared_memory_map_.emplace(id, std::move(shared_mem));
base::UnsafeSharedMemoryRegion region =
base::UnsafeSharedMemoryRegion::Create(1);
shared_memory_map_.emplace(id, std::move(region));
}
return base::SharedMemory::GetFdFromSharedMemoryHandle(
base::SharedMemory::DuplicateHandle(shared_memory_map_[id]->handle()));
base::subtle::ScopedFDPair fd_pair =
base::UnsafeSharedMemoryRegion::TakeHandleForSerialization(
shared_memory_map_[id].Duplicate()).PassPlatformHandle();
return fd_pair.fd.release();
}
} // namespace wayland_fuzzer
......
......@@ -10,7 +10,7 @@
#include <wayland-util.h>
#include "base/macros.h"
#include "base/memory/shared_memory.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "components/exo/wayland/fuzzer/actions.pb.h"
// Forwards declarations for the wayland-defined structs.
......@@ -60,7 +60,7 @@ class Harness {
int GetFileDescriptor(int id);
private:
std::map<int, std::unique_ptr<base::SharedMemory>> shared_memory_map_;
std::map<int, base::UnsafeSharedMemoryRegion> shared_memory_map_;
DISALLOW_COPY_AND_ASSIGN(Harness);
};
......
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