Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| 16 static void OnSandboxedProcessStarted(JNIEnv*, | |
| 17 jclass, | |
| 18 jint client_context, | |
| 19 jint pid) { | |
| 20 reinterpret_cast<content::SandboxedProcessClient*>( | |
|
jam
2012/06/12 17:24:11
nit: indentation si off
michaelbai
2012/06/12 19:44:26
Done.
| |
| 21 client_context)->OnSandboxedProcessStarted(pid); | |
| 22 } | |
| 23 | |
| 24 namespace content { | |
| 25 | |
| 26 ScopedJavaLocalRef<jobject> StartSandboxedProcess( | |
| 27 const CommandLine::StringVector& argv, | |
| 28 int ipc_fd, | |
| 29 int crash_fd, | |
| 30 SandboxedProcessClient* client) { | |
| 31 JNIEnv* env = AttachCurrentThread(); | |
| 32 DCHECK(env); | |
| 33 | |
| 34 // Create the Command line String[] | |
| 35 ScopedJavaLocalRef<jobjectArray> j_argv = ToJavaArrayOfStrings(env, argv); | |
| 36 | |
| 37 return Java_SandboxedProcessLauncher_start(env, | |
| 38 base::android::GetApplicationContext(), | |
| 39 static_cast<jobjectArray>(j_argv.obj()), | |
| 40 static_cast<jint>(ipc_fd), | |
| 41 static_cast<jint>(crash_fd), | |
| 42 reinterpret_cast<jint>(client)); | |
| 43 } | |
| 44 | |
| 45 void CancelStartSandboxedProcess( | |
| 46 const base::android::JavaRef<jobject>& connection) { | |
| 47 Java_SandboxedProcessLauncher_cancelStart(AttachCurrentThread(), | |
| 48 connection.obj()); | |
| 49 } | |
| 50 | |
| 51 void StopSandboxedProcess(base::ProcessHandle handle) { | |
| 52 JNIEnv* env = AttachCurrentThread(); | |
| 53 DCHECK(env); | |
| 54 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle)); | |
| 55 } | |
| 56 | |
| 57 bool RegisterSandboxedProcessLauncher(JNIEnv* env) { | |
| 58 return RegisterNativesImpl(env); | |
| 59 } | |
| 60 | |
| 61 } // namespace content | |
| OLD | NEW |