Convert Pepper shared memory allocation to the new shared memory API

This CL replaces the deprecated base::SharedMemoryHandle and
base::SharedMemory in Pepper to allocate shared memory for plugin process
with the new shared memory API

The shared memory is used in ppapi::ArrayBufferVar in the following way:

A plugin process asks its host (renderer) to allocate shared memory.
The plugin process writes into this memory, and the host only reads from it.
The host tracks all shared memory it allocates in a table via HostVarTracker::TrackSharedMemoryHandle().
A shared memory handle can be later extracted from this table by calling

Even though the host never reads from the shared memory, ReadOnlySharedMemoryRegion
cannot be used because the plugin should keep its writable shared memory region
to be used in ArrayBufferRawVarData::Init() later. The new shared memory API
doesn't allow to have read-only and writable handles to the same region at the same time.
Moreover, this region is stored inside in ppapi::proxy::ArrayBufferRawVarData::plugin_shm_handle_
as a ppapi::proxy::SerializedHandle that doesn't support WritableSharedMemoryRegion, and adding
this support would be cumbersome.
Notice that the shared memory used here was never actually read-only, because it wasn't
constructed from a handle obtained from base::SharedMemory::GetReadOnlyHandle().
See a comment to the base::SharedMemory constructor.

Bug: 795291
Change-Id: I437f8d124916615fb25e840431b83cc9586b0773
Commit-Queue: Tanmoy Mollik <>
Reviewed-by: Alex Ilin <>
Reviewed-by: Bill Budge <>
Cr-Original-Commit-Position: refs/heads/master@{#655176}
Cr-Mirrored-Commit: 2faf9f99315b4a20784086792396490835aab981
9 files changed