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

Side by Side Diff: components/cronet/android/test/src/org/chromium/net/NativeTestServer.java

Issue 1085903002: Enable Sdch in Cronet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 5 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 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.content.Context; 7 import android.content.Context;
8 import android.os.ConditionVariable;
8 9
10 import org.chromium.base.CalledByNative;
9 import org.chromium.base.JNINamespace; 11 import org.chromium.base.JNINamespace;
10 12
11 /** 13 /**
12 * Wrapper class to start an in-process native test server, and get URLs 14 * Wrapper class to start an in-process native test server, and get URLs
13 * needed to talk to it. 15 * needed to talk to it.
14 */ 16 */
15 @JNINamespace("cronet") 17 @JNINamespace("cronet")
16 public final class NativeTestServer { 18 public final class NativeTestServer {
19 private static final ConditionVariable sHostResolverBlock = new ConditionVar iable();
20
17 public static boolean startNativeTestServer(Context context) { 21 public static boolean startNativeTestServer(Context context) {
18 return nativeStartNativeTestServer( 22 return nativeStartNativeTestServer(
19 TestFilesInstaller.getInstalledPath(context)); 23 TestFilesInstaller.getInstalledPath(context));
20 } 24 }
21 25
22 public static void shutdownNativeTestServer() { 26 public static void shutdownNativeTestServer() {
23 nativeShutdownNativeTestServer(); 27 nativeShutdownNativeTestServer();
24 } 28 }
25 29
30 /**
31 * Registers customized DNS mapping for {@link NativeTestServer}.
32 * @param contextAdapter native context adapter object that this
33 * mapping should apply to.
34 * @param isLegacyAPI {@code true} if this context adapter is a part of the
35 * old API.
36 */
37 public static void registerHostResolverProc(long contextAdapter, boolean isL egacyAPI) {
38 sHostResolverBlock.close();
39 nativeRegisterHostResolverProc(contextAdapter, isLegacyAPI);
40 sHostResolverBlock.block();
41 }
42
26 public static String getEchoBodyURL() { 43 public static String getEchoBodyURL() {
27 return nativeGetEchoBodyURL(); 44 return nativeGetEchoBodyURL();
28 } 45 }
29 46
30 public static String getEchoHeaderURL(String header) { 47 public static String getEchoHeaderURL(String header) {
31 return nativeGetEchoHeaderURL(header); 48 return nativeGetEchoHeaderURL(header);
32 } 49 }
33 50
34 public static String getEchoAllHeadersURL() { 51 public static String getEchoAllHeadersURL() {
35 return nativeGetEchoAllHeadersURL(); 52 return nativeGetEchoAllHeadersURL();
36 } 53 }
37 54
38 public static String getEchoMethodURL() { 55 public static String getEchoMethodURL() {
39 return nativeGetEchoMethodURL(); 56 return nativeGetEchoMethodURL();
40 } 57 }
41 58
42 public static String getRedirectToEchoBody() { 59 public static String getRedirectToEchoBody() {
43 return nativeGetRedirectToEchoBody(); 60 return nativeGetRedirectToEchoBody();
44 } 61 }
45 62
46 public static String getFileURL(String filePath) { 63 public static String getFileURL(String filePath) {
47 return nativeGetFileURL(filePath); 64 return nativeGetFileURL(filePath);
48 } 65 }
49 66
67 public static String getSdchURL() {
68 return nativeGetSdchURL();
69 }
70
71 @CalledByNative
72 private static void onHostResolverProcRegistered() {
73 sHostResolverBlock.open();
74 }
75
50 private static native boolean nativeStartNativeTestServer(String filePath); 76 private static native boolean nativeStartNativeTestServer(String filePath);
51 private static native void nativeShutdownNativeTestServer(); 77 private static native void nativeShutdownNativeTestServer();
78 private static native void nativeRegisterHostResolverProc(
79 long contextAdapter, boolean isLegacyAPI);
52 private static native String nativeGetEchoBodyURL(); 80 private static native String nativeGetEchoBodyURL();
53 private static native String nativeGetEchoHeaderURL(String header); 81 private static native String nativeGetEchoHeaderURL(String header);
54 private static native String nativeGetEchoAllHeadersURL(); 82 private static native String nativeGetEchoAllHeadersURL();
55 private static native String nativeGetEchoMethodURL(); 83 private static native String nativeGetEchoMethodURL();
56 private static native String nativeGetRedirectToEchoBody(); 84 private static native String nativeGetRedirectToEchoBody();
57 private static native String nativeGetFileURL(String filePath); 85 private static native String nativeGetFileURL(String filePath);
86 private static native String nativeGetSdchURL();
58 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698