Index: content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java |
diff --git a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java |
index 7884711d80e6fa5e8f52cba0252bce8ceef59956..807e77ce0e7f1895e542a436923d365d26ce2d75 100644 |
--- a/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java |
+++ b/content/shell/android/shell_apk/src/org/chromium/content_shell_apk/ChildProcessLauncherTestUtils.java |
@@ -79,13 +79,33 @@ public final class ChildProcessLauncherTestUtils { |
}); |
} |
+ // Retrieves the service number of the passed in connection from its service name, or -1 if the |
+ // service number could not be determined. |
+ public static int getConnectionServiceNumber(final BaseChildProcessConnection connection) { |
+ String serviceName = getConnectionServiceName(connection); |
+ // The service name ends up with the service number. |
+ StringBuilder numberString = new StringBuilder(); |
+ for (int i = serviceName.length() - 1; i >= 0; i--) { |
+ char c = serviceName.charAt(i); |
+ if (!Character.isDigit(c)) { |
+ break; |
+ } |
+ numberString.append(c); |
+ } |
+ try { |
+ return Integer.decode(numberString.toString()); |
+ } catch (NumberFormatException nfe) { |
+ return -1; |
+ } |
+ } |
+ |
// Retrieves the service number of the passed in connection on the launcher thread as to not |
// assert. |
- public static int getConnectionServiceNumber(final BaseChildProcessConnection connection) { |
- return runOnLauncherAndGetResult(new Callable<Integer>() { |
+ public static String getConnectionServiceName(final BaseChildProcessConnection connection) { |
+ return runOnLauncherAndGetResult(new Callable<String>() { |
@Override |
- public Integer call() { |
- return connection.getServiceNumber(); |
+ public String call() { |
+ return connection.getServiceName().getClassName(); |
} |
}); |
} |