Add brokered mojo shared memory region create methods |
||
Issue description
mojo::SharedMemoryBuffer::Create is used for shared memory in processes which don't have the privileges to create shared memory region themselves. Under the hood, a broker is used in a privileged process to create a region which is then passed back to the caller.
There is no equivalent for this in the base::*SharedMemoryRegion creators. The proposal is to add mojo/public/cpp/base/shared_memory_utils.h containing the appropriate create methods.
The implementations will be variations on the following:
mojo::ScopedSharedBufferHandle handle =
mojo::SharedBufferHandle::Create(size);
if (!handle.is_valid()) {
DLOG(ERROR) << ....
return;
}
base::WritableSharedMemoryRegion region =
mojo::UnwrapWritableSharedMemoryRegion(std::move(handle));
if (!region.IsValid()) {
DLOG(ERROR) << ....
return;
}
And then doing the appropriate conversion to Unsafe or ReadOnly as necessary.
,
Aug 17
Renderers already do tons of sync IPC from the main thread. I'm not sure we should advise otherwise for this.
,
Aug 17
Oh, I didn't know that this is already a common practice, good to know.
,
Aug 22
,
Aug 22
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/3db31de0beb45cfc047e28b67548775268270113 commit 3db31de0beb45cfc047e28b67548775268270113 Author: Matthew Cary <mattcary@chromium.org> Date: Wed Aug 22 16:40:02 2018 Add mojo::Create*SharedMemoryRegions This adds *SharedMemoryRegion create methods that parallel those in base::. These use mojo::SharedMemoryBuffer::Create, which will use a broker if appropriate to create shared memory in unprivileged processes. Also update comments to clarify migration. Bug: 872778 Change-Id: Ia32da8181fd37d88a49a26e3e7e158612147646b Reviewed-on: https://chromium-review.googlesource.com/1169602 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Ken Rockot <rockot@chromium.org> Commit-Queue: Matthew Cary <mattcary@chromium.org> Cr-Commit-Position: refs/heads/master@{#585068} [modify] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/base/memory/read_only_shared_memory_region.h [modify] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/base/memory/unsafe_shared_memory_region.h [modify] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/base/memory/writable_shared_memory_region.h [modify] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/mojo/public/cpp/base/BUILD.gn [add] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/mojo/public/cpp/base/shared_memory_utils.cc [add] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/mojo/public/cpp/base/shared_memory_utils.h [modify] https://crrev.com/3db31de0beb45cfc047e28b67548775268270113/mojo/public/cpp/system/buffer.h
,
Sep 7
,
Sep 11
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/b4f775157f2e456630092e39fb0b3df5e46dcaea commit b4f775157f2e456630092e39fb0b3df5e46dcaea Author: Matthew Cary <mattcary@chromium.org> Date: Tue Sep 11 15:19:54 2018 Update CommandBufferProxyImpl to mojo shm creation This changes CommandBufferProxyImpl::AllocateAndMapSharedMemory to use the new mojo shared memory region API for creating the unsafe shared memory region it uses. Bug: 872778 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel Change-Id: Ia1b5380eb21afe54a05e81d26df8307819de23c0 Reviewed-on: https://chromium-review.googlesource.com/1171229 Reviewed-by: Sunny Sachanandani <sunnyps@chromium.org> Reviewed-by: Alexandr Ilin <alexilin@chromium.org> Reviewed-by: Daniele Castagna <dcastagna@chromium.org> Commit-Queue: Matthew Cary <mattcary@chromium.org> Cr-Commit-Position: refs/heads/master@{#590313} [modify] https://crrev.com/b4f775157f2e456630092e39fb0b3df5e46dcaea/gpu/ipc/client/command_buffer_proxy_impl.cc |
||
►
Sign in to add a comment |
||
Comment 1 by alexilin@chromium.org
, Aug 17