OLD | NEW |
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/sandboxed_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/SandboxedProcessLauncher_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 base::GlobalDescriptors; | 16 using base::GlobalDescriptors; |
17 using content::StartSandboxedProcessCallback; | 17 using content::StartSandboxedProcessCallback; |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 // Called from SandboxedProcessLauncher.java when the SandboxedProcess was | 21 // Called from SandboxedProcessLauncher.java when the SandboxedProcess was |
22 // started. | 22 // started. |
23 // |client_context| is the pointer to StartSandboxedProcessCallback which was | 23 // |client_context| is the pointer to StartSandboxedProcessCallback which was |
24 // passed in from StartSandboxedProcess. | 24 // passed in from StartSandboxedProcess. |
25 // |handle| is the processID of the child process as originated in Java. | 25 // |handle| is the processID of the child process as originated in Java, 0 if |
| 26 // the SandboxedProcess could not be created. |
26 static void OnSandboxedProcessStarted(JNIEnv*, | 27 static void OnSandboxedProcessStarted(JNIEnv*, |
27 jclass, | 28 jclass, |
28 jint client_context, | 29 jint client_context, |
29 jint handle) { | 30 jint handle) { |
30 StartSandboxedProcessCallback* callback = | 31 StartSandboxedProcessCallback* callback = |
31 reinterpret_cast<StartSandboxedProcessCallback*>(client_context); | 32 reinterpret_cast<StartSandboxedProcessCallback*>(client_context); |
32 callback->Run(static_cast<base::ProcessHandle>(handle)); | 33 if (handle) |
| 34 callback->Run(static_cast<base::ProcessHandle>(handle)); |
33 delete callback; | 35 delete callback; |
34 } | 36 } |
35 | 37 |
36 void StartSandboxedProcess( | 38 void StartSandboxedProcess( |
37 const CommandLine::StringVector& argv, | 39 const CommandLine::StringVector& argv, |
38 int ipc_fd, | 40 int ipc_fd, |
39 const GlobalDescriptors::Mapping& files_to_register, | 41 const GlobalDescriptors::Mapping& files_to_register, |
40 const StartSandboxedProcessCallback& callback) { | 42 const StartSandboxedProcessCallback& callback) { |
41 JNIEnv* env = AttachCurrentThread(); | 43 JNIEnv* env = AttachCurrentThread(); |
42 DCHECK(env); | 44 DCHECK(env); |
(...skipping 25 matching lines...) Expand all Loading... |
68 JNIEnv* env = AttachCurrentThread(); | 70 JNIEnv* env = AttachCurrentThread(); |
69 DCHECK(env); | 71 DCHECK(env); |
70 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle)); | 72 Java_SandboxedProcessLauncher_stop(env, static_cast<jint>(handle)); |
71 } | 73 } |
72 | 74 |
73 bool RegisterSandboxedProcessLauncher(JNIEnv* env) { | 75 bool RegisterSandboxedProcessLauncher(JNIEnv* env) { |
74 return RegisterNativesImpl(env); | 76 return RegisterNativesImpl(env); |
75 } | 77 } |
76 | 78 |
77 } // namespace content | 79 } // namespace content |
OLD | NEW |