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

Side by Side Diff: base/test/multiprocess_test_android.cc

Issue 2800833003: Revert of Android: Remove GetApplicationContext part 2 (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
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 "base/test/multiprocess_test.h" 5 #include "base/test/multiprocess_test.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/android/context_utils.h"
10 #include "base/android/jni_android.h" 11 #include "base/android/jni_android.h"
11 #include "base/android/jni_array.h" 12 #include "base/android/jni_array.h"
12 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
13 #include "base/base_switches.h" 14 #include "base/base_switches.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
16 #include "jni/MainReturnCodeResult_jni.h" 17 #include "jni/MainReturnCodeResult_jni.h"
17 #include "jni/MultiprocessTestClientLauncher_jni.h" 18 #include "jni/MultiprocessTestClientLauncher_jni.h"
18 19
19 namespace base { 20 namespace base {
(...skipping 26 matching lines...) Expand all
46 base::android::ToJavaIntArray(env, fd_fds)); 47 base::android::ToJavaIntArray(env, fd_fds));
47 48
48 CommandLine command_line(base_command_line); 49 CommandLine command_line(base_command_line);
49 if (!command_line.HasSwitch(switches::kTestChildProcess)) { 50 if (!command_line.HasSwitch(switches::kTestChildProcess)) {
50 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname); 51 command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
51 } 52 }
52 53
53 android::ScopedJavaLocalRef<jobjectArray> j_argv = 54 android::ScopedJavaLocalRef<jobjectArray> j_argv =
54 android::ToJavaArrayOfStrings(env, command_line.argv()); 55 android::ToJavaArrayOfStrings(env, command_line.argv());
55 jint pid = android::Java_MultiprocessTestClientLauncher_launchClient( 56 jint pid = android::Java_MultiprocessTestClientLauncher_launchClient(
56 env, j_argv, fds); 57 env, android::GetApplicationContext(), j_argv, fds);
57 58
58 SpawnChildResult result; 59 SpawnChildResult result;
59 result.process = Process(pid); 60 result.process = Process(pid);
60 return result; 61 return result;
61 } 62 }
62 63
63 bool WaitForMultiprocessTestChildExit(const Process& process, 64 bool WaitForMultiprocessTestChildExit(const Process& process,
64 TimeDelta timeout, 65 TimeDelta timeout,
65 int* exit_code) { 66 int* exit_code) {
66 JNIEnv* env = android::AttachCurrentThread(); 67 JNIEnv* env = android::AttachCurrentThread();
67 DCHECK(env); 68 DCHECK(env);
68 69
69 base::android::ScopedJavaLocalRef<jobject> result_code = 70 base::android::ScopedJavaLocalRef<jobject> result_code =
70 android::Java_MultiprocessTestClientLauncher_waitForMainToReturn( 71 android::Java_MultiprocessTestClientLauncher_waitForMainToReturn(
71 env, process.Pid(), static_cast<int32_t>(timeout.InMilliseconds())); 72 env, android::GetApplicationContext(), process.Pid(),
73 static_cast<int32_t>(timeout.InMilliseconds()));
72 if (result_code.is_null() || 74 if (result_code.is_null() ||
73 Java_MainReturnCodeResult_hasTimedOut(env, result_code)) { 75 Java_MainReturnCodeResult_hasTimedOut(env, result_code)) {
74 return false; 76 return false;
75 } 77 }
76 if (exit_code) { 78 if (exit_code) {
77 *exit_code = Java_MainReturnCodeResult_getReturnCode(env, result_code); 79 *exit_code = Java_MainReturnCodeResult_getReturnCode(env, result_code);
78 } 80 }
79 return true; 81 return true;
80 } 82 }
81 83
82 bool TerminateMultiProcessTestChild(const Process& process, 84 bool TerminateMultiProcessTestChild(const Process& process,
83 int exit_code, 85 int exit_code,
84 bool wait) { 86 bool wait) {
85 JNIEnv* env = android::AttachCurrentThread(); 87 JNIEnv* env = android::AttachCurrentThread();
86 DCHECK(env); 88 DCHECK(env);
87 89
88 return android::Java_MultiprocessTestClientLauncher_terminate( 90 return android::Java_MultiprocessTestClientLauncher_terminate(
89 env, process.Pid(), exit_code, wait); 91 env, android::GetApplicationContext(), process.Pid(), exit_code, wait);
90 } 92 }
91 93
92 } // namespace base 94 } // namespace base
OLDNEW
« no previous file with comments | « base/test/android/java/src/org/chromium/base/MultiprocessTestClientLauncher.java ('k') | base/test/test_file_util_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698