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

Side by Side Diff: content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java

Issue 2882823002: Moving some CPL logic to CPLH. (Closed)
Patch Set: Fixed warm-up and tests. Created 3 years, 7 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 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 package org.chromium.content_shell_apk; 5 package org.chromium.content_shell_apk;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 8
9 import org.chromium.base.process_launcher.ChildProcessCreationParams; 9 import org.chromium.base.process_launcher.ChildProcessCreationParams;
10 import org.chromium.base.process_launcher.FileDescriptorInfo; 10 import org.chromium.base.process_launcher.FileDescriptorInfo;
11 import org.chromium.base.process_launcher.IChildProcessService; 11 import org.chromium.base.process_launcher.IChildProcessService;
12 import org.chromium.content.browser.ChildProcessConnection; 12 import org.chromium.content.browser.ChildProcessConnection;
13 import org.chromium.content.browser.ChildProcessLauncher; 13 import org.chromium.content.browser.ChildProcessLauncherHelper;
14 import org.chromium.content.browser.LauncherThread; 14 import org.chromium.content.browser.LauncherThread;
15 15
16 import java.util.concurrent.Callable; 16 import java.util.concurrent.Callable;
17 import java.util.concurrent.FutureTask; 17 import java.util.concurrent.FutureTask;
18 import java.util.concurrent.Semaphore; 18 import java.util.concurrent.Semaphore;
19 19
20 /** An assortment of static methods used in tests that deal with launching child processes. */ 20 /** An assortment of static methods used in tests that deal with launching child processes. */
21 public final class ChildProcessLauncherTestUtils { 21 public final class ChildProcessLauncherTestUtils {
22 // Do not instanciate, use static methods instead. 22 // Do not instanciate, use static methods instead.
23 private ChildProcessLauncherTestUtils() {} 23 private ChildProcessLauncherTestUtils() {}
(...skipping 24 matching lines...) Expand all
48 } 48 }
49 try { 49 try {
50 FutureTask<R> task = new FutureTask<R>(callable); 50 FutureTask<R> task = new FutureTask<R>(callable);
51 LauncherThread.post(task); 51 LauncherThread.post(task);
52 return task.get(); 52 return task.get();
53 } catch (Exception e) { 53 } catch (Exception e) {
54 throw new RuntimeException(e); 54 throw new RuntimeException(e);
55 } 55 }
56 } 56 }
57 57
58 public static ChildProcessConnection startInternalForTesting(final Context c ontext, 58 public static ChildProcessLauncherHelper startForTesting(final Context conte xt,
59 final String[] commandLine, final FileDescriptorInfo[] filesToMap, 59 final String[] commandLine, final FileDescriptorInfo[] filesToBeMapp ed,
60 final ChildProcessCreationParams params) { 60 final ChildProcessCreationParams params) {
61 return runOnLauncherAndGetResult(new Callable<ChildProcessLauncherHelper >() {
62 @Override
63 public ChildProcessLauncherHelper call() {
64 return ChildProcessLauncherHelper.createAndStartForTesting(0L /* nativePointer */,
65 commandLine, filesToBeMapped, params, true /* inSandbox */,
66 false /* alwaysInForeground */);
67 }
68 });
69 }
70
71 public static ChildProcessConnection getConnection(
72 final ChildProcessLauncherHelper childProcessLauncher) {
61 return runOnLauncherAndGetResult(new Callable<ChildProcessConnection>() { 73 return runOnLauncherAndGetResult(new Callable<ChildProcessConnection>() {
62 @Override 74 @Override
63 public ChildProcessConnection call() { 75 public ChildProcessConnection call() {
64 return ChildProcessLauncher.startInternal(context, commandLine, filesToMap, 76 return childProcessLauncher.getChildProcessConnection();
65 null /* launchCallback */, null /* childProcessCallback */,
66 true /* inSandbox */, false /* alwaysInForeground */, pa rams);
67 } 77 }
68 }); 78 });
69 } 79 }
70 80
71 // Retrieves the PID of the passed in connection on the launcher thread as t o not assert. 81 // Retrieves the PID of the passed in connection on the launcher thread as t o not assert.
72 public static int getConnectionPid(final ChildProcessConnection connection) { 82 public static int getConnectionPid(final ChildProcessConnection connection) {
73 return runOnLauncherAndGetResult(new Callable<Integer>() { 83 return runOnLauncherAndGetResult(new Callable<Integer>() {
74 @Override 84 @Override
75 public Integer call() { 85 public Integer call() {
76 return connection.getPid(); 86 return connection.getPid();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 public static IChildProcessService getConnectionService( 123 public static IChildProcessService getConnectionService(
114 final ChildProcessConnection connection) { 124 final ChildProcessConnection connection) {
115 return runOnLauncherAndGetResult(new Callable<IChildProcessService>() { 125 return runOnLauncherAndGetResult(new Callable<IChildProcessService>() {
116 @Override 126 @Override
117 public IChildProcessService call() { 127 public IChildProcessService call() {
118 return connection.getService(); 128 return connection.getService();
119 } 129 }
120 }); 130 });
121 } 131 }
122 } 132 }
OLDNEW
« no previous file with comments | « content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestHelperService.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698