[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 1 | // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 5 | // A Predictor object is instantiated once in the browser process, and manages |
| 6 | // both preresolution of hostnames, as well as TCP/IP preconnection to expected |
| 7 | // subresources. |
| 8 | // Most hostname lists are provided by the renderer processes, and include URLs |
| 9 | // that *might* be used in the near future by the browsing user. One goal of |
| 10 | // this class is to cause the underlying DNS structure to lookup a hostname |
| 11 | // before it is really needed, and hence reduce latency in the standard lookup |
| 12 | // paths. |
| 13 | // Subresource relationships are usually acquired from the referrer field in a |
| 14 | // navigation. A subresource URL may be associated with a referrer URL. Later |
| 15 | // navigations may, if the likelihood of needing the subresource is high enough, |
[email protected] | f4ef861ba | 2010-07-28 22:37:23 | [diff] [blame] | 16 | // cause this module to speculatively create a TCP/IP connection. If there is |
| 17 | // only a low likelihood, then a DNS pre-resolution operation may be performed. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 18 | |
[email protected] | 3530cd9 | 2010-06-27 06:22:01 | [diff] [blame] | 19 | #ifndef CHROME_BROWSER_NET_PREDICTOR_H_ |
| 20 | #define CHROME_BROWSER_NET_PREDICTOR_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 21 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 22 | |
| 23 | #include <map> |
| 24 | #include <queue> |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 25 | #include <set> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 26 | #include <string> |
| 27 | |
[email protected] | a918f87 | 2010-06-01 14:30:51 | [diff] [blame] | 28 | #include "base/gtest_prod_util.h" |
[email protected] | fd2f8afe | 2009-06-11 21:53:55 | [diff] [blame] | 29 | #include "base/ref_counted.h" |
[email protected] | 3530cd9 | 2010-06-27 06:22:01 | [diff] [blame] | 30 | #include "chrome/browser/net/url_info.h" |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 31 | #include "chrome/browser/net/referrer.h" |
[email protected] | 3530cd9 | 2010-06-27 06:22:01 | [diff] [blame] | 32 | #include "chrome/common/net/predictor_common.h" |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 33 | #include "net/base/host_port_pair.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 34 | |
[email protected] | c02c853d7 | 2010-08-07 06:23:24 | [diff] [blame] | 35 | class ListValue; |
| 36 | |
[email protected] | fd2f8afe | 2009-06-11 21:53:55 | [diff] [blame] | 37 | namespace net { |
| 38 | class HostResolver; |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 39 | } // namespace net |
[email protected] | fd2f8afe | 2009-06-11 21:53:55 | [diff] [blame] | 40 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | namespace chrome_browser_net { |
| 42 | |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 43 | typedef chrome_common_net::UrlList UrlList; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 44 | typedef chrome_common_net::NameList NameList; |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 45 | typedef std::map<GURL, UrlInfo> Results; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 46 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 47 | // Note that Predictor is not thread safe, and must only be called from |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 48 | // the IO thread. Failure to do so will result in a DCHECK at runtime. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 49 | class Predictor : public base::RefCountedThreadSafe<Predictor> { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 50 | public: |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 51 | // A version number for prefs that are saved. This should be incremented when |
| 52 | // we change the format so that we discard old data. |
[email protected] | f4ef861ba | 2010-07-28 22:37:23 | [diff] [blame] | 53 | enum { PREDICTOR_REFERRER_VERSION = 2 }; |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 54 | |
[email protected] | f4ef861ba | 2010-07-28 22:37:23 | [diff] [blame] | 55 | // Depending on the expected_subresource_use_, we may either make a TCP/IP |
| 56 | // preconnection, or merely pre-resolve the hostname via DNS (or even do |
| 57 | // nothing). The following are the threasholds for taking those actions. |
| 58 | static const double kPreconnectWorthyExpectedValue; |
| 59 | static const double kDNSPreresolutionWorthyExpectedValue; |
| 60 | // Values of expected_subresource_use_ that are less than the following |
| 61 | // threshold will be discarded when we Trim() the values, such as is done when |
| 62 | // the process ends, and some values are persisted. |
| 63 | static const double kPersistWorthyExpectedValue; |
| 64 | |
| 65 | // |max_concurrent| specifies how many concurrent (parallel) prefetches will |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 66 | // be performed. Host lookups will be issued through |host_resolver|. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 67 | Predictor(net::HostResolver* host_resolver, |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 68 | base::TimeDelta max_queue_delay_ms, size_t max_concurrent, |
| 69 | bool preconnect_enabled); |
[email protected] | b2b8b83 | 2009-02-06 19:03:29 | [diff] [blame] | 70 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 71 | // Cancel pending requests and prevent new ones from being made. |
| 72 | void Shutdown(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 73 | |
| 74 | // In some circumstances, for privacy reasons, all results should be |
| 75 | // discarded. This method gracefully handles that activity. |
| 76 | // Destroy all our internal state, which shows what names we've looked up, and |
| 77 | // how long each has taken, etc. etc. We also destroy records of suggesses |
| 78 | // (cache hits etc.). |
| 79 | void DiscardAllResults(); |
| 80 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 81 | // Add hostname(s) to the queue for processing. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 82 | void ResolveList(const UrlList& urls, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 83 | UrlInfo::ResolutionMotivation motivation); |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 84 | void Resolve(const GURL& url, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 85 | UrlInfo::ResolutionMotivation motivation); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 86 | |
[email protected] | 9008c86f | 2010-08-06 07:10:24 | [diff] [blame] | 87 | // Instigate pre-connection to any URLs, or pre-resolution of related host, |
| 88 | // that we predict will be needed after this navigation (typically |
| 89 | // more-embedded resources on a page). This method will actually post a task |
| 90 | // to do the actual work, so as not to jump ahead of the frame navigation that |
| 91 | // instigated this activity. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 92 | void PredictFrameSubresources(const GURL& url); |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 93 | |
[email protected] | 1455ccf1 | 2010-08-18 16:32:14 | [diff] [blame] | 94 | // The Omnibox has proposed a given url to the user, and if it is a search |
| 95 | // URL, then it also indicates that this is preconnectable (i.e., we could |
| 96 | // preconnect to the search server). |
| 97 | void AnticipateOmniboxUrl(const GURL& url, bool preconnectable); |
| 98 | |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 99 | // Record details of a navigation so that we can preresolve the host name |
| 100 | // ahead of time the next time the users navigates to the indicated host. |
[email protected] | d6bb256 | 2010-08-25 23:31:30 | [diff] [blame] | 101 | // Should only be called when urls are distinct, and they should already be |
| 102 | // canonicalized to not have a path. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 103 | void LearnFromNavigation(const GURL& referring_url, const GURL& target_url); |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 104 | |
| 105 | // Dump HTML table containing list of referrers for about:dns. |
| 106 | void GetHtmlReferrerLists(std::string* output); |
| 107 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 108 | // Dump the list of currently known referrer domains and related prefetchable |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 109 | // domains. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 110 | void GetHtmlInfo(std::string* output); |
| 111 | |
[email protected] | 03c5e86 | 2009-02-17 22:50:14 | [diff] [blame] | 112 | // Discard any referrer for which all the suggested host names are currently |
| 113 | // annotated with no user latency reduction. Also scale down (diminish) the |
| 114 | // total benefit of those that did help, so that their reported contribution |
| 115 | // wll go done by a factor of 2 each time we trim (moving the referrer closer |
| 116 | // to being discarded at a future Trim). |
| 117 | void TrimReferrers(); |
| 118 | |
| 119 | // Construct a ListValue object that contains all the data in the referrers_ |
| 120 | // so that it can be persisted in a pref. |
| 121 | void SerializeReferrers(ListValue* referral_list); |
| 122 | |
| 123 | // Process a ListValue that contains all the data from a previous reference |
| 124 | // list, as constructed by SerializeReferrers(), and add all the identified |
| 125 | // values into the current referrer list. |
| 126 | void DeserializeReferrers(const ListValue& referral_list); |
| 127 | |
[email protected] | c02c853d7 | 2010-08-07 06:23:24 | [diff] [blame] | 128 | void DeserializeReferrersThenDelete(ListValue* referral_list); |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 129 | |
[email protected] | e695fbd6 | 2009-06-30 16:31:54 | [diff] [blame] | 130 | // For unit test code only. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 131 | size_t max_concurrent_dns_lookups() const { |
| 132 | return max_concurrent_dns_lookups_; |
| 133 | } |
[email protected] | e695fbd6 | 2009-06-30 16:31:54 | [diff] [blame] | 134 | |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 135 | // Flag setting to use preconnection instead of just DNS pre-fetching. |
| 136 | bool preconnect_enabled() const { return preconnect_enabled_; } |
| 137 | |
[email protected] | 1455ccf1 | 2010-08-18 16:32:14 | [diff] [blame] | 138 | // Put URL in canonical form, including a scheme, host, and port. |
| 139 | // Returns GURL::EmptyGURL() if the scheme is not http/https or if the url |
| 140 | // cannot be otherwise canonicalized. |
| 141 | static GURL CanonicalizeUrl(const GURL& url); |
| 142 | |
[email protected] | b2b8b83 | 2009-02-06 19:03:29 | [diff] [blame] | 143 | private: |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 144 | friend class base::RefCountedThreadSafe<Predictor>; |
| 145 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, BenefitLookupTest); |
| 146 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, ShutdownWhenResolutionIsPendingTest); |
| 147 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, SingleLookupTest); |
| 148 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, ConcurrentLookupTest); |
| 149 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, MassiveConcurrentLookupTest); |
| 150 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueuePushPopTest); |
| 151 | FRIEND_TEST_ALL_PREFIXES(PredictorTest, PriorityQueueReorderTest); |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 152 | friend class WaitForResolutionHelper; // For testing. |
| 153 | |
| 154 | class LookupRequest; |
| 155 | |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 156 | // A simple priority queue for handling host names. |
| 157 | // Some names that are queued up have |motivation| that requires very rapid |
| 158 | // handling. For example, a sub-resource name lookup MUST be done before the |
| 159 | // actual sub-resource is fetched. In contrast, a name that was speculatively |
| 160 | // noted in a page has to be resolved before the user "gets around to" |
| 161 | // clicking on a link. By tagging (with a motivation) each push we make into |
| 162 | // this FIFO queue, the queue can re-order the more important names to service |
| 163 | // them sooner (relative to some low priority background resolutions). |
| 164 | class HostNameQueue { |
| 165 | public: |
| 166 | HostNameQueue(); |
| 167 | ~HostNameQueue(); |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 168 | void Push(const GURL& url, |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 169 | UrlInfo::ResolutionMotivation motivation); |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 170 | bool IsEmpty() const; |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 171 | GURL Pop(); |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 172 | |
| 173 | private: |
| 174 | // The names in the queue that should be serviced (popped) ASAP. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 175 | std::queue<GURL> rush_queue_; |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 176 | // The names in the queue that should only be serviced when rush_queue is |
| 177 | // empty. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 178 | std::queue<GURL> background_queue_; |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 179 | |
| 180 | DISALLOW_COPY_AND_ASSIGN(HostNameQueue); |
| 181 | }; |
| 182 | |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 183 | // A map that is keyed with the host/port that we've learned were the cause |
| 184 | // of loading additional URLs. The list of additional targets is held |
| 185 | // in a Referrer instance, which is a value in this map. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 186 | typedef std::map<GURL, Referrer> Referrers; |
[email protected] | 7c19b87b0 | 2009-01-26 16:19:44 | [diff] [blame] | 187 | |
[email protected] | 9008c86f | 2010-08-06 07:10:24 | [diff] [blame] | 188 | ~Predictor(); |
| 189 | |
| 190 | // Perform actual resolution or preconnection to subresources now. This is |
| 191 | // an internal worker method that is reached via a post task from |
| 192 | // PredictFrameSubresources(). |
| 193 | void PrepareFrameSubresources(const GURL& url); |
| 194 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 195 | // Only for testing. Returns true if hostname has been successfully resolved |
| 196 | // (name found). |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 197 | bool WasFound(const GURL& url) const { |
| 198 | Results::const_iterator it(results_.find(url)); |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 199 | return (it != results_.end()) && |
| 200 | it->second.was_found(); |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | // Only for testing. Return how long was the resolution |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 204 | // or UrlInfo::kNullDuration if it hasn't been resolved yet. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 205 | base::TimeDelta GetResolutionDuration(const GURL& url) { |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 206 | if (results_.find(url) == results_.end()) |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 207 | return UrlInfo::kNullDuration; |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 208 | return results_[url].resolve_duration(); |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | // Only for testing; |
| 212 | size_t peak_pending_lookups() const { return peak_pending_lookups_; } |
| 213 | |
[email protected] | 8539853 | 2009-06-16 21:32:18 | [diff] [blame] | 214 | // Access method for use by async lookup request to pass resolution result. |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 215 | void OnLookupFinished(LookupRequest* request, const GURL& url, bool found); |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 216 | |
[email protected] | 8539853 | 2009-06-16 21:32:18 | [diff] [blame] | 217 | // Underlying method for both async and synchronous lookup to update state. |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 218 | void LookupFinished(LookupRequest* request, |
[email protected] | c5629c3 | 2010-06-23 01:22:43 | [diff] [blame] | 219 | const GURL& url, bool found); |
[email protected] | 8539853 | 2009-06-16 21:32:18 | [diff] [blame] | 220 | |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 221 | // Queue hostname for resolution. If queueing was done, return the pointer |
| 222 | // to the queued instance, otherwise return NULL. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 223 | UrlInfo* AppendToResolutionQueue(const GURL& url, |
| 224 | UrlInfo::ResolutionMotivation motivation); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 225 | |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 226 | // Check to see if too much queuing delay has been noted for the given info, |
| 227 | // which indicates that there is "congestion" or growing delay in handling the |
| 228 | // resolution of names. Rather than letting this congestion potentially grow |
| 229 | // without bounds, we abandon our queued efforts at pre-resolutions in such a |
| 230 | // case. |
| 231 | // To do this, we will recycle |info|, as well as all queued items, back to |
| 232 | // the state they had before they were queued up. We can't do anything about |
| 233 | // the resolutions we've already sent off for processing on another thread, so |
| 234 | // we just let them complete. On a slow system, subject to congestion, this |
| 235 | // will greatly reduce the number of resolutions done, but it will assure that |
| 236 | // any resolutions that are done, are in a timely and hence potentially |
| 237 | // helpful manner. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 238 | bool CongestionControlPerformed(UrlInfo* info); |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 239 | |
| 240 | // Take lookup requests from work_queue_ and tell HostResolver to look them up |
| 241 | // asynchronously, provided we don't exceed concurrent resolution limit. |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 242 | void StartSomeQueuedResolutions(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 243 | |
[email protected] | a20bc09 | 2009-06-05 01:34:20 | [diff] [blame] | 244 | // work_queue_ holds a list of names we need to look up. |
| 245 | HostNameQueue work_queue_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 246 | |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 247 | // results_ contains information for existing/prior prefetches. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 248 | Results results_; |
| 249 | |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 250 | // For each URL that we might navigate to (that we've "learned about") |
[email protected] | 21dae9b | 2008-11-06 23:32:53 | [diff] [blame] | 251 | // we have a Referrer list. Each Referrer list has all hostnames we need to |
| 252 | // pre-resolve when there is a navigation to the orginial hostname. |
| 253 | Referrers referrers_; |
| 254 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 255 | std::set<LookupRequest*> pending_lookups_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 256 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 257 | // For testing, to verify that we don't exceed the limit. |
| 258 | size_t peak_pending_lookups_; |
[email protected] | b2b8b83 | 2009-02-06 19:03:29 | [diff] [blame] | 259 | |
[email protected] | 1933eb20 | 2009-02-19 18:23:25 | [diff] [blame] | 260 | // When true, we don't make new lookup requests. |
[email protected] | b2b8b83 | 2009-02-06 19:03:29 | [diff] [blame] | 261 | bool shutdown_; |
| 262 | |
[email protected] | e085c30 | 2009-06-01 18:31:36 | [diff] [blame] | 263 | // The number of concurrent lookups currently allowed. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 264 | const size_t max_concurrent_dns_lookups_; |
[email protected] | e085c30 | 2009-06-01 18:31:36 | [diff] [blame] | 265 | |
[email protected] | 602faf3c | 2009-06-27 14:35:44 | [diff] [blame] | 266 | // The maximum queueing delay that is acceptable before we enter congestion |
| 267 | // reduction mode, and discard all queued (but not yet assigned) resolutions. |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 268 | const base::TimeDelta max_dns_queue_delay_; |
[email protected] | 602faf3c | 2009-06-27 14:35:44 | [diff] [blame] | 269 | |
[email protected] | ec86bea | 2009-12-08 18:35:14 | [diff] [blame] | 270 | // The host resovler we warm DNS entries for. |
[email protected] | 94a0d3d9 | 2009-06-27 01:50:14 | [diff] [blame] | 271 | scoped_refptr<net::HostResolver> host_resolver_; |
[email protected] | fd2f8afe | 2009-06-11 21:53:55 | [diff] [blame] | 272 | |
[email protected] | 760d970a | 2010-05-18 00:39:18 | [diff] [blame] | 273 | // Are we currently using preconnection, rather than just DNS resolution, for |
| 274 | // subresources and omni-box search URLs. |
| 275 | bool preconnect_enabled_; |
| 276 | |
[email protected] | 1455ccf1 | 2010-08-18 16:32:14 | [diff] [blame] | 277 | // Most recent suggestion from Omnibox provided via AnticipateOmniboxUrl(). |
| 278 | std::string last_omnibox_host_; |
| 279 | |
| 280 | // The time when the last preresolve was done for last_omnibox_host_. |
| 281 | base::TimeTicks last_omnibox_preresolve_; |
| 282 | |
| 283 | // The number of consecutive requests to AnticipateOmniboxUrl() that suggested |
| 284 | // preconnecting (because it was to a search service). |
| 285 | int consecutive_omnibox_preconnect_count_; |
| 286 | |
| 287 | // The time when the last preconnection was requested to a search service. |
| 288 | base::TimeTicks last_omnibox_preconnect_; |
| 289 | |
[email protected] | 74be069e8 | 2010-06-25 00:12:49 | [diff] [blame] | 290 | DISALLOW_COPY_AND_ASSIGN(Predictor); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 291 | }; |
| 292 | |
| 293 | } // namespace chrome_browser_net |
| 294 | |
[email protected] | 3530cd9 | 2010-06-27 06:22:01 | [diff] [blame] | 295 | #endif // CHROME_BROWSER_NET_PREDICTOR_H_ |