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

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

Issue 585203002: Turn FileDescriptorInfo a collection class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 6 years, 3 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 | « content/browser/android/child_process_launcher_android.h ('k') | content/browser/child_process_launcher.cc » ('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 0e42fc49e9a4ead3dbee19e91a842459c509473e..b6e755e513506a9b01c87cce81c4490649818461 100644
--- a/content/browser/android/child_process_launcher_android.cc
+++ b/content/browser/android/child_process_launcher_android.cc
@@ -102,7 +102,7 @@ static void OnChildProcessStarted(JNIEnv*,
void StartChildProcess(
const base::CommandLine::StringVector& argv,
int child_process_id,
- const std::vector<content::FileDescriptorInfo>& files_to_register,
+ scoped_ptr<content::FileDescriptorInfo> files_to_register,
const StartChildProcessCallback& callback) {
JNIEnv* env = AttachCurrentThread();
DCHECK(env);
@@ -110,7 +110,7 @@ void StartChildProcess(
// Create the Command line String[]
ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv);
- size_t file_count = files_to_register.size();
+ size_t file_count = files_to_register->GetMappingSize();
DCHECK(file_count > 0);
ScopedJavaLocalRef<jintArray> j_file_ids(env, env->NewIntArray(file_count));
@@ -128,10 +128,14 @@ void StartChildProcess(
env->GetBooleanArrayElements(j_file_auto_close.obj(), NULL);
base::android::CheckException(env);
for (size_t i = 0; i < file_count; ++i) {
- const content::FileDescriptorInfo& fd_info = files_to_register[i];
- file_ids[i] = fd_info.id;
- file_fds[i] = fd_info.fd.fd;
- file_auto_close[i] = fd_info.fd.auto_close;
+ // 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));
+ PCHECK(0 <= file_fds[i]);
}
env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0);
env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0);
« no previous file with comments | « content/browser/android/child_process_launcher_android.h ('k') | content/browser/child_process_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698