Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Unified Diff: components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java

Issue 2909663002: [Cronet] Add API to set DNS cache entry
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
diff --git a/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java b/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
index 9ab5f648e77d91a56f64f62f9a0a044273373563..3705e2cd3141c508e8f547de952d236100919ab9 100644
--- a/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
+++ b/components/cronet/android/api/src/org/chromium/net/ExperimentalCronetEngine.java
@@ -7,6 +7,7 @@ import android.content.Context;
import android.support.annotation.VisibleForTesting;
import java.io.IOException;
+import java.net.InetAddress;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
@@ -434,4 +435,32 @@ public abstract class ExperimentalCronetEngine extends CronetEngine {
public int getDownstreamThroughputKbps() {
return CONNECTION_METRIC_UNKNOWN;
}
+
+ /**
+ * Put an entry for a host in the host resolver cache. This can save time
+ * when making requests to this host in the future by avoiding having to
+ * resolve the host.
+ * <p>
+ * <b>Caveats:</b>
+ * <ul>
+ * <li>Only add trustworthy entries. Incorrect entries can provoke
+ * security vulnerabilities like man-in-the-middle attacks when SSL/TLS
+ * is not used.</li>
+ * <li>Putting an entry in the cache evicts any previously existing entry
+ * for the host.</li>
+ * <li>Hosts can resolve to different IP addresses accessible with varying
+ * latencies. An entry placed in the cache accessible with high latency,
+ * e.g. a far away server, can harm performance if normal host
+ * resolution would have provided more optimal results, e.g. the address
+ * of a nearby server.</li>
+ * <li>The entry may be purged from the cache prior to the given lifetime
+ * when certain events happen, for example if the default network
+ * connection changes.</li>
+ * </ul>
+ * @param hostName the name of the host to add an entry for.
+ * @param addresses the list of addresses to add for the host.
+ * @param secondsToLive the maximum number of seconds this entry should live
+ * in the cache.
+ */
+ public void putHostCache(String hostName, InetAddress[] addresses, int secondsToLive) {}
}
« no previous file with comments | « no previous file | components/cronet/android/cronet_url_request_context_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698