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

Unified Diff: components/cronet/android/java/src/org/chromium/net/HttpUrlRequestFactoryConfig.java

Issue 544223003: Add SetSupportsQuic method to explicitly specify server that supports QUIC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
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() {

Powered by Google App Engine
This is Rietveld 408576698