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

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

Issue 10541110: Added sandboxed process launcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed ProcessID and Sync Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/android/sandboxed_process_launcher.h"
6
7 #include "base/android/jni_android.h"
8 #include "base/android/jni_array.h"
9 #include "base/logging.h"
10 #include "jni/sandboxed_process_launcher_jni.h"
11
12 using base::android::AttachCurrentThread;
13 using base::android::ToJavaArrayOfStrings;
14 using base::android::ScopedJavaLocalRef;
15 using content::StartSandboxedProcessCallback;
16
17 static void OnSandboxedProcessStarted(JNIEnv*,
18 jclass,
19 jint client_context,
20 jint pid) {
21 StartSandboxedProcessCallback* callback =
22 reinterpret_cast<StartSandboxedProcessCallback*>(client_context);
23 callback->Run(static_cast<base::ProcessHandle>(pid));
24 delete callback;
25 }
26
27 namespace content {
28
29 ScopedJavaLocalRef<jobject> StartSandboxedProcess(
30 const CommandLine::StringVector& argv,
31 int ipc_fd,
32 int crash_fd,
33 const StartSandboxedProcessCallback& callback) {
34 JNIEnv* env = AttachCurrentThread();
35 DCHECK(env);
36
37 // Create the Command line String[]
38 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv);
39
40 return Java_SandboxedProcessLauncher_start(env,
41 base::android::GetApplicationContext(),
42 static_cast<jobjectArray>(j_argv.obj()),
43 static_cast<jint>(ipc_fd),
44 static_cast<jint>(crash_fd),
45 reinterpret_cast<jint>(new StartSandboxedProcessCallback(callback)));
46 }
47
48 void CancelStartSandboxedProcess(
49 const base::android::JavaRef<jobject>& connection) {
50 Java_SandboxedProcessLauncher_cancelStart(AttachCurrentThread(),
51 connection.obj());
52 }
53
54 void StopSandboxedProcess(base::ProcessHandle handle) {
55 JNIEnv* env = AttachCurrentThread();
56 DCHECK(env);
57 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle));
58 }
59
60 bool RegisterSandboxedProcessLauncher(JNIEnv* env) {
61 return RegisterNativesImpl(env);
62 }
63
64 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698