summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/dns_global.cc
diff options
context:
space:
mode:
authorjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:50:14 +0000
committerjar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-17 22:50:14 +0000
commit03c5e868627fd74ec5c13cb26df3cb110853765f (patch)
treec97563d5255b2ae0de3faf921577130bb346008f /chrome/browser/net/dns_global.cc
parentb7125fd56addf151194b09314c1f7f2c9d03a5b9 (diff)
downloadchromium_src-03c5e868627fd74ec5c13cb26df3cb110853765f.zip
chromium_src-03c5e868627fd74ec5c13cb26df3cb110853765f.tar.gz
chromium_src-03c5e868627fd74ec5c13cb26df3cb110853765f.tar.bz2
Persist info about subresources on pages for DNS pre-resolution
The DNS pre-resolution system already "learns" what domains are commonly needed when rendering sub-resources of a page at a given domain. This patch saves (some of) the information learned into a persistent pref, and restores it on startup. For now, I put in a wimpy pruning of the list each time I save, so that the list will not grow endlessly from session to session. I probably need a better pruning algorithm, such as one that prunes after a given amount of time, rather than only during shutdown. For now, this should get a lot of nice results, and provide slightly larger than needed lists to users that have long lived sessions, which is similar to the current performance, where I didn't persist any info, and only pruned (actually discarded) all learned info at shutdown. r=mbelshe Review URL: http://codereview.chromium.org/21374 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9912 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/dns_global.cc')
-rw-r--r--chrome/browser/net/dns_global.cc32
1 files changed, 29 insertions, 3 deletions
diff --git a/chrome/browser/net/dns_global.cc b/chrome/browser/net/dns_global.cc
index b34de8a..67e4265 100644
--- a/chrome/browser/net/dns_global.cc
+++ b/chrome/browser/net/dns_global.cc
@@ -60,6 +60,7 @@ void OnTheRecord(bool enable) {
void RegisterPrefs(PrefService* local_state) {
local_state->RegisterListPref(prefs::kDnsStartupPrefetchList);
+ local_state->RegisterListPref(prefs::kDnsHostReferralList);
}
void RegisterUserPrefs(PrefService* user_prefs) {
@@ -73,8 +74,7 @@ static DnsMaster* dns_master;
// This API is only used in the browser process.
// It is called from an IPC message originating in the renderer. It currently
// includes both Page-Scan, and Link-Hover prefetching.
-// TODO(jar): Separate out link-hover prefetching, and histogram results
-// separately.
+// TODO(jar): Separate out link-hover prefetching, and page-scan results.
void DnsPrefetchList(const NameList& hostnames) {
DnsPrefetchMotivatedList(hostnames, DnsHostInfo::PAGE_SCAN_MOTIVATED);
}
@@ -221,7 +221,7 @@ void PrefetchObserver::OnFinishResolutionWithStatus(bool was_resolved,
return;
// TODO(jar): Don't add host to our list if it is a non-linked lookup, and
// instead rely on Referrers to pull this in automatically with the enclosing
- // page load.
+ // page load (once we start to persist elements of our referrer tree).
StartupListAppend(navigation_info);
}
@@ -466,6 +466,32 @@ void DnsPrefetchHostNamesAtStartup(PrefService* user_prefs,
DnsHostInfo::STARTUP_LIST_MOTIVATED);
}
+//------------------------------------------------------------------------------
+// Functions to persist and restore host references, that are used to direct DNS
+// prefetch of names (probably) used in subresources when the major resource is
+// navigated towards.
+
+void SaveSubresourceReferrers(PrefService* local_state) {
+ if (NULL == dns_master)
+ return;
+ ListValue* referral_list =
+ local_state->GetMutableList(prefs::kDnsHostReferralList);
+ dns_master->SerializeReferrers(referral_list);
+}
+
+void RestoreSubresourceReferrers(PrefService* local_state) {
+ if (NULL == dns_master)
+ return;
+ ListValue* referral_list =
+ local_state->GetMutableList(prefs::kDnsHostReferralList);
+ dns_master->DeserializeReferrers(*referral_list);
+}
+
+void TrimSubresourceReferrers() {
+ if (NULL == dns_master)
+ return;
+ dns_master->TrimReferrers();
+}
} // namespace chrome_browser_net