New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 920183 link

Starred by 1 user

Issue metadata

Status: Started
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 795291



Sign in to add a comment

Convert base/metrics to the new shared memory API

Project Member Reported by alexilin@chromium.org, Jan 9

Issue description

base::SharedMemory and base::SharedMemoryHandle should be converted to the new shared memory API: base::{Writable,ReadOnly,Unsafe}SharedMemoryRegion and base::{Writable,ReadOnly}SharedMemoryMapping.

Metrics have two distinct use-cases for shared memory:
* Field trials
* Histograms

Field trials are written in a shared memory region once in the browser process and shared with all other processes as read-only. ReadOnlySharedMemoryRegion is a nice fit for this use-case. 

Field trials don't use usual Mojo/IPC mechanisms for transferring shared memory regions to other processes. Instead, a shared memory region gets created before a child process is forked and a child inherits an opened file descriptor. It's possible to preserve this logic with the new shared memory API since the blocking  issue 776564  has been resolved.

Histograms shared memory is writable in all processes. We may use either UnsafeSharedMemoryRegion or WritableSharedMemoryRegion. The browser creates one shared memory region per child process. We could create and map a Writable region in the browser process first, and then move the region object to a child process.

Both field trials and histograms use a SharedPersistentMemoryAllocator class that implements a PersistentMemoryAllocator backed by the shared memory. PersistentMemoryAllocator can be constructed around both readonly and writable memory. I propose to create two new subclasses of PersistentMemoryAllocator: 
* WritableSharedPersistentMemoryAllocator backed by WritableSharedMemoryMapping
* ReadOnlySharedPersistentMemoryAllocator backed by ReadOnlySharedMemoryMapping
Clients actually may use a pointer to the base class because the new allocators wouldn't expose the shared_memory() method.
 
Blocking: 795291

Sign in to add a comment