base: Introduce the new Shared Memory API

Design doc (public): https://goo.gl/HmBYy6

This patch proposes the new API for the Shared Memory based on two
concepts, a shared memory region and a shared memory mapping. The
region controls the platform-specific handle and mediates sharing and
access control. The mapping is just a reference to the memory bytes
which knows how to unmap itself. Ownership is per-instance: neither a
region nor a mapping may be copied, and resources are freed when then
instance dies. This is accomplished through move-only semantics.

The goal of the new API is to provide a correct cross-platform
implementation that makes the sharing mode explicit via the C++ type
system.

Thus, this CL introduces two classes for shared memory mappings:
- WritableSharedMemoryMapping owns and provides an access to writable
shared memory
- ReadOnlySharedMemoryMapping for read-only shared memory

and three classes representing shared memory regions:
- UnsafeSharedMemoryRegion allows to create
WritableSharedMemoryMapping instances and cannot be used for making
read-only mappings
- ReadOnlySharedMemoryRegion, on the contrary, can produce only
ReadOnlySharedMemoryMapping instances and it also creates one writable
mapping in the caller process address space
- WritableSharedMemoryRegion allows to create writable
mappings and can be eventually converted to ReadOnlySharedMemoryRegion.
The important limitation in comparison with UnsafeSharedMemoryRegion
is that the WritableSharedMemoryRegion cannot be duplicated so in
order to pass the writable region to another process, the ownership of
the region must be moved/transferred to this process.

Bug: 795291
Change-Id: I7d1d0a24932145cc0f449b01ceb8cafef9b7e407
Reviewed-on: https://chromium-review.googlesource.com/893458
Commit-Queue: Alexandr Ilin <alexilin@chromium.org>
Reviewed-by: Matthew Cary <mattcary@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#545521}
25 files changed