Update pepper to not assume that SharedMemoryHandle is an int.
This CL is a refactor. This CL contains no intended behavior changes.
Pepper code assumes that SharedMemoryHandle is backed by a PlatformFile, and
that the relevant HANDLE or fd can be cast to an int. These assumptions will no
longer be true once SharedMemory is backed by Mach primitives on Mac.
This CL adds the method ShareSharedMemoryHandleWithRemote() to
ProxyChannel::Delegate. This method is used in place of ShareHandleWithRemote()
when a SharedMemory object is being shared between processes. This CL updates
the type of all SharedMemory handles to be SharedMemoryHandle.
BUG=466437
Review URL: https://codereview.chromium.org/1154613006
Cr-Commit-Position: refs/heads/master@{#332325}
diff --git a/ppapi/proxy/proxy_channel.h b/ppapi/proxy/proxy_channel.h
index 1de65117..fbd31ad85 100644
--- a/ppapi/proxy/proxy_channel.h
+++ b/ppapi/proxy/proxy_channel.h
@@ -7,6 +7,7 @@
#include "base/files/scoped_file.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/shared_memory.h"
#include "base/process/process.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_platform_file.h"
@@ -50,6 +51,15 @@
base::PlatformFile handle,
base::ProcessId remote_pid,
bool should_close_source) = 0;
+
+ // Duplicates a shared memory handle, returning one that is valid on the
+ // other side of the channel. This is part of the delegate interface
+ // because both sides of the channel may not have sufficient permission to
+ // duplicate handles directly. The implementation must provide the same
+ // guarantees as ProxyChannel::ShareSharedMemoryHandleWithRemote below.
+ virtual base::SharedMemoryHandle ShareSharedMemoryHandleWithRemote(
+ const base::SharedMemoryHandle& handle,
+ base::ProcessId remote_pid) = 0;
};
~ProxyChannel() override;
@@ -70,6 +80,14 @@
base::PlatformFile handle,
bool should_close_source);
+ // Shares a shared memory handle with the remote side. It returns a handle
+ // that should be sent in exactly one IPC message. Upon receipt, the remote
+ // side then owns that handle. Note: if sending the message fails, the
+ // returned handle is properly closed by the IPC system. The original handle
+ // is not closed by this operation.
+ base::SharedMemoryHandle ShareSharedMemoryHandleWithRemote(
+ const base::SharedMemoryHandle& handle);
+
// IPC::Sender implementation.
bool Send(IPC::Message* msg) override;