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

Unified Diff: ppapi/proxy/dispatcher.cc

Issue 6580050: Factor fd sharing code in proxy and fix fd issues once and for all. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix review comments Created 9 years, 10 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
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/ppb_audio_proxy.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/proxy/dispatcher.cc
diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc
index 53b0baf01c485e6b0c9ad08c0666bfa8f6f097cd..ad0094dfd8fb278d7bfbed0842dd0c72d6d32830 100644
--- a/ppapi/proxy/dispatcher.cc
+++ b/ppapi/proxy/dispatcher.cc
@@ -252,6 +252,33 @@ const void* Dispatcher::GetLocalInterface(const char* interface) {
return local_get_interface_(interface);
}
+IPC::PlatformFileForTransit Dispatcher::ShareHandleWithRemote(
+ base::PlatformFile handle,
+ bool should_close_source) {
+ IPC::PlatformFileForTransit out_handle;
+#if defined(OS_WIN)
+ DWORD options = DUPLICATE_SAME_ACCESS;
+ if (should_close_source)
+ options |= DUPLICATE_CLOSE_SOURCE;
+ if (!::DuplicateHandle(::GetCurrentProcess(),
+ handle,
+ remote_process_handle_,
+ &out_handle,
+ 0,
+ FALSE,
+ options))
+ out_handle = IPC::InvalidPlatformFileForTransit();
+#elif defined(OS_POSIX)
+ // If asked to close the source, we can simply re-use the source fd instead of
+ // dup()ing and close()ing.
+ int fd = should_close_source ? handle : ::dup(handle);
+ out_handle = base::FileDescriptor(fd, true);
+#else
+ #error Not implemented.
+#endif
+ return out_handle;
+}
+
bool Dispatcher::Send(IPC::Message* msg) {
if (test_sink_)
return test_sink_->Send(msg);
« no previous file with comments | « ppapi/proxy/dispatcher.h ('k') | ppapi/proxy/ppb_audio_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698