Index: components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java |
diff --git a/components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java b/components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java |
index 913bae8585e2037268fbb02a54e9bdb6fd285244..09bfbfd6b2f13d2676ff75234100fc91df7f1121 100644 |
--- a/components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java |
+++ b/components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java |
@@ -4,6 +4,7 @@ |
package org.chromium.net; |
+import org.json.JSONArray; |
import org.json.JSONException; |
import org.json.JSONObject; |
@@ -86,6 +87,37 @@ public class HttpUrlRequestFactoryConfig { |
} |
/** |
+ * Explicitly mark |host| as supporting QUIC. |
+ * Note that enableHttpCache(DISK) is needed to take advantage of 0-RTT |
+ * connection establishment between sessions. |
+ * |
+ * @param host of the server that supports QUIC. |
+ * @param port of the server that supports QUIC. |
+ * @param alternatePort to use for QUIC. |
+ */ |
+ public HttpUrlRequestFactoryConfig addQuicHint(String host, |
+ int port, |
+ int alternatePort) { |
+ try { |
+ JSONArray quicHints = mConfig.optJSONArray( |
+ UrlRequestContextConfig.QUIC_HINTS); |
+ if (quicHints == null) { |
+ quicHints = new JSONArray(); |
+ mConfig.put(UrlRequestContextConfig.QUIC_HINTS, quicHints); |
+ } |
+ |
+ JSONObject hint = new JSONObject(); |
+ hint.put(UrlRequestContextConfig.QUIC_HINT_HOST, host); |
+ hint.put(UrlRequestContextConfig.QUIC_HINT_PORT, port); |
+ hint.put(UrlRequestContextConfig.QUIC_HINT_ALT_PORT, alternatePort); |
+ quicHints.put(hint); |
+ } catch (JSONException e) { |
+ ; |
+ } |
+ return this; |
+ } |
+ |
+ /** |
* Get JSON string representation of the config. |
*/ |
public String toString() { |