diff options
author | erikchen <erikchen@chromium.org> | 2015-06-04 13:44:18 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-04 20:44:56 +0000 |
commit | fc29ad99d6286026e7cce6019179334d59330935 (patch) | |
tree | ba894e359a8f86d0eb232645fbba23c8f0dfd18d /content/ppapi_plugin | |
parent | a7f6fc40172ab43cbff179fb0432623ff14c17b9 (diff) | |
download | chromium_src-fc29ad99d6286026e7cce6019179334d59330935.zip chromium_src-fc29ad99d6286026e7cce6019179334d59330935.tar.gz chromium_src-fc29ad99d6286026e7cce6019179334d59330935.tar.bz2 |
Further clean up pepper's use of SharedMemory.
This CL uses the new methods content::BrokerDuplicateSharedMemoryHandle() and
base::SharedMemory::DuplicateHandle() to remove some duplicated code. This CL
changes the implementation of ShareSharedMemoryhandleWithRemote() to no longer
assume that the SharedMemoryHandle is backed by a POSIX fd.
BUG=466437
Review URL: https://codereview.chromium.org/1166443004
Cr-Commit-Position: refs/heads/master@{#332903}
Diffstat (limited to 'content/ppapi_plugin')
-rw-r--r-- | content/ppapi_plugin/ppapi_thread.cc | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc index a0ed633..10c8263 100644 --- a/content/ppapi_plugin/ppapi_thread.cc +++ b/content/ppapi_plugin/ppapi_thread.cc @@ -202,16 +202,24 @@ IPC::PlatformFileForTransit PpapiThread::ShareHandleWithRemote( base::SharedMemoryHandle PpapiThread::ShareSharedMemoryHandleWithRemote( const base::SharedMemoryHandle& handle, base::ProcessId remote_pid) { - base::PlatformFile local_platform_file = -#if defined(OS_POSIX) - handle.fd; -#elif defined(OS_WIN) - handle; -#else -#error Not implemented. +#if defined(OS_WIN) + if (peer_handle_.IsValid()) { + DCHECK(is_broker_); + return IPC::GetFileHandleForProcess(handle, peer_handle_.Get(), false); + } #endif - return PpapiThread::ShareHandleWithRemote(local_platform_file, remote_pid, - false); + + DCHECK(remote_pid != base::kNullProcessId); +#if defined(OS_WIN) || defined(OS_MACOSX) + base::SharedMemoryHandle duped_handle; + bool success = + BrokerDuplicateSharedMemoryHandle(handle, remote_pid, &duped_handle); + if (success) + return duped_handle; + return base::SharedMemory::NULLHandle(); +#else + return base::SharedMemory::DuplicateHandle(handle); +#endif // defined(OS_WIN) || defined(OS_MACOSX) } std::set<PP_Instance>* PpapiThread::GetGloballySeenInstanceIDSet() { |