Chromium Code Reviews| Index: ppapi/proxy/dispatcher.cc |
| diff --git a/ppapi/proxy/dispatcher.cc b/ppapi/proxy/dispatcher.cc |
| index 53b0baf01c485e6b0c9ad08c0666bfa8f6f097cd..85db58d374ab7290f51522484dcaae8b86cf9a81 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 close_source) { |
|
viettrungluu
2011/02/25 01:25:03
Or maybe |should_close_source|?
|
| + IPC::PlatformFileForTransit out_handle; |
| +#if defined(OS_WIN) |
| + DWORD options = DUPLICATE_SAME_ACCESS; |
| + if (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 = 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); |