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

Side by Side Diff: content/browser/android/child_process_launcher.cc

Issue 12321131: Renamed Sandboxed process to Child process (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebaesed and removed stub SandboxedProcessService Created 7 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/android/sandboxed_process_launcher.h" 5 #include "content/browser/android/child_process_launcher.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h" 8 #include "base/android/jni_array.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "jni/SandboxedProcessLauncher_jni.h" 11 #include "jni/ChildProcessLauncher_jni.h"
12 12
13 using base::android::AttachCurrentThread; 13 using base::android::AttachCurrentThread;
14 using base::android::ToJavaArrayOfStrings; 14 using base::android::ToJavaArrayOfStrings;
15 using base::android::ScopedJavaLocalRef; 15 using base::android::ScopedJavaLocalRef;
16 using content::StartSandboxedProcessCallback; 16 using content::StartChildProcessCallback;
17 17
18 namespace content { 18 namespace content {
19 19
20 // Called from SandboxedProcessLauncher.java when the SandboxedProcess was 20 // Called from ChildProcessLauncher.java when the ChildProcess was
21 // started. 21 // started.
22 // |client_context| is the pointer to StartSandboxedProcessCallback which was 22 // |client_context| is the pointer to StartChildProcessCallback which was
23 // passed in from StartSandboxedProcess. 23 // passed in from StartChildProcess.
24 // |handle| is the processID of the child process as originated in Java, 0 if 24 // |handle| is the processID of the child process as originated in Java, 0 if
25 // the SandboxedProcess could not be created. 25 // the ChildProcess could not be created.
26 static void OnSandboxedProcessStarted(JNIEnv*, 26 static void OnChildProcessStarted(JNIEnv*,
27 jclass, 27 jclass,
28 jint client_context, 28 jint client_context,
29 jint handle) { 29 jint handle) {
30 StartSandboxedProcessCallback* callback = 30 StartChildProcessCallback* callback =
31 reinterpret_cast<StartSandboxedProcessCallback*>(client_context); 31 reinterpret_cast<StartChildProcessCallback*>(client_context);
32 if (handle) 32 if (handle)
33 callback->Run(static_cast<base::ProcessHandle>(handle)); 33 callback->Run(static_cast<base::ProcessHandle>(handle));
34 delete callback; 34 delete callback;
35 } 35 }
36 36
37 void StartSandboxedProcess( 37 void StartChildProcess(
38 const CommandLine::StringVector& argv, 38 const CommandLine::StringVector& argv,
39 const std::vector<content::FileDescriptorInfo>& files_to_register, 39 const std::vector<content::FileDescriptorInfo>& files_to_register,
40 const StartSandboxedProcessCallback& callback) { 40 const StartChildProcessCallback& callback) {
41 JNIEnv* env = AttachCurrentThread(); 41 JNIEnv* env = AttachCurrentThread();
42 DCHECK(env); 42 DCHECK(env);
43 43
44 // Create the Command line String[] 44 // Create the Command line String[]
45 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); 45 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv);
46 46
47 size_t file_count = files_to_register.size(); 47 size_t file_count = files_to_register.size();
48 DCHECK(file_count > 0); 48 DCHECK(file_count > 0);
49 49
50 ScopedJavaLocalRef<jintArray> j_file_ids(env, env->NewIntArray(file_count)); 50 ScopedJavaLocalRef<jintArray> j_file_ids(env, env->NewIntArray(file_count));
(...skipping 13 matching lines...) Expand all
64 for (size_t i = 0; i < file_count; ++i) { 64 for (size_t i = 0; i < file_count; ++i) {
65 const content::FileDescriptorInfo& fd_info = files_to_register[i]; 65 const content::FileDescriptorInfo& fd_info = files_to_register[i];
66 file_ids[i] = fd_info.id; 66 file_ids[i] = fd_info.id;
67 file_fds[i] = fd_info.fd.fd; 67 file_fds[i] = fd_info.fd.fd;
68 file_auto_close[i] = fd_info.fd.auto_close; 68 file_auto_close[i] = fd_info.fd.auto_close;
69 } 69 }
70 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); 70 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0);
71 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); 71 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0);
72 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); 72 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0);
73 73
74 Java_SandboxedProcessLauncher_start(env, 74 Java_ChildProcessLauncher_start(env,
75 base::android::GetApplicationContext(), 75 base::android::GetApplicationContext(),
76 j_argv.obj(), 76 j_argv.obj(),
77 j_file_ids.obj(), 77 j_file_ids.obj(),
78 j_file_fds.obj(), 78 j_file_fds.obj(),
79 j_file_auto_close.obj(), 79 j_file_auto_close.obj(),
80 reinterpret_cast<jint>(new StartSandboxedProcessCallback(callback))); 80 reinterpret_cast<jint>(new StartChildProcessCallback(callback)));
81 } 81 }
82 82
83 void StopSandboxedProcess(base::ProcessHandle handle) { 83 void StopChildProcess(base::ProcessHandle handle) {
84 JNIEnv* env = AttachCurrentThread(); 84 JNIEnv* env = AttachCurrentThread();
85 DCHECK(env); 85 DCHECK(env);
86 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle)); 86 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle));
87 } 87 }
88 88
89 bool RegisterSandboxedProcessLauncher(JNIEnv* env) { 89 bool RegisterChildProcessLauncher(JNIEnv* env) {
90 return RegisterNativesImpl(env); 90 return RegisterNativesImpl(env);
91 } 91 }
92 92
93 } // namespace content 93 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698