| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/child_process_launcher_helper_android.h" | 5 #include "content/browser/child_process_launcher_helper_android.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/android/apk_assets.h" | 9 #include "base/android/apk_assets.h" |
| 10 #include "base/android/context_utils.h" | 10 #include "base/android/context_utils.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 using base::android::ScopedJavaGlobalRef; | 27 using base::android::ScopedJavaGlobalRef; |
| 28 using base::android::ScopedJavaLocalRef; | 28 using base::android::ScopedJavaLocalRef; |
| 29 using base::android::ToJavaArrayOfStrings; | 29 using base::android::ToJavaArrayOfStrings; |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 namespace internal { | 32 namespace internal { |
| 33 namespace { | 33 namespace { |
| 34 | 34 |
| 35 // Stops a child process based on the handle returned from StartChildProcess. | 35 // Stops a child process based on the handle returned from StartChildProcess. |
| 36 void StopChildProcess(base::ProcessHandle handle) { | 36 void StopChildProcess(base::ProcessHandle handle) { |
| 37 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
| 37 JNIEnv* env = AttachCurrentThread(); | 38 JNIEnv* env = AttachCurrentThread(); |
| 38 DCHECK(env); | 39 DCHECK(env); |
| 39 Java_ChildProcessLauncherHelper_stop(env, static_cast<jint>(handle)); | 40 Java_ChildProcessLauncherHelper_stop(env, static_cast<jint>(handle)); |
| 40 } | 41 } |
| 41 | 42 |
| 42 } // namespace | 43 } // namespace |
| 43 | 44 |
| 44 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { | 45 void ChildProcessLauncherHelper::BeforeLaunchOnClientThread() { |
| 45 // Android only supports renderer, sandboxed utility and gpu. | 46 // Android only supports renderer, sandboxed utility and gpu. |
| 46 std::string process_type = | 47 std::string process_type = |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 if (Java_ChildProcessLauncherHelper_isOomProtected(AttachCurrentThread(), | 153 if (Java_ChildProcessLauncherHelper_isOomProtected(AttachCurrentThread(), |
| 153 java_peer_)) { | 154 java_peer_)) { |
| 154 return base::TERMINATION_STATUS_OOM_PROTECTED; | 155 return base::TERMINATION_STATUS_OOM_PROTECTED; |
| 155 } | 156 } |
| 156 return base::GetTerminationStatus(process.process.Handle(), exit_code); | 157 return base::GetTerminationStatus(process.process.Handle(), exit_code); |
| 157 } | 158 } |
| 158 | 159 |
| 159 // static | 160 // static |
| 160 bool ChildProcessLauncherHelper::TerminateProcess( | 161 bool ChildProcessLauncherHelper::TerminateProcess( |
| 161 const base::Process& process, int exit_code, bool wait) { | 162 const base::Process& process, int exit_code, bool wait) { |
| 162 StopChildProcess(process.Handle()); | 163 BrowserThread::PostTask(BrowserThread::PROCESS_LAUNCHER, FROM_HERE, |
| 164 base::Bind(&StopChildProcess, process.Handle())); |
| 163 return true; | 165 return true; |
| 164 } | 166 } |
| 165 | 167 |
| 166 // static | 168 // static |
| 167 void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( | 169 void ChildProcessLauncherHelper::ForceNormalProcessTerminationSync( |
| 168 ChildProcessLauncherHelper::Process process) { | 170 ChildProcessLauncherHelper::Process process) { |
| 169 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); | 171 DCHECK_CURRENTLY_ON(BrowserThread::PROCESS_LAUNCHER); |
| 170 VLOG(1) << "ChromeProcess: Stopping process with handle " | 172 VLOG(1) << "ChromeProcess: Stopping process with handle " |
| 171 << process.process.Handle(); | 173 << process.process.Handle(); |
| 172 StopChildProcess(process.process.Handle()); | 174 StopChildProcess(process.process.Handle()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 AttachCurrentThread())); | 247 AttachCurrentThread())); |
| 246 } | 248 } |
| 247 | 249 |
| 248 } // namespace internal | 250 } // namespace internal |
| 249 | 251 |
| 250 bool RegisterChildProcessLauncher(JNIEnv* env) { | 252 bool RegisterChildProcessLauncher(JNIEnv* env) { |
| 251 return internal::RegisterNativesImpl(env); | 253 return internal::RegisterNativesImpl(env); |
| 252 } | 254 } |
| 253 | 255 |
| 254 } // namespace content | 256 } // namespace content |
| OLD | NEW |