| OLD | NEW |
| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 mContext = context; | 124 mContext = context; |
| 125 setLibraryName("cronet"); | 125 setLibraryName("cronet"); |
| 126 enableLegacyMode(false); | 126 enableLegacyMode(false); |
| 127 enableQUIC(false); | 127 enableQUIC(false); |
| 128 enableHTTP2(true); | 128 enableHTTP2(true); |
| 129 enableSDCH(false); | 129 enableSDCH(false); |
| 130 enableHttpCache(HTTP_CACHE_DISABLED, 0); | 130 enableHttpCache(HTTP_CACHE_DISABLED, 0); |
| 131 } | 131 } |
| 132 | 132 |
| 133 /** | 133 /** |
| 134 * Constructs a User-Agent string including Cronet version, and | 134 * Constructs a User-Agent string including application name and version
, |
| 135 * application name and version. | 135 * system build version, model and id, and Cronet version. |
| 136 * | 136 * |
| 137 * @return User-Agent string. | 137 * @return User-Agent string. |
| 138 */ | 138 */ |
| 139 public String getDefaultUserAgent() { | 139 public String getDefaultUserAgent() { |
| 140 return UserAgent.from(mContext); | 140 return UserAgent.from(mContext); |
| 141 } | 141 } |
| 142 | 142 |
| 143 /** | 143 /** |
| 144 * Overrides the User-Agent header for all requests. An explicitly | 144 * Overrides the User-Agent header for all requests. An explicitly |
| 145 * set User-Agent header (set using | 145 * set User-Agent header (set using |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 void loadLibrary() { | 233 void loadLibrary() { |
| 234 if (mLibraryLoader == null) { | 234 if (mLibraryLoader == null) { |
| 235 System.loadLibrary(mLibraryName); | 235 System.loadLibrary(mLibraryName); |
| 236 } else { | 236 } else { |
| 237 mLibraryLoader.loadLibrary(mLibraryName); | 237 mLibraryLoader.loadLibrary(mLibraryName); |
| 238 } | 238 } |
| 239 } | 239 } |
| 240 | 240 |
| 241 /** | 241 /** |
| 242 * Sets whether <a href="https://www.chromium.org/quic">QUIC</a> protoco
l | 242 * Sets whether <a href="https://www.chromium.org/quic">QUIC</a> protoco
l |
| 243 * is enabled. Defaults to disabled. | 243 * is enabled. Defaults to disabled. If QUIC is enabled, then QUIC User
Agent Id |
| 244 * containing application name and Cronet version is sent to the server. |
| 244 * @param value {@code true} to enable QUIC, {@code false} to disable. | 245 * @param value {@code true} to enable QUIC, {@code false} to disable. |
| 245 * @return the builder to facilitate chaining. | 246 * @return the builder to facilitate chaining. |
| 246 */ | 247 */ |
| 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. Returns empty string if QUIC is not enabled. |
| 260 * |
| 261 * @return QUIC User Agent ID string. |
| 262 */ |
| 263 String getDefaultQuicUserAgentId() { |
| 264 return mQuicEnabled ? UserAgent.getQuicUserAgentIdFrom(mContext) : "
"; |
| 265 } |
| 266 |
| 267 /** |
| 257 * Sets whether <a href="https://tools.ietf.org/html/rfc7540">HTTP/2</a> | 268 * Sets whether <a href="https://tools.ietf.org/html/rfc7540">HTTP/2</a> |
| 258 * protocol is enabled. Defaults to enabled. | 269 * protocol is enabled. Defaults to enabled. |
| 259 * @param value {@code true} to enable HTTP/2, {@code false} to disable. | 270 * @param value {@code true} to enable HTTP/2, {@code false} to disable. |
| 260 * @return the builder to facilitate chaining. | 271 * @return the builder to facilitate chaining. |
| 261 */ | 272 */ |
| 262 public Builder enableHTTP2(boolean value) { | 273 public Builder enableHTTP2(boolean value) { |
| 263 mHttp2Enabled = value; | 274 mHttp2Enabled = value; |
| 264 return this; | 275 return this; |
| 265 } | 276 } |
| 266 | 277 |
| (...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 */ | 1100 */ |
| 1090 @Deprecated | 1101 @Deprecated |
| 1091 public interface RequestFinishedListener { // TODO(klm): Add a convenience a
bstract class. | 1102 public interface RequestFinishedListener { // TODO(klm): Add a convenience a
bstract class. |
| 1092 /** | 1103 /** |
| 1093 * Invoked with request info. | 1104 * Invoked with request info. |
| 1094 * @param requestInfo {@link UrlRequestInfo} for finished request. | 1105 * @param requestInfo {@link UrlRequestInfo} for finished request. |
| 1095 */ | 1106 */ |
| 1096 void onRequestFinished(UrlRequestInfo requestInfo); | 1107 void onRequestFinished(UrlRequestInfo requestInfo); |
| 1097 } | 1108 } |
| 1098 } | 1109 } |
| OLD | NEW |