summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/dns_master.h
diff options
context:
space:
mode:
authorjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 23:32:53 +0000
committerjar@google.com <jar@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-06 23:32:53 +0000
commit21dae9b9628a3a7ef481c1871d69e9b48ed90158 (patch)
treeda091a8ff8222d6bfbde888972752d289644b4f7 /chrome/browser/net/dns_master.h
parenta2633667fc8bf1429fe33f5dd89b550e484a03c9 (diff)
downloadchromium_src-21dae9b9628a3a7ef481c1871d69e9b48ed90158.zip
chromium_src-21dae9b9628a3a7ef481c1871d69e9b48ed90158.tar.gz
chromium_src-21dae9b9628a3a7ef481c1871d69e9b48ed90158.tar.bz2
Adaptively identify URL subresources and pre-resolve hosts via DNS
Use the HTTP "referer" header to identify subresources used during a page load. Store that info, and use it when next visiting the referenced hosts to pre-resolve the (probably) needed subresources. This set of changes will surely evolve as we see how it plays out on broader distribution (via histogram measurments), but this should be the foundation of the change. In design specs, this was previously referred to as "adaptive correlated DNS prefetching." r=mbelshe Review URL: http://codereview.chromium.org/9168 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4929 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/dns_master.h')
-rw-r--r--chrome/browser/net/dns_master.h42
1 files changed, 35 insertions, 7 deletions
diff --git a/chrome/browser/net/dns_master.h b/chrome/browser/net/dns_master.h
index 1da6b4f..4bc61ee 100644
--- a/chrome/browser/net/dns_master.h
+++ b/chrome/browser/net/dns_master.h
@@ -24,6 +24,7 @@
#include "base/condition_variable.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/net/dns_host_info.h"
+#include "chrome/browser/net/referrer.h"
#include "chrome/common/net/dns.h"
#include "googleurl/src/url_canon.h"
@@ -63,12 +64,28 @@ class DnsMaster {
void DiscardAllResults();
// Add hostname(s) to the queue for processing by slaves
- void ResolveList(const NameList& hostnames);
- void Resolve(const std::string& hostname);
+ void ResolveList(const NameList& hostnames,
+ DnsHostInfo::ResolutionMotivation motivation);
+ void Resolve(const std::string& hostname,
+ DnsHostInfo::ResolutionMotivation motivation);
// Get latency benefit of the prefetch that we are navigating to.
- bool AcruePrefetchBenefits(DnsHostInfo* host_info);
+ bool AccruePrefetchBenefits(const GURL& referrer,
+ DnsHostInfo* navigation_info);
+ // Instigate prefetch of any domains we predict will be needed after this
+ // navigation.
+ void NavigatingTo(const std::string& host_name);
+
+ // Record details of a navigation so that we can preresolve the host name
+ // ahead of time the next time the users navigates to the indicated host.
+ void NonlinkNavigation(const GURL& referrer, DnsHostInfo* navigation_info);
+
+ // Dump HTML table containing list of referrers for about:dns.
+ void GetHtmlReferrerLists(std::string* output);
+
+ // Dump the list of currently know referrer domains and related prefetchable
+ // domains.
void GetHtmlInfo(std::string* output);
// For testing only...
@@ -120,25 +137,36 @@ class DnsMaster {
void SetSlaveHasTerminated(int slave_index);
private:
- //----------------------------------------------------------------------------
- // Internal helper functions
+ // A map that is keyed with the hostnames that we've learned were the cause
+ // of loading additional hostnames. The list of additional hostnames in held
+ // in a Referrer instance, which is found in this type.
+ typedef std::map<std::string, Referrer> Referrers;
// "PreLocked" means that the caller has already Acquired lock_ in the
// following method names.
- void PreLockedResolve(const std::string& hostname);
+ // Queue hostname for resolution. If queueing was done, return the pointer
+ // to the queued instance, otherwise return NULL.
+ DnsHostInfo* PreLockedResolve(const std::string& hostname,
+ DnsHostInfo::ResolutionMotivation motivation);
bool PreLockedCreateNewSlaveIfNeeded(); // Lazy slave processes creation.
// Number of slave processes started early (to help with startup prefetch).
static const int kSlaveCountMin = 4;
+ // Synchronize access to results_, referrers_, and slave control data.
Lock lock_;
// name_buffer_ holds a list of names we need to look up.
std::queue<std::string> name_buffer_;
- // results_ contains information progress for existing/prior prefetches.
+ // results_ contains information for existing/prior prefetches.
Results results_;
+ // For each hostname that we might navigate to (that we've "learned about")
+ // we have a Referrer list. Each Referrer list has all hostnames we need to
+ // pre-resolve when there is a navigation to the orginial hostname.
+ Referrers referrers_;
+
// Signaling slaves to process elements in the queue, or to terminate,
// is done using ConditionVariables.
ConditionVariable slaves_have_work_;