| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 package org.chromium.net; | 4 package org.chromium.net; |
| 5 | 5 |
| 6 import android.content.Context; | 6 import android.content.Context; |
| 7 import android.support.annotation.VisibleForTesting; | 7 import android.support.annotation.VisibleForTesting; |
| 8 | 8 |
| 9 import java.io.IOException; | 9 import java.io.IOException; |
| 10 import java.net.Proxy; | 10 import java.net.Proxy; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 * {@link Builder} to retrieve the application | 82 * {@link Builder} to retrieve the application |
| 83 * context. A reference to only the application | 83 * context. A reference to only the application |
| 84 * context will be kept, so as to avoid extending | 84 * context will be kept, so as to avoid extending |
| 85 * the lifetime of {@code context} unnecessarily. | 85 * the lifetime of {@code context} unnecessarily. |
| 86 */ | 86 */ |
| 87 public Builder(Context context) { | 87 public Builder(Context context) { |
| 88 super(context); | 88 super(context); |
| 89 } | 89 } |
| 90 | 90 |
| 91 /** | 91 /** |
| 92 * Constructs {@link Builder} with a given delegate that provides the ac
tual implementation |
| 93 * of the {@code Builder} methods. This constructor is used only by the
internal |
| 94 * implementation. |
| 95 * |
| 96 * @param builderDelegate delegate that provides the actual implementati
on. |
| 97 * |
| 98 * {@hide} |
| 99 */ |
| 100 public Builder(ICronetEngineBuilder builderDelegate) { |
| 101 super(builderDelegate); |
| 102 } |
| 103 |
| 104 /** |
| 92 * Enables the network quality estimator, which collects and reports | 105 * Enables the network quality estimator, which collects and reports |
| 93 * measurements of round trip time (RTT) and downstream throughput at | 106 * measurements of round trip time (RTT) and downstream throughput at |
| 94 * various layers of the network stack. After enabling the estimator, | 107 * various layers of the network stack. After enabling the estimator, |
| 95 * listeners of RTT and throughput can be added with | 108 * listeners of RTT and throughput can be added with |
| 96 * {@link #addRttListener} and {@link #addThroughputListener} and | 109 * {@link #addRttListener} and {@link #addThroughputListener} and |
| 97 * removed with {@link #removeRttListener} and | 110 * removed with {@link #removeRttListener} and |
| 98 * {@link #removeThroughputListener}. The estimator uses memory and CPU | 111 * {@link #removeThroughputListener}. The estimator uses memory and CPU |
| 99 * only when enabled. | 112 * only when enabled. |
| 100 * @param value {@code true} to enable network quality estimator, | 113 * @param value {@code true} to enable network quality estimator, |
| 101 * {@code false} to disable. | 114 * {@code false} to disable. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 131 * @return the builder to facilitate chaining. | 144 * @return the builder to facilitate chaining. |
| 132 */ | 145 */ |
| 133 public Builder setDataReductionProxyOptions( | 146 public Builder setDataReductionProxyOptions( |
| 134 String primaryProxy, String fallbackProxy, String secureProxyChe
ckUrl) { | 147 String primaryProxy, String fallbackProxy, String secureProxyChe
ckUrl) { |
| 135 mBuilderDelegate.setDataReductionProxyOptions( | 148 mBuilderDelegate.setDataReductionProxyOptions( |
| 136 primaryProxy, fallbackProxy, secureProxyCheckUrl); | 149 primaryProxy, fallbackProxy, secureProxyCheckUrl); |
| 137 return this; | 150 return this; |
| 138 } | 151 } |
| 139 | 152 |
| 140 /** | 153 /** |
| 141 * Sets whether the resulting {@link CronetEngine} uses an | |
| 142 * implementation based on the system's | |
| 143 * {@link java.net.HttpURLConnection} implementation, or if this is | |
| 144 * only done as a backup if the native implementation fails to load. | |
| 145 * Defaults to disabled. | |
| 146 * @param value {@code true} makes the resulting {@link CronetEngine} | |
| 147 * use an implementation based on the system's | |
| 148 * {@link java.net.HttpURLConnection} implementation | |
| 149 * without trying to load the native implementation. | |
| 150 * {@code false} makes the resulting {@code CronetEngine} | |
| 151 * use the native implementation, or if that fails to load, | |
| 152 * falls back to an implementation based on the system's | |
| 153 * {@link java.net.HttpURLConnection} implementation. | |
| 154 * @return the builder to facilitate chaining. | |
| 155 */ | |
| 156 public Builder enableLegacyMode(boolean value) { | |
| 157 mBuilderDelegate.enableLegacyMode(value); | |
| 158 return this; | |
| 159 } | |
| 160 | |
| 161 /** | |
| 162 * Enables | 154 * Enables |
| 163 * <a href="https://developer.chrome.com/multidevice/data-compression">D
ata | 155 * <a href="https://developer.chrome.com/multidevice/data-compression">D
ata |
| 164 * Reduction Proxy</a>. Defaults to disabled. | 156 * Reduction Proxy</a>. Defaults to disabled. |
| 165 * @param key key to use when authenticating with the proxy. | 157 * @param key key to use when authenticating with the proxy. |
| 166 * @return the builder to facilitate chaining. | 158 * @return the builder to facilitate chaining. |
| 167 */ | 159 */ |
| 168 public Builder enableDataReductionProxy(String key) { | 160 public Builder enableDataReductionProxy(String key) { |
| 169 mBuilderDelegate.enableDataReductionProxy(key); | 161 mBuilderDelegate.enableDataReductionProxy(key); |
| 170 return this; | 162 return this; |
| 171 } | 163 } |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 * {@link #CONNECTION_METRIC_UNKNOWN} if the value is | 435 * {@link #CONNECTION_METRIC_UNKNOWN} if the value is |
| 444 * unavailable. This must be called after | 436 * unavailable. This must be called after |
| 445 * {@link Builder#enableNetworkQualityEstimator}, and will | 437 * {@link Builder#enableNetworkQualityEstimator}, and will |
| 446 * throw an exception otherwise. | 438 * throw an exception otherwise. |
| 447 * @return Estimate of the downstream throughput in kilobits per second. | 439 * @return Estimate of the downstream throughput in kilobits per second. |
| 448 */ | 440 */ |
| 449 public int getDownstreamThroughputKbps() { | 441 public int getDownstreamThroughputKbps() { |
| 450 return CONNECTION_METRIC_UNKNOWN; | 442 return CONNECTION_METRIC_UNKNOWN; |
| 451 } | 443 } |
| 452 } | 444 } |
| OLD | NEW |