Index: chrome/browser/net/url_info.cc |
=================================================================== |
--- chrome/browser/net/url_info.cc (revision 54027) |
+++ chrome/browser/net/url_info.cc (working copy) |
@@ -131,11 +131,6 @@ |
resolve_duration_, kMaxNonNetworkDnsLookupDuration, |
TimeDelta::FromMinutes(15), 100); |
} |
- |
- // Record potential beneficial time, and maybe we'll get a cache hit. |
- // We keep the maximum, as the warming we did earlier may still be |
- // helping with a cache upstream in DNS resolution. |
- benefits_remaining_ = std::max(resolve_duration_, benefits_remaining_); |
} |
sequence_number_ = sequence_counter++; |
DLogResultsStats("DNS PrefetchFound"); |
@@ -147,29 +142,11 @@ |
resolve_duration_ = GetDuration(); |
if (kMaxNonNetworkDnsLookupDuration <= resolve_duration_) { |
DHISTOGRAM_TIMES("DNS.PrefetchNotFoundName", resolve_duration_); |
- // Record potential beneficial time, and maybe we'll get a cache hit. |
- benefits_remaining_ = std::max(resolve_duration_, benefits_remaining_); |
} |
sequence_number_ = sequence_counter++; |
DLogResultsStats("DNS PrefetchNotFound"); |
} |
-void UrlInfo::SetStartedState() { |
- DCHECK(PENDING == state_); |
- state_ = STARTED; |
- queue_duration_ = resolve_duration_ = TimeDelta(); // 0ms. |
- SetMotivation(NO_PREFETCH_MOTIVATION); |
- GetDuration(); // Set time. |
-} |
- |
-void UrlInfo::SetFinishedState(bool was_resolved) { |
- DCHECK(STARTED == state_); |
- state_ = was_resolved ? FINISHED : FINISHED_UNRESOLVED; |
- resolve_duration_ = GetDuration(); |
- // TODO(jar): Sequence number should be incremented in prefetched HostInfo. |
- DLogResultsStats("DNS HTTP Finished"); |
-} |
- |
void UrlInfo::SetUrl(const GURL& url) { |
if (url_.is_empty()) // Not yet initialized. |
url_ = url; |
@@ -195,65 +172,12 @@ |
return time_since_resolution < kCacheExpirationDuration; |
} |
-// Compare the actual navigation DNS latency found in navigation_info, to the |
-// previously prefetched info. |
-DnsBenefit UrlInfo::AccruePrefetchBenefits(UrlInfo* navigation_info) { |
- DCHECK(FINISHED == navigation_info->state_ || |
- FINISHED_UNRESOLVED == navigation_info->state_); |
- DCHECK(navigation_info->url() == url_); |
- |
- if ((0 == benefits_remaining_.InMilliseconds()) || |
- (FOUND != state_ && NO_SUCH_NAME != state_)) { |
- if (FINISHED == navigation_info->state_) |
- UMA_HISTOGRAM_LONG_TIMES("DNS.IndependentNavigation", |
- navigation_info->resolve_duration_); |
- else |
- UMA_HISTOGRAM_LONG_TIMES("DNS.IndependentFailedNavigation", |
- navigation_info->resolve_duration_); |
- return PREFETCH_NO_BENEFIT; |
- } |
- |
- TimeDelta benefit = benefits_remaining_ - navigation_info->resolve_duration_; |
- navigation_info->benefits_remaining_ = benefits_remaining_; |
- benefits_remaining_ = TimeDelta(); // We used up all our benefits here. |
- |
- navigation_info->motivation_ = motivation_; |
- if (LEARNED_REFERAL_MOTIVATED == motivation_ || |
- STATIC_REFERAL_MOTIVATED == motivation_) |
- navigation_info->referring_url_ = referring_url_; |
- |
- if (navigation_info->resolve_duration_ > kMaxNonNetworkDnsLookupDuration) { |
- // Our precache effort didn't help since HTTP stack hit the network. |
- UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchCacheEvictionL", resolve_duration_); |
- DLogResultsStats("DNS PrefetchCacheEviction"); |
- return PREFETCH_CACHE_EVICTION; |
- } |
- |
- if (NO_SUCH_NAME == state_) { |
- UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchNegativeHitL", benefit); |
- DLogResultsStats("DNS PrefetchNegativeHit"); |
- return PREFETCH_NAME_NONEXISTANT; |
- } |
- |
- DCHECK_EQ(FOUND, state_); |
- if (LEARNED_REFERAL_MOTIVATED == motivation_ || |
- STATIC_REFERAL_MOTIVATED == motivation_) { |
- UMA_HISTOGRAM_TIMES("DNS.PrefetchReferredPositiveHit", benefit); |
- DLogResultsStats("DNS PrefetchReferredPositiveHit"); |
- } else { |
- UMA_HISTOGRAM_LONG_TIMES("DNS.PrefetchPositiveHitL", benefit); |
- DLogResultsStats("DNS PrefetchPositiveHit"); |
- } |
- return PREFETCH_NAME_FOUND; |
-} |
- |
void UrlInfo::DLogResultsStats(const char* message) const { |
if (!detailed_logging_enabled) |
return; |
DLOG(INFO) << "\t" << message << "\tq=" |
<< queue_duration().InMilliseconds() << "ms,\tr=" |
<< resolve_duration().InMilliseconds() << "ms\tp=" |
- << benefits_remaining_.InMilliseconds() << "ms\tseq=" |
<< sequence_number_ |
<< "\t" << url_.spec(); |
} |
@@ -329,7 +253,7 @@ |
} |
// static |
-void UrlInfo::GetHtmlTable(const DnsInfoTable host_infos, |
+void UrlInfo::GetHtmlTable(const UrlInfoTable host_infos, |
const char* description, |
const bool brief, |
std::string* output) { |
@@ -344,53 +268,29 @@ |
return; |
} |
- const char* row_format = "<tr align=right><td>%s</td>" |
- "<td>%d</td><td>%d</td><td>%s</td><td>%s</td></tr>"; |
+ output->append("<br><table border=1>" |
+ "<tr><th>Host name</th>" |
+ "<th>How long ago<br>(HH:MM:SS)</th>" |
+ "<th>Motivation</th>" |
+ "</tr>"); |
- output->append("<br><table border=1>"); |
- StringAppendF(output, |
- "<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>", |
- "Host name", "Applicable Prefetch<br>Time (ms)", |
- "Recent Resolution<br>Time(ms)", "How long ago<br>(HH:MM:SS)", |
- "Motivation"); |
+ const char* row_format = "<tr align=right><td>%s</td>" // Host name. |
+ "<td>%s</td>" // How long ago. |
+ "<td>%s</td>" // Motivation. |
+ "</tr>"; |
// Print bulk of table, and gather stats at same time. |
- MinMaxAverage queue, resolve, preresolve, when; |
+ MinMaxAverage queue, when; |
TimeTicks current_time = TimeTicks::Now(); |
- for (DnsInfoTable::const_iterator it(host_infos.begin()); |
+ for (UrlInfoTable::const_iterator it(host_infos.begin()); |
it != host_infos.end(); it++) { |
queue.sample((it->queue_duration_.InMilliseconds())); |
StringAppendF(output, row_format, |
RemoveJs(it->url_.spec()).c_str(), |
- preresolve.sample((it->benefits_remaining_.InMilliseconds())), |
- resolve.sample((it->resolve_duration_.InMilliseconds())), |
HoursMinutesSeconds(when.sample( |
(current_time - it->time_).InSeconds())).c_str(), |
it->GetAsciiMotivation().c_str()); |
} |
- // Write min, max, and average summary lines. |
- if (host_infos.size() > 2) { |
- output->append("<B>"); |
- StringAppendF(output, row_format, |
- "<b>---minimum---</b>", |
- preresolve.minimum(), resolve.minimum(), |
- HoursMinutesSeconds(when.minimum()).c_str(), ""); |
- StringAppendF(output, row_format, |
- "<b>---average---</b>", |
- preresolve.average(), resolve.average(), |
- HoursMinutesSeconds(when.average()).c_str(), ""); |
- StringAppendF(output, row_format, |
- "<b>standard deviation</b>", |
- preresolve.standard_deviation(), |
- resolve.standard_deviation(), "n/a", ""); |
- StringAppendF(output, row_format, |
- "<b>---maximum---</b>", |
- preresolve.maximum(), resolve.maximum(), |
- HoursMinutesSeconds(when.maximum()).c_str(), ""); |
- StringAppendF(output, row_format, |
- "<b>-----SUM-----</b>", |
- preresolve.sum(), resolve.sum(), "n/a", ""); |
- } |
output->append("</table>"); |
#ifdef DEBUG |