Chromium Code Reviews| 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.util.Log; | 8 import android.util.Log; |
| 9 | 9 |
| 10 import org.json.JSONArray; | 10 import org.json.JSONArray; |
| 11 import org.json.JSONException; | 11 import org.json.JSONException; |
| 12 import org.json.JSONObject; | 12 import org.json.JSONObject; |
| 13 | 13 |
| 14 import java.io.File; | 14 import java.io.File; |
| 15 import java.lang.reflect.Constructor; | 15 import java.lang.reflect.Constructor; |
| 16 import java.net.Proxy; | |
| 17 import java.net.URL; | |
| 18 import java.net.URLConnection; | |
| 19 import java.net.URLStreamHandlerFactory; | |
| 16 import java.util.concurrent.Executor; | 20 import java.util.concurrent.Executor; |
| 17 | 21 |
| 18 /** | 22 /** |
| 19 * An engine to process {@link UrlRequest}s, which uses the best HTTP stack | 23 * An engine to process {@link UrlRequest}s, which uses the best HTTP stack |
| 20 * available on the current platform. | 24 * available on the current platform. |
| 21 */ | 25 */ |
| 22 public abstract class CronetEngine { | 26 public abstract class CronetEngine { |
| 23 /** | 27 /** |
| 24 * A builder for {@link CronetEngine}s, which allows runtime configuration o f | 28 * A builder for {@link CronetEngine}s, which allows runtime configuration o f |
| 25 * {@code CronetEngine}. Configuration options are set on the builder and | 29 * {@code CronetEngine}. Configuration options are set on the builder and |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 160 * <a href="https://developer.chrome.com/multidevice/data-compression"> | 164 * <a href="https://developer.chrome.com/multidevice/data-compression"> |
| 161 * Data Reduction Proxy</a> configuration parameters with a primary | 165 * Data Reduction Proxy</a> configuration parameters with a primary |
| 162 * proxy name, fallback proxy name, and a secure proxy check URL. Proxie s | 166 * proxy name, fallback proxy name, and a secure proxy check URL. Proxie s |
| 163 * are specified as [scheme://]host[:port]. Used for testing. | 167 * are specified as [scheme://]host[:port]. Used for testing. |
| 164 * @param primaryProxy the primary data reduction proxy to use. | 168 * @param primaryProxy the primary data reduction proxy to use. |
| 165 * @param fallbackProxy a fallback data reduction proxy to use. | 169 * @param fallbackProxy a fallback data reduction proxy to use. |
| 166 * @param secureProxyCheckUrl a URL to fetch to determine if using a sec ure | 170 * @param secureProxyCheckUrl a URL to fetch to determine if using a sec ure |
| 167 * proxy is allowed. | 171 * proxy is allowed. |
| 168 * @return the builder to facilitate chaining. | 172 * @return the builder to facilitate chaining. |
| 169 * @hide | 173 * @hide |
| 174 * @deprecated Marked as deprecated because @hide doesn't properly hide but | |
| 175 * javadocs are built with nodeprecated="yes". | |
|
xunjieli
2015/10/02 15:49:06
This is a little hacky to use @deprecated to hide
pauljensen
2015/10/02 23:39:43
I looked into doclava before uploading this CL (se
| |
| 170 */ | 176 */ |
| 171 public Builder setDataReductionProxyOptions( | 177 public Builder setDataReductionProxyOptions( |
| 172 String primaryProxy, String fallbackProxy, String secureProxyChe ckUrl) { | 178 String primaryProxy, String fallbackProxy, String secureProxyChe ckUrl) { |
| 173 if (primaryProxy.isEmpty() || fallbackProxy.isEmpty() | 179 if (primaryProxy.isEmpty() || fallbackProxy.isEmpty() |
| 174 || secureProxyCheckUrl.isEmpty()) { | 180 || secureProxyCheckUrl.isEmpty()) { |
| 175 throw new IllegalArgumentException( | 181 throw new IllegalArgumentException( |
| 176 "Primary and fallback proxies and check url must be set" ); | 182 "Primary and fallback proxies and check url must be set" ); |
| 177 } | 183 } |
| 178 putString(CronetEngineBuilderList.DATA_REDUCTION_PRIMARY_PROXY, prim aryProxy); | 184 putString(CronetEngineBuilderList.DATA_REDUCTION_PRIMARY_PROXY, prim aryProxy); |
| 179 putString(CronetEngineBuilderList.DATA_REDUCTION_FALLBACK_PROXY, fal lbackProxy); | 185 putString(CronetEngineBuilderList.DATA_REDUCTION_FALLBACK_PROXY, fal lbackProxy); |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 */ | 440 */ |
| 435 public abstract void startNetLogToFile(String fileName, boolean logAll); | 441 public abstract void startNetLogToFile(String fileName, boolean logAll); |
| 436 | 442 |
| 437 /** | 443 /** |
| 438 * Stops NetLog logging and flushes file to disk. If a logging session is | 444 * Stops NetLog logging and flushes file to disk. If a logging session is |
| 439 * not in progress, this call is ignored. | 445 * not in progress, this call is ignored. |
| 440 */ | 446 */ |
| 441 public abstract void stopNetLog(); | 447 public abstract void stopNetLog(); |
| 442 | 448 |
| 443 /** | 449 /** |
| 450 * Establishes a new connection to the resource specified by the {@link URL} {@code url}. | |
| 451 * <p> | |
| 452 * <b>Note:</b> Cronet's {@link java.net.HttpURLConnection} implementation i s subject to certain | |
| 453 * limitations, see {@link #createURLStreamHandlerFactory} for details. | |
| 454 * | |
| 455 * @param url URL of resource to connect to. | |
| 456 * @return an {@link java.net.HttpURLConnection} instance implemented by thi s CronetEngine. | |
| 457 */ | |
| 458 public abstract URLConnection openConnection(URL url); | |
| 459 | |
| 460 /** | |
| 461 * Establishes a new connection to the resource specified by the {@link URL} {@code url} | |
| 462 * using the given proxy. | |
| 463 * <p> | |
| 464 * <b>Note:</b> Cronet's {@link java.net.HttpURLConnection} implementation i s subject to certain | |
| 465 * limitations, see {@link #createURLStreamHandlerFactory} for details. | |
| 466 * | |
| 467 * @param url URL of resource to connect to. | |
| 468 * @param proxy proxy to use when establishing connection. | |
| 469 * @return an {@link java.net.HttpURLConnection} instance implemented by thi s CronetEngine. | |
| 470 */ | |
| 471 public abstract URLConnection openConnection(URL url, Proxy proxy); | |
|
xunjieli
2015/10/02 15:49:06
Maybe add in the javadoc that this method is not i
pauljensen
2015/10/02 23:39:43
I hid it like I did setDataReductionProxyOptions()
| |
| 472 | |
| 473 /** | |
| 474 * Creates a {@link URLStreamHandlerFactory} to handle HTTP and HTTPS | |
| 475 * traffic. An instance of this class can be installed via | |
| 476 * {@link java.net.URL#setURLStreamHandlerFactory} thus using this CronetEng ine by default for | |
| 477 * all requests created via {@link java.net.URL#openConnection}. | |
| 478 * <p> | |
| 479 * Cronet does not use certain HTTP features provided via the system: | |
| 480 * <ul> | |
| 481 * <li>the HTTP cache installed via | |
| 482 * {@link android.net.http.HttpResponseCache#install(java.io.File, long) | |
| 483 * HttpResponseCache.install()}</li> | |
| 484 * <li>the HTTP authentication method installed via | |
| 485 * {@link java.net.Authenticator#setDefault}</li> | |
| 486 * <li>the HTTP cookie storage installed via {@link java.net.CookieHandler#s etDefault}</li> | |
| 487 * </ul> | |
| 488 * <p> | |
| 489 * While Cronet supports and encourages requests using the HTTPS protocol, | |
| 490 * Cronet does not provide support for the | |
| 491 * {@link javax.net.ssl.HttpsURLConnection} API. This lack of support also | |
| 492 * includes not using certain HTTPS features provided via the system: | |
| 493 * <ul> | |
| 494 * <li>the HTTPS hostname verifier installed via {@link | |
| 495 * javax.net.ssl.HttpsURLConnection#setDefaultHostnameVerifier(javax.net.s sl.HostnameVerifier) | |
| 496 * HttpsURLConnection.setDefaultHostnameVerifier()}</li> | |
| 497 * <li>the HTTPS socket factory installed via {@link | |
| 498 * javax.net.ssl.HttpsURLConnection#setDefaultSSLSocketFactory(javax.net.s sl.SSLSocketFactory) | |
| 499 * HttpsURLConnection.setDefaultSSLSocketFactory()}</li> | |
| 500 * </ul> | |
| 501 * | |
| 502 * @return an {@link java.net.URLStreamHandlerFactory} instance implemented by this | |
| 503 * CronetEngine. | |
| 504 */ | |
| 505 public abstract URLStreamHandlerFactory createURLStreamHandlerFactory(); | |
| 506 | |
| 507 /** | |
| 444 * Creates a {@link CronetEngine} with the given {@link Builder}. | 508 * Creates a {@link CronetEngine} with the given {@link Builder}. |
| 445 * @param context Android {@link Context}. | 509 * @param context Android {@link Context}. |
| 446 * @param config engine configuration. | 510 * @param config engine configuration. |
| 447 * @deprecated Use {@link CronetEngine.Builder}. | 511 * @deprecated Use {@link CronetEngine.Builder}. |
| 448 */ | 512 */ |
| 449 @Deprecated | 513 @Deprecated |
| 450 public static CronetEngine createContext(Builder config) { | 514 public static CronetEngine createContext(Builder config) { |
| 451 CronetEngine cronetEngine = null; | 515 CronetEngine cronetEngine = null; |
| 452 if (config.userAgent().isEmpty()) { | 516 if (config.userAgent().isEmpty()) { |
| 453 config.setUserAgent(UserAgent.from(config.getContext())); | 517 config.setUserAgent(UserAgent.from(config.getContext())); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 478 cronetEngine = possibleEngine; | 542 cronetEngine = possibleEngine; |
| 479 } | 543 } |
| 480 } catch (ClassNotFoundException e) { | 544 } catch (ClassNotFoundException e) { |
| 481 // Leave as null. | 545 // Leave as null. |
| 482 } catch (Exception e) { | 546 } catch (Exception e) { |
| 483 throw new IllegalStateException("Cannot instantiate: " + CRONET_URL_ REQUEST_CONTEXT, e); | 547 throw new IllegalStateException("Cannot instantiate: " + CRONET_URL_ REQUEST_CONTEXT, e); |
| 484 } | 548 } |
| 485 return cronetEngine; | 549 return cronetEngine; |
| 486 } | 550 } |
| 487 } | 551 } |
| OLD | NEW |