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

Unified Diff: content/browser/android/child_process_launcher_android.cc

Issue 909553003: Android: Get rid of extra dup()s on launching child processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « no previous file | content/browser/file_descriptor_info_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/android/child_process_launcher_android.cc
diff --git a/content/browser/android/child_process_launcher_android.cc b/content/browser/android/child_process_launcher_android.cc
index da2af473564ce9c7fc02e7d5092fc7f73e2913f5..161493b503dde819b598a99cec879387bd5c307e 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -128,14 +128,12 @@ void StartChildProcess(
env->GetBooleanArrayElements(j_file_auto_close.obj(), NULL);
base::android::CheckException(env);
for (size_t i = 0; i < file_count; ++i) {
- // Owners of passed descriptors can outlive this function and we don't know
- // when it is safe to close() them. So we pass dup()-ed FD and
- // let ChildProcessLauncher in java take care of their lifetimes.
- // TODO(morrita): Drop FileDescriptorInfo.mAutoClose on Java side.
- file_auto_close[i] = true; // This indicates ownership transfer.
file_ids[i] = files_to_register->GetIDAt(i);
- file_fds[i] = dup(files_to_register->GetFDAt(i));
+ file_fds[i] = files_to_register->GetFDAt(i);
PCHECK(0 <= file_fds[i]);
+ file_auto_close[i] = files_to_register->OwnsFD(file_fds[i]);
mdempsky 2015/02/07 02:37:05 OwnsFD and ReleaseFD seem like clunky APIs, but un
+ if (file_auto_close[i])
+ ignore_result(files_to_register->ReleaseFD(file_fds[i]).release());
}
env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0);
env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0);
« no previous file with comments | « no previous file | content/browser/file_descriptor_info_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698