Chromium Code Reviews| Index: components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java |
| diff --git a/components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java b/components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java |
| index 745d10a57f978f05e834e8a590502ebf634bb096..512264d52d73994246e1adff2c5640fa91f29d9d 100644 |
| --- a/components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java |
| +++ b/components/cronet/android/test/src/org/chromium/net/CronetTestUtil.java |
| @@ -4,6 +4,9 @@ |
| package org.chromium.net; |
| +import android.os.ConditionVariable; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.base.annotations.JNINamespace; |
| /** |
| @@ -11,13 +14,45 @@ import org.chromium.base.annotations.JNINamespace; |
| */ |
| @JNINamespace("cronet") |
| public class CronetTestUtil { |
| + private static final ConditionVariable sHostResolverBlock = new ConditionVariable(); |
| + |
| + /** |
| + * Registers customized DNS mapping for testing host names used by test servers. |
|
mef
2016/01/26 21:45:03
I think we should specify fake host names as stati
pauljensen
2016/01/29 17:10:09
They can be accessed via other APIs; I've listed t
|
| + * @param cronetEngine {@link CronetEngine} that this mapping should apply to. |
| + * @param isLegacyAPI {@code true} if this context adapter is a part of the |
|
mef
2016/01/26 21:45:03
obsolete @param.
pauljensen
2016/01/29 17:10:09
Done.
|
| + * old API. |
| + * @param destination host to map to (e.g. 127.0.0.1) |
| + */ |
| + public static void registerHostResolverProc(CronetEngine cronetEngine, String destination) { |
| + long contextAdapter = |
| + ((CronetUrlRequestContext) cronetEngine).getUrlRequestContextAdapter(); |
| + nativeRegisterHostResolverProc(contextAdapter, false, destination); |
| + sHostResolverBlock.block(); |
| + sHostResolverBlock.close(); |
| + } |
| + |
| /** |
| - * Start QUIC server on local host. |
| - * @return non-zero QUIC server port number on success or 0 if failed. |
| + * Registers customized DNS mapping for testing host names used by test servers. |
| + * @param requestFactory {@link HttpUrlRequestFactory} that this mapping should apply to. |
| + * @param isLegacyAPI {@code true} if this context adapter is a part of the |
|
mef
2016/01/26 21:45:03
obsolete @param.
pauljensen
2016/01/29 17:10:09
Done.
|
| + * old API. |
| + * @param destination host to map to (e.g. 127.0.0.1) |
| */ |
| - public static int startQuicServer() { |
| - return nativeStartQuicServer(); |
| + public static void registerHostResolverProc( |
| + HttpUrlRequestFactory requestFactory, String destination) { |
| + long contextAdapter = ((ChromiumUrlRequestFactory) requestFactory) |
| + .getRequestContext() |
| + .getUrlRequestContextAdapter(); |
| + nativeRegisterHostResolverProc(contextAdapter, true, destination); |
| + sHostResolverBlock.block(); |
| + sHostResolverBlock.close(); |
| + } |
| + |
| + @CalledByNative |
| + private static void onHostResolverProcRegistered() { |
| + sHostResolverBlock.open(); |
| } |
| - private static native int nativeStartQuicServer(); |
| + private static native void nativeRegisterHostResolverProc( |
| + long contextAdapter, boolean isLegacyAPI, String destination); |
| } |