| 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/child_process_launcher_android.h" | 5 #include "content/browser/android/child_process_launcher_android.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" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } // anonymous namespace | 63 } // anonymous namespace |
| 64 | 64 |
| 65 // Called from ChildProcessLauncher.java when the ChildProcess was | 65 // Called from ChildProcessLauncher.java when the ChildProcess was |
| 66 // started. | 66 // started. |
| 67 // |client_context| is the pointer to StartChildProcessCallback which was | 67 // |client_context| is the pointer to StartChildProcessCallback which was |
| 68 // passed in from StartChildProcess. | 68 // passed in from StartChildProcess. |
| 69 // |handle| is the processID of the child process as originated in Java, 0 if | 69 // |handle| is the processID of the child process as originated in Java, 0 if |
| 70 // the ChildProcess could not be created. | 70 // the ChildProcess could not be created. |
| 71 static void OnChildProcessStarted(JNIEnv*, | 71 static void OnChildProcessStarted(JNIEnv*, |
| 72 jclass, | 72 jclass, |
| 73 jint client_context, | 73 jlong client_context, |
| 74 jint handle) { | 74 jint handle) { |
| 75 StartChildProcessCallback* callback = | 75 StartChildProcessCallback* callback = |
| 76 reinterpret_cast<StartChildProcessCallback*>(client_context); | 76 reinterpret_cast<StartChildProcessCallback*>(client_context); |
| 77 if (handle) | 77 if (handle) |
| 78 callback->Run(static_cast<base::ProcessHandle>(handle)); | 78 callback->Run(static_cast<base::ProcessHandle>(handle)); |
| 79 delete callback; | 79 delete callback; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void StartChildProcess( | 82 void StartChildProcess( |
| 83 const CommandLine::StringVector& argv, | 83 const CommandLine::StringVector& argv, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); | 115 env->ReleaseIntArrayElements(j_file_ids.obj(), file_ids, 0); |
| 116 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); | 116 env->ReleaseIntArrayElements(j_file_fds.obj(), file_fds, 0); |
| 117 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); | 117 env->ReleaseBooleanArrayElements(j_file_auto_close.obj(), file_auto_close, 0); |
| 118 | 118 |
| 119 Java_ChildProcessLauncher_start(env, | 119 Java_ChildProcessLauncher_start(env, |
| 120 base::android::GetApplicationContext(), | 120 base::android::GetApplicationContext(), |
| 121 j_argv.obj(), | 121 j_argv.obj(), |
| 122 j_file_ids.obj(), | 122 j_file_ids.obj(), |
| 123 j_file_fds.obj(), | 123 j_file_fds.obj(), |
| 124 j_file_auto_close.obj(), | 124 j_file_auto_close.obj(), |
| 125 reinterpret_cast<jint>(new StartChildProcessCallback(callback))); | 125 reinterpret_cast<intptr_t>(new StartChildProcessCallback(callback))); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void StopChildProcess(base::ProcessHandle handle) { | 128 void StopChildProcess(base::ProcessHandle handle) { |
| 129 JNIEnv* env = AttachCurrentThread(); | 129 JNIEnv* env = AttachCurrentThread(); |
| 130 DCHECK(env); | 130 DCHECK(env); |
| 131 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); | 131 Java_ChildProcessLauncher_stop(env, static_cast<jint>(handle)); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool IsChildProcessOomProtected(base::ProcessHandle handle) { | 134 bool IsChildProcessOomProtected(base::ProcessHandle handle) { |
| 135 JNIEnv* env = AttachCurrentThread(); | 135 JNIEnv* env = AttachCurrentThread(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 161 | 161 |
| 162 jboolean IsSingleProcess(JNIEnv* env, jclass clazz) { | 162 jboolean IsSingleProcess(JNIEnv* env, jclass clazz) { |
| 163 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 163 return CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
| 164 } | 164 } |
| 165 | 165 |
| 166 bool RegisterChildProcessLauncher(JNIEnv* env) { | 166 bool RegisterChildProcessLauncher(JNIEnv* env) { |
| 167 return RegisterNativesImpl(env); | 167 return RegisterNativesImpl(env); |
| 168 } | 168 } |
| 169 | 169 |
| 170 } // namespace content | 170 } // namespace content |
| OLD | NEW |