OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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; | 5 package org.chromium.content_shell; |
6 | 6 |
7 import org.chromium.base.annotations.CalledByNative; | 7 import org.chromium.base.annotations.CalledByNative; |
8 import org.chromium.base.annotations.JNINamespace; | 8 import org.chromium.base.annotations.JNINamespace; |
9 import org.chromium.content.browser.ServiceRegistry; | 9 import org.chromium.content.browser.InterfaceProvider; |
| 10 import org.chromium.content.browser.InterfaceRegistry; |
10 import org.chromium.mojo.system.Pair; | 11 import org.chromium.mojo.system.Pair; |
11 | 12 |
12 /** | 13 /** |
13 * Test hooks for Mojo service support in the browser. See http://crbug.com/4159
45. | 14 * Test hooks for shell InterfaceRegistry/Provider support in the browser. |
| 15 * See http://crbug.com/415945. |
14 */ | 16 */ |
15 @JNINamespace("content") | 17 @JNINamespace("content") |
16 public class ShellMojoTestUtils { | 18 public class ShellMojoTestUtils { |
17 public static long setupTestEnvironment() { | 19 public static long setupTestEnvironment() { |
18 return nativeSetupTestEnvironment(); | 20 return nativeSetupTestEnvironment(); |
19 } | 21 } |
20 | 22 |
21 public static void tearDownTestEnvironment(long testEnvironment) { | 23 public static void tearDownTestEnvironment(long testEnvironment) { |
22 nativeTearDownTestEnvironment(testEnvironment); | 24 nativeTearDownTestEnvironment(testEnvironment); |
23 } | 25 } |
24 | 26 |
25 /** | 27 /** |
26 * Yields two ServiceRegistries bound to each other. | 28 * Returns an InterfaceRegistry and an InterfaceProvider bound to it. |
27 */ | 29 */ |
28 public static Pair<ServiceRegistry, ServiceRegistry> createServiceRegistryPa
ir( | 30 public static Pair<InterfaceRegistry, InterfaceProvider> createInterfaceRegi
stryAndProvider( |
29 long testEnvironment) { | 31 long testEnvironment) { |
30 // Declaring parametrized return type for nativeCreateServiceRegistryPai
r() breaks the JNI | 32 // Declaring parametrized return type for nativeCreateInterfaceRegistryA
ndProvider() breaks |
31 // generator. TODO(ppi): support parametrized return types in the JNI ge
nerator. | 33 // the JNI generator. TODO(ppi): support parametrized return types in th
e JNI generator. |
32 @SuppressWarnings("unchecked") | 34 @SuppressWarnings("unchecked") |
33 Pair<ServiceRegistry, ServiceRegistry> pair = | 35 Pair<InterfaceRegistry, InterfaceProvider> pair = |
34 nativeCreateServiceRegistryPair(testEnvironment); | 36 nativeCreateInterfaceRegistryAndProvider(testEnvironment); |
35 return pair; | 37 return pair; |
36 } | 38 } |
37 | 39 |
38 public static void runLoop(long timeoutMs) { | 40 public static void runLoop(long timeoutMs) { |
39 nativeRunLoop(timeoutMs); | 41 nativeRunLoop(timeoutMs); |
40 } | 42 } |
41 | 43 |
42 @CalledByNative | 44 @CalledByNative |
43 public static Pair makePair(ServiceRegistry serviceRegistryA, | 45 public static Pair makePair(InterfaceRegistry registry, InterfaceProvider pr
ovider) { |
44 ServiceRegistry serviceRegistryB) { | 46 return new Pair<InterfaceRegistry, InterfaceProvider>(registry, provider
); |
45 return new Pair<ServiceRegistry, ServiceRegistry>(serviceRegistryA, serv
iceRegistryB); | |
46 } | 47 } |
47 | 48 |
48 private static native long nativeSetupTestEnvironment(); | 49 private static native long nativeSetupTestEnvironment(); |
49 private static native void nativeTearDownTestEnvironment(long testEnvironmen
t); | 50 private static native void nativeTearDownTestEnvironment(long testEnvironmen
t); |
50 private static native Pair nativeCreateServiceRegistryPair(long testEnvironm
ent); | 51 private static native Pair nativeCreateInterfaceRegistryAndProvider(long tes
tEnvironment); |
51 private static native void nativeRunLoop(long timeoutMs); | 52 private static native void nativeRunLoop(long timeoutMs); |
52 } | 53 } |
OLD | NEW |