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

Side by Side Diff: components/cronet/android/api/src/org/chromium/net/CronetEngine.java

Issue 1665503002: [Cronet] Expose quic_user_agent_id and quic_prefer_aes config options. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync Created 4 years, 10 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
« no previous file with comments | « no previous file | components/cronet/android/api/src/org/chromium/net/UserAgent.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.support.annotation.IntDef; 8 import android.support.annotation.IntDef;
9 import android.support.annotation.Nullable; 9 import android.support.annotation.Nullable;
10 import android.util.Log; 10 import android.util.Log;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 // See setters below for verbose descriptions. 97 // See setters below for verbose descriptions.
98 private final Context mContext; 98 private final Context mContext;
99 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>(); 99 private final List<QuicHint> mQuicHints = new LinkedList<QuicHint>();
100 private final List<Pkp> mPkps = new LinkedList<Pkp>(); 100 private final List<Pkp> mPkps = new LinkedList<Pkp>();
101 private String mUserAgent; 101 private String mUserAgent;
102 private String mStoragePath; 102 private String mStoragePath;
103 private boolean mLegacyModeEnabled; 103 private boolean mLegacyModeEnabled;
104 private LibraryLoader mLibraryLoader; 104 private LibraryLoader mLibraryLoader;
105 private String mLibraryName; 105 private String mLibraryName;
106 private boolean mQuicEnabled; 106 private boolean mQuicEnabled;
107 private String mQuicUserAgentId;
107 private boolean mHttp2Enabled; 108 private boolean mHttp2Enabled;
108 private boolean mSdchEnabled; 109 private boolean mSdchEnabled;
109 private String mDataReductionProxyKey; 110 private String mDataReductionProxyKey;
110 private String mDataReductionProxyPrimaryProxy; 111 private String mDataReductionProxyPrimaryProxy;
111 private String mDataReductionProxyFallbackProxy; 112 private String mDataReductionProxyFallbackProxy;
112 private String mDataReductionProxySecureProxyCheckUrl; 113 private String mDataReductionProxySecureProxyCheckUrl;
113 private boolean mDisableCache; 114 private boolean mDisableCache;
114 private int mHttpCacheMode; 115 private int mHttpCacheMode;
115 private long mHttpCacheMaxSize; 116 private long mHttpCacheMaxSize;
116 private String mExperimentalOptions; 117 private String mExperimentalOptions;
117 private long mMockCertVerifier; 118 private long mMockCertVerifier;
118 119
119 /** 120 /**
120 * Default config enables SPDY, disables QUIC, SDCH and HTTP cache. 121 * Default config enables SPDY, disables QUIC, SDCH and HTTP cache.
121 * @param context Android {@link Context} for engine to use. 122 * @param context Android {@link Context} for engine to use.
122 */ 123 */
123 public Builder(Context context) { 124 public Builder(Context context) {
124 mContext = context; 125 mContext = context;
125 setLibraryName("cronet"); 126 setLibraryName("cronet");
126 enableLegacyMode(false); 127 enableLegacyMode(false);
127 enableQUIC(false); 128 enableQUIC(false);
128 enableHTTP2(true); 129 enableHTTP2(true);
129 enableSDCH(false); 130 enableSDCH(false);
130 enableHttpCache(HTTP_CACHE_DISABLED, 0); 131 enableHttpCache(HTTP_CACHE_DISABLED, 0);
131 } 132 }
132 133
133 /** 134 /**
134 * Constructs a User-Agent string including Cronet version, and 135 * Constructs a User-Agent string including application name and version ,
135 * application name and version. 136 * system build version, model and id, and Cronet version.
136 * 137 *
137 * @return User-Agent string. 138 * @return User-Agent string.
138 */ 139 */
139 public String getDefaultUserAgent() { 140 public String getDefaultUserAgent() {
140 return UserAgent.from(mContext); 141 return UserAgent.from(mContext);
141 } 142 }
142 143
143 /** 144 /**
144 * Overrides the User-Agent header for all requests. An explicitly 145 * Overrides the User-Agent header for all requests. An explicitly
145 * set User-Agent header (set using 146 * set User-Agent header (set using
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 public Builder enableQUIC(boolean value) { 248 public Builder enableQUIC(boolean value) {
248 mQuicEnabled = value; 249 mQuicEnabled = value;
249 return this; 250 return this;
250 } 251 }
251 252
252 boolean quicEnabled() { 253 boolean quicEnabled() {
253 return mQuicEnabled; 254 return mQuicEnabled;
254 } 255 }
255 256
256 /** 257 /**
258 * Constructs default QUIC User Agent Id string including application na me
259 * and Cronet version.
260 *
261 * @return QUIC User Agent ID string.
262 */
263 public String getDefaultQuicUserAgentId() {
xunjieli 2016/02/04 14:00:06 I feel that since we are in experimental stage her
264 return UserAgent.getQuicUserAgentIdFrom(mContext);
265 }
266
267 /**
268 * Overrides the UIC User Agent Id for all requests.
269 * @return the builder to facilitate chaining.
270 */
271 public Builder setQuicUserAgentId(String quicUserAgentId) {
272 mQuicUserAgentId = quicUserAgentId;
273 return this;
274 }
275
276 String getQuicUserAgentId() {
277 return mQuicUserAgentId;
278 }
279
280 /**
257 * Sets whether <a href="https://tools.ietf.org/html/rfc7540">HTTP/2</a> 281 * Sets whether <a href="https://tools.ietf.org/html/rfc7540">HTTP/2</a>
258 * protocol is enabled. Defaults to enabled. 282 * protocol is enabled. Defaults to enabled.
259 * @param value {@code true} to enable HTTP/2, {@code false} to disable. 283 * @param value {@code true} to enable HTTP/2, {@code false} to disable.
260 * @return the builder to facilitate chaining. 284 * @return the builder to facilitate chaining.
261 */ 285 */
262 public Builder enableHTTP2(boolean value) { 286 public Builder enableHTTP2(boolean value) {
263 mHttp2Enabled = value; 287 mHttp2Enabled = value;
264 return this; 288 return this;
265 } 289 }
266 290
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 * @param builder builder to used for creating the CronetEngine instance. 928 * @param builder builder to used for creating the CronetEngine instance.
905 * @return the created CronetEngine instance. 929 * @return the created CronetEngine instance.
906 * @deprecated Use {@link CronetEngine.Builder}. 930 * @deprecated Use {@link CronetEngine.Builder}.
907 */ 931 */
908 @Deprecated 932 @Deprecated
909 public static CronetEngine createContext(Builder builder) { 933 public static CronetEngine createContext(Builder builder) {
910 CronetEngine cronetEngine = null; 934 CronetEngine cronetEngine = null;
911 if (builder.getUserAgent() == null) { 935 if (builder.getUserAgent() == null) {
912 builder.setUserAgent(builder.getDefaultUserAgent()); 936 builder.setUserAgent(builder.getDefaultUserAgent());
913 } 937 }
938 if (builder.quicEnabled() && builder.getQuicUserAgentId() == null) {
939 builder.setQuicUserAgentId(builder.getQuicUserAgentId());
940 }
914 if (!builder.legacyMode()) { 941 if (!builder.legacyMode()) {
915 cronetEngine = createCronetEngine(builder); 942 cronetEngine = createCronetEngine(builder);
916 } 943 }
917 if (cronetEngine == null) { 944 if (cronetEngine == null) {
918 cronetEngine = new JavaCronetEngine(builder.getUserAgent()); 945 cronetEngine = new JavaCronetEngine(builder.getUserAgent());
919 } 946 }
920 Log.i(TAG, "Using network stack: " + cronetEngine.getVersionString()); 947 Log.i(TAG, "Using network stack: " + cronetEngine.getVersionString());
921 return cronetEngine; 948 return cronetEngine;
922 } 949 }
923 950
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 */ 1116 */
1090 @Deprecated 1117 @Deprecated
1091 public interface RequestFinishedListener { // TODO(klm): Add a convenience a bstract class. 1118 public interface RequestFinishedListener { // TODO(klm): Add a convenience a bstract class.
1092 /** 1119 /**
1093 * Invoked with request info. 1120 * Invoked with request info.
1094 * @param requestInfo {@link UrlRequestInfo} for finished request. 1121 * @param requestInfo {@link UrlRequestInfo} for finished request.
1095 */ 1122 */
1096 void onRequestFinished(UrlRequestInfo requestInfo); 1123 void onRequestFinished(UrlRequestInfo requestInfo);
1097 } 1124 }
1098 } 1125 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/android/api/src/org/chromium/net/UserAgent.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698