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

Unified Diff: content/browser/child_process_launcher.cc

Issue 621613002: Refactoring: Make IPC::Channel::TakeClientFileDescriptor() a ScopedFD. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Mac build Created 6 years, 2 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/browser/child_process_launcher.cc
diff --git a/content/browser/child_process_launcher.cc b/content/browser/child_process_launcher.cc
index b9573974eca8e38629b7c5c5a3eb23a1ee45fa2e..4fe4ea10e644c234d12454bb945395e21f4b63b1 100644
--- a/content/browser/child_process_launcher.cc
+++ b/content/browser/child_process_launcher.cc
@@ -88,7 +88,7 @@ class ChildProcessLauncher::Context
// We need to close the client end of the IPC channel to reliably detect
// child termination. We will close this fd after we create the child
// process which is asynchronous on Android.
- ipcfd_ = delegate->GetIpcFd();
+ ipcfd_.reset(delegate->TakeIpcFd().release());
#endif
BrowserThread::PostTask(
BrowserThread::PROCESS_LAUNCHER, FROM_HERE,
@@ -178,14 +178,14 @@ class ChildProcessLauncher::Context
#if defined(OS_WIN)
bool launch_elevated = delegate->ShouldLaunchElevated();
#elif defined(OS_ANDROID)
- int ipcfd = delegate->GetIpcFd();
+ // Uses |ipcfd_| instead of |ipcfd| on Android.
#elif defined(OS_MACOSX)
base::EnvironmentMap env = delegate->GetEnvironment();
- int ipcfd = delegate->GetIpcFd();
+ base::ScopedFD ipcfd = delegate->TakeIpcFd();
#elif defined(OS_POSIX)
bool use_zygote = delegate->ShouldUseZygote();
base::EnvironmentMap env = delegate->GetEnvironment();
- int ipcfd = delegate->GetIpcFd();
+ base::ScopedFD ipcfd = delegate->TakeIpcFd();
#endif
scoped_ptr<base::CommandLine> cmd_line_deleter(cmd_line);
base::TimeTicks begin_launch_time = base::TimeTicks::Now();
@@ -204,7 +204,12 @@ class ChildProcessLauncher::Context
cmd_line->GetSwitchValueASCII(switches::kProcessType);
scoped_ptr<FileDescriptorInfo> files_to_register(
FileDescriptorInfoImpl::Create());
- files_to_register->Share(kPrimaryIPCChannel, ipcfd);
+
+#if defined(OS_ANDROID)
+ files_to_register->Share(kPrimaryIPCChannel, this_object->ipcfd_.get());
+#else
+ files_to_register->Transfer(kPrimaryIPCChannel, ipcfd.Pass());
+#endif
base::StatsTable* stats_table = base::StatsTable::current();
if (stats_table &&
base::SharedMemory::IsHandleValid(
@@ -236,7 +241,6 @@ class ChildProcessLauncher::Context
base::ProcessHandle handle = base::kNullProcessHandle;
// We need to close the client end of the IPC channel to reliably detect
// child termination.
- base::ScopedFD ipcfd_closer(ipcfd);
#if !defined(OS_MACOSX)
GetContentClient()->browser()->GetAdditionalMappedFilesForChildProcess(
@@ -334,7 +338,7 @@ class ChildProcessLauncher::Context
base::ProcessHandle handle) {
#if defined(OS_ANDROID)
// Finally close the ipcfd
- base::ScopedFD ipcfd_closer(ipcfd_);
+ base::ScopedFD ipcfd_closer = ipcfd_.Pass();
#endif
starting_ = false;
process_.set_handle(handle);
@@ -425,7 +429,7 @@ class ChildProcessLauncher::Context
bool terminate_child_on_shutdown_;
#if defined(OS_ANDROID)
// The fd to close after creating the process.
- int ipcfd_;
+ base::ScopedFD ipcfd_;
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
bool zygote_;
#endif

Powered by Google App Engine
This is Rietveld 408576698