public abstract class**CronetEngine** extends Object  
An engine to process[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)s, which uses the best HTTP stack available on the current platform. An instance of this class can be created using[CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html).  

### Nested Class Summary

|-------|---|---|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| class | [CronetEngine.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html) || A builder for[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)s, which allows runtime configuration of`CronetEngine`. |

### Constant Summary

|-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| int | [ACTIVE_REQUEST_COUNT_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#ACTIVE_REQUEST_COUNT_UNKNOWN)           | The value of the active request count is unknown          |
| int | [CONNECTION_METRIC_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#CONNECTION_METRIC_UNKNOWN)                 | The value of a connection metric is unknown.              |
| int | [EFFECTIVE_CONNECTION_TYPE_2G](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_2G)           | The estimate of the effective connection type is 2G.      |
| int | [EFFECTIVE_CONNECTION_TYPE_3G](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_3G)           | The estimate of the effective connection type is 3G.      |
| int | [EFFECTIVE_CONNECTION_TYPE_4G](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_4G)           | The estimate of the effective connection type is 4G.      |
| int | [EFFECTIVE_CONNECTION_TYPE_OFFLINE](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_OFFLINE) | The device is offline.                                    |
| int | [EFFECTIVE_CONNECTION_TYPE_SLOW_2G](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_SLOW_2G) | The estimate of the effective connection type is slow 2G. |
| int | [EFFECTIVE_CONNECTION_TYPE_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_UNKNOWN) | The estimate of the effective connection type is unknown. |

### Public Constructor Summary

|---|-----------------------------------------------------------------------------------------------------------------------------------------|
|   | [CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#CronetEngine())() |

### Public Method Summary

|--------------------------------------------------------------------------------------------------------------------------------------------| |
| void                                                                                                                                       | [addRequestFinishedListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addRequestFinishedListener(org.chromium.net.RequestFinishedInfo.Listener))([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener) Registers a listener that gets called after the end of each request with the request info.                                                                                                                                                               |
| void                                                                                                                                       | [addRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addRttListener(org.chromium.net.NetworkQualityRttListener))([NetworkQualityRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityRttListener.html)listener) Registers a listener that gets called whenever the network quality estimator witnesses a sample round trip time.                                                                                                                                                                          |
| void                                                                                                                                       | [addThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addThroughputListener(org.chromium.net.NetworkQualityThroughputListener))([NetworkQualityThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityThroughputListener.html)listener) Registers a listener that gets called whenever the network quality estimator witnesses a sample throughput measurement.                                                                                                                                |
| void                                                                                                                                       | [configureNetworkQualityEstimatorForTesting](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#configureNetworkQualityEstimatorForTesting(boolean,%20boolean,%20boolean))(boolean useLocalHostRequests, boolean useSmallerResponses, boolean disableOfflineCheck) Configures the network quality estimator for testing.                                                                                                                                                                                                                                                            |
| abstract URLStreamHandlerFactory                                                                                                           | [createURLStreamHandlerFactory](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#createURLStreamHandlerFactory())() Creates a[URLStreamHandlerFactory](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URLStreamHandlerFactory.html)to handle HTTP and HTTPS traffic.                                                                                                                                                                                                                                                                                |
| int                                                                                                                                        | [getActiveRequestCount](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getActiveRequestCount())() Returns the number of in-flight requests.                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| int                                                                                                                                        | [getDownstreamThroughputKbps](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getDownstreamThroughputKbps())() Returns the downstream throughput estimate (in kilobits per second) computed by the network quality estimator.                                                                                                                                                                                                                                                                                                                                                    |
| int                                                                                                                                        | [getEffectiveConnectionType](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())() Returns an estimate of the effective connection type computed by the network quality estimator.                                                                                                                                                                                                                                                                                                                                                                     |
| abstract byte\[\]                                                                                                                          | [getGlobalMetricsDeltas](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getGlobalMetricsDeltas())() Returns differences in metrics collected by Cronet since the last call to this method.                                                                                                                                                                                                                                                                                                                                                                                      |
| int                                                                                                                                        | [getHttpRttMs](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getHttpRttMs())() Returns the HTTP RTT estimate (in milliseconds) computed by the network quality estimator.                                                                                                                                                                                                                                                                                                                                                                                                      |
| int                                                                                                                                        | [getTransportRttMs](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getTransportRttMs())() Returns the transport RTT estimate (in milliseconds) computed by the network quality estimator.                                                                                                                                                                                                                                                                                                                                                                                       |
| abstract String                                                                                                                            | [getVersionString](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getVersionString())()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html) | [newUrlRequestBuilder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#newUrlRequestBuilder(java.lang.String,%20org.chromium.net.UrlRequest.Callback,%20java.util.concurrent.Executor))(String url,[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html)callback, Executor executor) Creates a builder for[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html).                                                                     |
| abstract URLConnection                                                                                                                     | [openConnection](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#openConnection(java.net.URL))(URL url) Establishes a new connection to the resource specified by the[URL](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URL.html)`url`.                                                                                                                                                                                                                                                                                                          |
| void                                                                                                                                       | [removeRequestFinishedListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#removeRequestFinishedListener(org.chromium.net.RequestFinishedInfo.Listener))([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener) Removes a finished request listener.                                                                                                                                                                                                               |
| void                                                                                                                                       | [removeRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#removeRttListener(org.chromium.net.NetworkQualityRttListener))([NetworkQualityRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityRttListener.html)listener) Removes a listener of round trip times if previously registered with[addRttListener(NetworkQualityRttListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addRttListener(org.chromium.net.NetworkQualityRttListener)). |
| void                                                                                                                                       | [removeThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#removeThroughputListener(org.chromium.net.NetworkQualityThroughputListener))([NetworkQualityThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityThroughputListener.html)listener) Removes a listener of throughput.                                                                                                                                                                                                                |
| abstract void                                                                                                                              | [shutdown](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#shutdown())() Shuts down the[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)if there are no active requests, otherwise throws an exception.                                                                                                                                                                                                                                                                                                     |
| void                                                                                                                                       | [startNetLogToDisk](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#startNetLogToDisk(java.lang.String,%20boolean,%20int))(String dirPath, boolean logAll, int maxSize) Starts NetLog logging to a specified directory with a bounded size.                                                                                                                                                                                                                                                                                                                                      |
| abstract void                                                                                                                              | [startNetLogToFile](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#startNetLogToFile(java.lang.String,%20boolean))(String fileName, boolean logAll) Starts NetLog logging to a file.                                                                                                                                                                                                                                                                                                                                                                                            |
| abstract void                                                                                                                              | [stopNetLog](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#stopNetLog())() Stops NetLog logging and flushes file to disk.                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

### Inherited Method Summary

From class java.lang.Object  

|------------------|---------------------------|
| Object           | clone()                   |
| boolean          | equals(Object arg0)       |
| void             | finalize()                |
| final Class\<?\> | getClass()                |
| int              | hashCode()                |
| final void       | notify()                  |
| final void       | notifyAll()               |
| String           | toString()                |
| final void       | wait(long arg0, int arg1) |
| final void       | wait(long arg0)           |
| final void       | wait()                    |

## Constants

#### public static final int**ACTIVE_REQUEST_COUNT_UNKNOWN**

The value of the active request count is unknown  
Constant Value:-1  

#### public static final int**CONNECTION_METRIC_UNKNOWN**

The value of a connection metric is unknown.  
Constant Value:-1  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_2G**

The estimate of the effective connection type is 2G.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:3  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_3G**

The estimate of the effective connection type is 3G.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:4  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_4G**

The estimate of the effective connection type is 4G.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:5  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_OFFLINE**

The device is offline.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:1  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_SLOW_2G**

The estimate of the effective connection type is slow 2G.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:2  

#### public static final int**EFFECTIVE_CONNECTION_TYPE_UNKNOWN**

The estimate of the effective connection type is unknown.  

##### See Also

- [getEffectiveConnectionType()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#getEffectiveConnectionType())  
Constant Value:0

## Public Constructors

#### public**CronetEngine**()

<br />

## Public Methods

#### public void**addRequestFinishedListener**([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener)

Registers a listener that gets called after the end of each request with the request info.

The listener is called on an[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)provided by the listener.  

##### Parameters

| listener | the listener for finished requests. |
|----------|-------------------------------------|

#### public void**addRttListener**([NetworkQualityRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityRttListener.html)listener)

Registers a listener that gets called whenever the network quality estimator witnesses a sample round trip time. This must be called after[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)), and with throw an exception otherwise. Round trip times may be recorded at various layers of the network stack, including TCP, QUIC, and at the URL request layer. The listener is called on the[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)that is passed to[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)).  

##### Parameters

| listener | the listener of round trip times. |
|----------|-----------------------------------|

#### public void**addThroughputListener**([NetworkQualityThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityThroughputListener.html)listener)

Registers a listener that gets called whenever the network quality estimator witnesses a sample throughput measurement. This must be called after[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)). Throughput observations are computed by measuring bytes read over the active network interface at times when at least one URL response is being received. The listener is called on the[Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)that is passed to[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)).  

##### Parameters

| listener | the listener of throughput. |
|----------|-----------------------------|

#### public void**configureNetworkQualityEstimatorForTesting**(boolean useLocalHostRequests, boolean useSmallerResponses, boolean disableOfflineCheck)

Configures the network quality estimator for testing. This must be called before round trip time and throughput listeners are added, and after the network quality estimator has been enabled.  

##### Parameters

| useLocalHostRequests |                                         include requests to localhost in estimates.                                          |
| useSmallerResponses  |                                       include small responses in throughput estimates.                                       |
| disableOfflineCheck  | when set to true, disables the device offline checks when computing the effective connection type or when writing the prefs. |
|----------------------|------------------------------------------------------------------------------------------------------------------------------|

#### public abstract URLStreamHandlerFactory**createURLStreamHandlerFactory**()

Creates a[URLStreamHandlerFactory](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URLStreamHandlerFactory.html)to handle HTTP and HTTPS traffic. An instance of this class can be installed via[URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URL.html#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory))thus using this CronetEngine by default for all requests created via[URL.openConnection()](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URL.html#openConnection()).

Cronet does not use certain HTTP features provided via the system:

- the HTTP cache installed via[HttpResponseCache.install()](https://developer.android.com/develop/connectivity/cronet/reference/android/net/http/HttpResponseCache.html#install(java.io.File,%20long))
- the HTTP authentication method installed via[Authenticator.setDefault(Authenticator)](https://developer.android.com/develop/connectivity/cronet/reference/java/net/Authenticator.html#setDefault(java.net.Authenticator))
- the HTTP cookie storage installed via[CookieHandler.setDefault(CookieHandler)](https://developer.android.com/develop/connectivity/cronet/reference/java/net/CookieHandler.html#setDefault(java.net.CookieHandler))

While Cronet supports and encourages requests using the HTTPS protocol, Cronet does not provide support for the[HttpsURLConnection](https://developer.android.com/develop/connectivity/cronet/reference/javax/net/ssl/HttpsURLConnection.html)API. This lack of support also includes not using certain HTTPS features provided via the system:

- the HTTPS hostname verifier installed via[HttpsURLConnection.setDefaultHostnameVerifier()](https://developer.android.com/develop/connectivity/cronet/reference/javax/net/ssl/HttpsURLConnection.html#setDefaultHostnameVerifier(javax.net.ssl.HostnameVerifier))
- the HTTPS socket factory installed via[HttpsURLConnection.setDefaultSSLSocketFactory()](https://developer.android.com/develop/connectivity/cronet/reference/javax/net/ssl/HttpsURLConnection.html#setDefaultSSLSocketFactory(javax.net.ssl.SSLSocketFactory))

<br />

##### Returns

- an[URLStreamHandlerFactory](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URLStreamHandlerFactory.html)instance implemented by this CronetEngine.  

#### public int**getActiveRequestCount**()

Returns the number of in-flight requests.

A request is in-flight if its start() method has been called but it hasn't reached a final state yet. A request reaches the final state when one of the following callbacks has been called:

- onSucceeded
- onCanceled
- onFailed

[Cronet requests's lifecycle](https://developer.android.com/guide/topics/connectivity/cronet/lifecycle)for more information.

<br />

#### public int**getDownstreamThroughputKbps**()

Returns the downstream throughput estimate (in kilobits per second) computed by the network quality estimator. Set to[CONNECTION_METRIC_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#CONNECTION_METRIC_UNKNOWN)if the value is unavailable. This must be called after[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)), and will throw an exception otherwise.  

##### Returns

- Estimate of the downstream throughput in kilobits per second.  

#### public int**getEffectiveConnectionType**()

Returns an estimate of the effective connection type computed by the network quality estimator. Call[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean))to begin computing this value.  

##### Returns

- the estimated connection type. The returned value is one of[EFFECTIVE_CONNECTION_TYPE_*](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#EFFECTIVE_CONNECTION_TYPE_UNKNOWN).  

#### public abstract byte\[\]**getGlobalMetricsDeltas**()

Returns differences in metrics collected by Cronet since the last call to this method.

Cronet collects these metrics globally. This means deltas returned by`getGlobalMetricsDeltas()`will include measurements of requests processed by other[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)instances. Since this function returns differences in metrics collected since the last call, and these metrics are collected globally, a call to any`CronetEngine`instance's`getGlobalMetricsDeltas()`method will affect the deltas returned by any other`CronetEngine`instance's`getGlobalMetricsDeltas()`.

Cronet starts collecting these metrics after the first call to`getGlobalMetricsDeltras()`, so the first call returns no useful data as no metrics have yet been collected.  

##### Returns

- differences in metrics collected by Cronet, since the last call to`getGlobalMetricsDeltas()`, serialized as a[protobuf](https://developers.google.com/protocol-buffers).  

#### public int**getHttpRttMs**()

Returns the HTTP RTT estimate (in milliseconds) computed by the network quality estimator. Set to[CONNECTION_METRIC_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#CONNECTION_METRIC_UNKNOWN)if the value is unavailable. This must be called after[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)), and will throw an exception otherwise.  

##### Returns

- Estimate of the HTTP RTT in milliseconds.  

#### public int**getTransportRttMs**()

Returns the transport RTT estimate (in milliseconds) computed by the network quality estimator. Set to[CONNECTION_METRIC_UNKNOWN](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#CONNECTION_METRIC_UNKNOWN)if the value is unavailable. This must be called after[CronetEngine.Builder.enableNetworkQualityEstimator(boolean)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.Builder.html#enableNetworkQualityEstimator(boolean)), and will throw an exception otherwise.  

##### Returns

- Estimate of the transport RTT in milliseconds.  

#### public abstract String**getVersionString**()

<br />

##### Returns

- a human-readable version string of the engine.  

#### public abstract[UrlRequest.Builder](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Builder.html)**newUrlRequestBuilder**(String url,[UrlRequest.Callback](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.Callback.html)callback, Executor executor)

Creates a builder for[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html). All callbacks for generated[UrlRequest](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/UrlRequest.html)objects will be invoked on`executor`'s threads.`executor`must not run tasks on the thread calling[Executor.execute(Runnable)](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html#execute(java.lang.Runnable))to prevent blocking networking operations and causing exceptions during shutdown.  

##### Parameters

|   url    |                                                              URL for the generated requests.                                                              |
| callback |                                                  callback object that gets invoked on different events.                                                   |
| executor | [Executor](https://developer.android.com/develop/connectivity/cronet/reference/java/util/concurrent/Executor.html)on which all callbacks will be invoked. |
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|

#### public abstract URLConnection**openConnection**(URL url)

Establishes a new connection to the resource specified by the[URL](https://developer.android.com/develop/connectivity/cronet/reference/java/net/URL.html)`url`.

**Note:** Cronet's[HttpURLConnection](https://developer.android.com/develop/connectivity/cronet/reference/java/net/HttpURLConnection.html)implementation is subject to certain limitations, see[createURLStreamHandlerFactory()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#createURLStreamHandlerFactory())for details.  

##### Parameters

| url | URL of resource to connect to. |
|-----|--------------------------------|

##### Returns

- an[HttpURLConnection](https://developer.android.com/develop/connectivity/cronet/reference/java/net/HttpURLConnection.html)instance implemented by this CronetEngine.  

##### Throws

| IOException | if an error occurs while opening the connection. |
|-------------|--------------------------------------------------|

#### public void**removeRequestFinishedListener**([RequestFinishedInfo.Listener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/RequestFinishedInfo.Listener.html)listener)

Removes a finished request listener.  

##### Parameters

| listener | the listener to remove. |
|----------|-------------------------|

#### public void**removeRttListener**([NetworkQualityRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityRttListener.html)listener)

Removes a listener of round trip times if previously registered with[addRttListener(NetworkQualityRttListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addRttListener(org.chromium.net.NetworkQualityRttListener)). This should be called after a[NetworkQualityRttListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityRttListener.html)is added in order to stop receiving observations.  

##### Parameters

| listener | the listener of round trip times. |
|----------|-----------------------------------|

#### public void**removeThroughputListener**([NetworkQualityThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityThroughputListener.html)listener)

Removes a listener of throughput. This should be called after a[NetworkQualityThroughputListener](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/NetworkQualityThroughputListener.html)is added with[addThroughputListener(NetworkQualityThroughputListener)](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#addThroughputListener(org.chromium.net.NetworkQualityThroughputListener))in order to stop receiving observations.  

##### Parameters

| listener | the listener of throughput. |
|----------|-----------------------------|

#### public abstract void**shutdown**()

Shuts down the[CronetEngine](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html)if there are no active requests, otherwise throws an exception.

Cannot be called on network thread - the thread Cronet calls into Executor on (which is different from the thread the Executor invokes callbacks on). May block until all the`CronetEngine`'s resources have been cleaned up.  

#### public void**startNetLogToDisk**(String dirPath, boolean logAll, int maxSize)

Starts NetLog logging to a specified directory with a bounded size. The NetLog will contain events emitted by all live CronetEngines. The NetLog is useful for debugging. Once logging has stopped[stopNetLog()](https://developer.android.com/develop/connectivity/cronet/reference/org/chromium/net/CronetEngine.html#stopNetLog()), the data will be written to netlog.json in`dirPath`. If logging is interrupted, you can stitch the files found in .inprogress subdirectory manually using: https://chromium.googlesource.com/chromium/src/+/main/net/tools/stitch_net_log_files.py. The log can be viewed using a Chrome browser navigated to chrome://net-internals/#import.  

##### Parameters

| dirPath |                                                                 the directory where the netlog.json file will be created. dirPath must already exist. NetLog files must not exist in the directory. If actively logging, this method is ignored.                                                                  |
| logAll  | `true`to include basic events, user cookies, credentials and all transferred bytes in the log. This option presents a privacy risk, since it exposes the user's credentials, and should only be used with the user's consent and in situations where the log won't be public.`false`to just include basic events. |
| maxSize |                                                                                           the maximum total disk space in bytes that should be used by NetLog. Actual disk space usage may exceed this limit slightly.                                                                                            |
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

#### public abstract void**startNetLogToFile**(String fileName, boolean logAll)

Starts NetLog logging to a file. The NetLog will contain events emitted by all live CronetEngines. The NetLog is useful for debugging. The file can be viewed using a Chrome browser navigated to chrome://net-internals/#import  

##### Parameters

| fileName |                                                                                  the complete file path. It must not be empty. If the file exists, it is truncated before starting. If actively logging, this method is ignored.                                                                                  |
|  logAll  | `true`to include basic events, user cookies, credentials and all transferred bytes in the log. This option presents a privacy risk, since it exposes the user's credentials, and should only be used with the user's consent and in situations where the log won't be public.`false`to just include basic events. |
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|

#### public abstract void**stopNetLog**()

Stops NetLog logging and flushes file to disk. If a logging session is not in progress, this call is ignored.