Index: chrome/browser/net/predictor.h |
diff --git a/chrome/browser/net/predictor.h b/chrome/browser/net/predictor.h |
index 8161a3616beb5eebdbc4427cf1e978ccaa0b306d..b56a62bdf913840cb937999a953b3be0569b9036 100644 |
--- a/chrome/browser/net/predictor.h |
+++ b/chrome/browser/net/predictor.h |
@@ -29,6 +29,7 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/memory/weak_ptr.h" |
#include "chrome/browser/net/referrer.h" |
+#include "chrome/browser/net/timed_cache.h" |
#include "chrome/browser/net/url_info.h" |
#include "chrome/common/net/predictor_common.h" |
#include "net/base/host_port_pair.h" |
@@ -91,6 +92,13 @@ class Predictor { |
// avoidance will kick in and all speculations in the queue will be discarded. |
static const int kMaxSpeculativeResolveQueueDelayMs; |
+ // We don't bother learning to preconnect via a GET if the original URL |
+ // navigation was so long ago, that a preconnection would have been dropped |
+ // anyway. We believe most servers will drop the connection in 10 seconds, so |
+ // we currently estimate this time-till-drop at 10 seconds. |
+ // TODO(jar): We should do a persistent field trial to validate/optimize this. |
+ static const int kMaxUnusedSocketLifetimeSecondsWithoutAGet; |
+ |
// |max_concurrent| specifies how many concurrent (parallel) prefetches will |
// be performed. Host lookups will be issued through |host_resolver|. |
explicit Predictor(bool preconnect_enabled); |
@@ -220,6 +228,18 @@ class Predictor { |
void EnablePredictorOnIOThread(bool enable); |
+ // May be called from either the IO or UI thread and will PostTask |
+ // to the IO thread if necessary. |
+ void PreconnectUrl(const GURL& url, const GURL& first_party_for_cookies, |
+ UrlInfo::ResolutionMotivation motivation, int count); |
+ |
+ void PreconnectUrlOnIOThread(const GURL& url, |
+ const GURL& first_party_for_cookies, |
+ UrlInfo::ResolutionMotivation motivation, |
+ int count); |
+ |
+ void RecordPreconnectNavigationStats(const GURL& url); |
+ |
// ------------- End IO thread methods. |
// The following methods may be called on either the IO or UI threads. |
@@ -489,6 +509,8 @@ class Predictor { |
// The time when the last preconnection was requested to a search service. |
base::TimeTicks last_omnibox_preconnect_; |
+ TimedCache recent_preconnects_; |
+ |
// For each URL that we might navigate to (that we've "learned about") |
// we have a Referrer list. Each Referrer list has all hostnames we might |
// need to pre-resolve or pre-connect to when there is a navigation to the |