public static final class

DnsOptions.StaleDnsOptions.Builder

extends Object
java.lang.Object
   ↳ org.chromium.net.DnsOptions.StaleDnsOptions.Builder

Class Overview

Builder for DnsOptions.StaleDnsOptions.

Summary

Public Methods
DnsOptions.StaleDnsOptions.Builder allowCrossNetworkUsage(boolean allowCrossNetworkUsage)
Sets whether to return results originating from other networks or not.
DnsOptions.StaleDnsOptions build()
Creates and returns the final DnsOptions.StaleDnsOptions instance, based on the values in this builder.
DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeout(Duration freshLookupTimeout)
DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeoutMillis(long freshLookupTimeoutMillis)
Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead.
DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelayMillis(long maxExpiredDelayMillis)
Sets how long (in milliseconds) past expiration to consider using expired results.
DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelayMillis(Duration maxExpiredDelay)
DnsOptions.StaleDnsOptions.Builder useStaleOnNameNotResolved(boolean useStaleOnNameNotResolved)
Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public DnsOptions.StaleDnsOptions.Builder allowCrossNetworkUsage (boolean allowCrossNetworkUsage)

Sets whether to return results originating from other networks or not. Normally, Cronet clears the DNS cache entirely when switching connections, e.g. between two Wi-Fi networks or from Wi-Fi to 4G.

Parameters
allowCrossNetworkUsage boolean
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining

public DnsOptions.StaleDnsOptions build ()

Creates and returns the final DnsOptions.StaleDnsOptions instance, based on the values in this builder.

Returns
DnsOptions.StaleDnsOptions

public DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeout (Duration freshLookupTimeout)

Same as setFreshLookupTimeoutMillis(long) but using Duration.

Parameters
freshLookupTimeout Duration
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining

public DnsOptions.StaleDnsOptions.Builder setFreshLookupTimeoutMillis (long freshLookupTimeoutMillis)

Sets how long (in milliseconds) to wait for a DNS request to return before using a stale result instead. If set to zero, returns stale results instantly but continues the DNS request in the background to update the cache.

Parameters
freshLookupTimeoutMillis long
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining

public DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelayMillis (long maxExpiredDelayMillis)

Sets how long (in milliseconds) past expiration to consider using expired results. Setting the value to zero means expired records can be used indefinitely.

Parameters
maxExpiredDelayMillis long
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining

public DnsOptions.StaleDnsOptions.Builder setMaxExpiredDelayMillis (Duration maxExpiredDelay)

Same as setMaxExpiredDelayMillis(long) but using Duration.

Parameters
maxExpiredDelay Duration
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining

public DnsOptions.StaleDnsOptions.Builder useStaleOnNameNotResolved (boolean useStaleOnNameNotResolved)

Sets whether to allow use of stale DNS results when network resolver fails to resolve the hostname.

Depending on the use case, if Cronet quickly sees a fresh failure, it may be desirable to use the failure as it is technically the fresher result, and we had such a fresh result quickly; or, prefer having any result (even if stale) to use over having a failure.

Parameters
useStaleOnNameNotResolved boolean
Returns
DnsOptions.StaleDnsOptions.Builder the builder for chaining