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

Unified Diff: ipc/ipc_platform_file.cc

Issue 1862493002: win: More attachment brokering for PlatformFileForTransit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_platform_file.cc
diff --git a/ipc/ipc_platform_file.cc b/ipc/ipc_platform_file.cc
index a9b7b880932e3c2dd4d5ca7b627c1d77764faf6f..c8fde86f1e4564403290da39c2abf6cb880e48bc 100644
--- a/ipc/ipc_platform_file.cc
+++ b/ipc/ipc_platform_file.cc
@@ -14,21 +14,21 @@ namespace IPC {
PlatformFileForTransit GetFileHandleForProcess(base::PlatformFile handle,
base::ProcessHandle process,
bool close_source_handle) {
- IPC::PlatformFileForTransit out_handle;
#if defined(OS_WIN)
HANDLE raw_handle = INVALID_HANDLE_VALUE;
DWORD options = DUPLICATE_SAME_ACCESS;
if (close_source_handle)
options |= DUPLICATE_CLOSE_SOURCE;
if (handle == INVALID_HANDLE_VALUE ||
- !::DuplicateHandle(::GetCurrentProcess(), handle, process, &raw_handle, 0,
- FALSE, options)) {
- out_handle = IPC::InvalidPlatformFileForTransit();
- } else {
- out_handle =
- IPC::PlatformFileForTransit(raw_handle, base::GetProcId(process));
- out_handle.SetOwnershipPassesToIPC(true);
+ !::DuplicateHandle(::GetCurrentProcess(), handle, ::GetCurrentProcess(),
+ &raw_handle, 0, FALSE, options)) {
+ return IPC::InvalidPlatformFileForTransit();
}
+
+ IPC::PlatformFileForTransit out_handle = IPC::PlatformFileForTransit(
+ raw_handle, base::GetCurrentProcId());
+ out_handle.SetOwnershipPassesToIPC(true);
+ return out_handle;
#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.
@@ -39,11 +39,10 @@ PlatformFileForTransit GetFileHandleForProcess(base::PlatformFile handle,
// close the source handle before the message is sent, creating a race
// condition.
int fd = close_source_handle ? handle : ::dup(handle);
- out_handle = base::FileDescriptor(fd, true);
+ return base::FileDescriptor(fd, true);
#else
#error Not implemented.
#endif
- return out_handle;
}
PlatformFileForTransit TakeFileHandleForProcess(base::File file,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698