Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: content/ppapi_plugin/ppapi_thread.cc

Issue 1166443004: Further clean up pepper's use of SharedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shared_memory_make_class3_base
Patch Set: Fix compile error on windows. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/ppapi_plugin/ppapi_thread.cc
diff --git a/content/ppapi_plugin/ppapi_thread.cc b/content/ppapi_plugin/ppapi_thread.cc
index a0ed633ff8747a0d22124f6b3af70eadda77e936..10c82631b5c5dc020bb3a3e7f144a5203a940547 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;
piman 2015/06/03 17:44:44 nit: just initialize this with base::SharedMemory:
erikchen 2015/06/03 17:58:31 Your suggestion saves 3 lines of code, but it make
+ 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() {

Powered by Google App Engine
This is Rietveld 408576698