New issue
Advanced search Search tips

Issue 923319 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Task



Sign in to add a comment

Make the ReadOnlySharedMemoryRegion::Create API clearer

Project Member Reported by alexilin@chromium.org, Jan 18 (4 days ago)

Issue description

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);
 

Sign in to add a comment