Chromium Code Reviews| 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.net; | 5 package org.chromium.net; |
| 6 | 6 |
| 7 import android.os.ConditionVariable; | |
| 8 | |
| 9 import org.chromium.base.annotations.CalledByNative; | |
| 7 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| 8 | 11 |
| 9 /** | 12 /** |
| 10 * Utilities for Cronet testing | 13 * Utilities for Cronet testing |
| 11 */ | 14 */ |
| 12 @JNINamespace("cronet") | 15 @JNINamespace("cronet") |
| 13 public class CronetTestUtil { | 16 public class CronetTestUtil { |
| 17 private static final ConditionVariable sHostResolverBlock = new ConditionVar iable(); | |
| 18 | |
| 14 /** | 19 /** |
| 15 * Start QUIC server on local host. | 20 * Registers customized DNS mapping for {@link NativeTestServer}. |
|
mef
2016/01/22 16:21:57
It is not only for NativeTestServer.
pauljensen
2016/01/25 02:47:48
Done.
| |
| 16 * @return non-zero QUIC server port number on success or 0 if failed. | 21 * @param contextAdapter native context adapter object that this |
| 22 * mapping should apply to. | |
| 23 * @param isLegacyAPI {@code true} if this context adapter is a part of the | |
| 24 * old API. | |
| 25 * @param destination host to map to (e.g. 127.0.0.1) | |
| 17 */ | 26 */ |
| 18 public static int startQuicServer() { | 27 public static void registerHostResolverProc( |
|
mef
2016/01/22 16:21:57
could it be better to have 2 separate registerHost
pauljensen
2016/01/25 02:47:48
Done.
| |
| 19 return nativeStartQuicServer(); | 28 long contextAdapter, boolean isLegacyAPI, String destination) { |
| 29 nativeRegisterHostResolverProc(contextAdapter, isLegacyAPI, destination) ; | |
| 30 sHostResolverBlock.block(); | |
| 31 sHostResolverBlock.close(); | |
| 20 } | 32 } |
| 21 | 33 |
| 22 private static native int nativeStartQuicServer(); | 34 @CalledByNative |
| 35 private static void onHostResolverProcRegistered() { | |
| 36 sHostResolverBlock.open(); | |
| 37 } | |
| 38 | |
| 39 private static native void nativeRegisterHostResolverProc( | |
| 40 long contextAdapter, boolean isLegacyAPI, String destination); | |
| 23 } | 41 } |
| OLD | NEW |