From https://crrev.com/c/1402880.
The current API for creating a read only region with only one writable mapping:
base::MappedReadOnlyRegion shm = base::ReadOnlySharedMemoryRegion::Create(4 << 10);
shm.mapping; // WritableSharedMemoryMapping
shm.region; // ReadOnlySharedMemoryRegion
This reads really oddly, since it's not obvious from the naming that MappedReadOnlyRegion is _actually_ a read-only _region_ and a writable _mapping_ of the same region.
The proposal is to change the naming:
ReadOnlySharedMemoryRegion::Create -> CreateWithWritableMapping()
and MappedReadOnlyRegion -> WritableMappingWithReadOnlyRegion or SingleWriterMemoryRegion
Another possibility is to return a pair from ReadOnlySharedMemoryRegion::Create() so one can write:
base::ReadOnlySharedMemoryRegion region;
base::WritableSharedMemoryRegion mapping;
std::tie(region, mapping) = base::ReadOnlySharedMemoryRegion::Create(size);