OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/net/predictor.h" | 5 #include "chrome/browser/net/predictor.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/histogram.h" | 12 #include "base/histogram.h" |
13 #include "base/stats_counters.h" | 13 #include "base/stats_counters.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/chrome_thread.h" | 16 #include "chrome/browser/chrome_thread.h" |
17 #include "chrome/browser/net/preconnect.h" | 17 #include "chrome/browser/net/preconnect.h" |
18 #include "net/base/address_list.h" | 18 #include "net/base/address_list.h" |
19 #include "net/base/completion_callback.h" | 19 #include "net/base/completion_callback.h" |
20 #include "net/base/host_port_pair.h" | 20 #include "net/base/host_port_pair.h" |
21 #include "net/base/host_resolver.h" | 21 #include "net/base/host_resolver.h" |
22 #include "net/base/net_errors.h" | 22 #include "net/base/net_errors.h" |
23 #include "net/base/net_log.h" | 23 #include "net/base/net_log.h" |
24 | 24 |
25 using base::TimeDelta; | 25 using base::TimeDelta; |
26 | 26 |
27 namespace chrome_browser_net { | 27 namespace chrome_browser_net { |
28 | 28 |
| 29 // static |
| 30 const double Predictor::kPreconnectWorthyExpectedValue = 0.7; |
| 31 // static |
| 32 const double Predictor::kDNSPreresolutionWorthyExpectedValue = 0.2; |
| 33 // static |
| 34 const double Predictor::kPersistWorthyExpectedValue = 0.1; |
| 35 |
| 36 |
29 class Predictor::LookupRequest { | 37 class Predictor::LookupRequest { |
30 public: | 38 public: |
31 LookupRequest(Predictor* predictor, | 39 LookupRequest(Predictor* predictor, |
32 net::HostResolver* host_resolver, | 40 net::HostResolver* host_resolver, |
33 const GURL& url) | 41 const GURL& url) |
34 : ALLOW_THIS_IN_INITIALIZER_LIST( | 42 : ALLOW_THIS_IN_INITIALIZER_LIST( |
35 net_callback_(this, &LookupRequest::OnLookupFinished)), | 43 net_callback_(this, &LookupRequest::OnLookupFinished)), |
36 predictor_(predictor), | 44 predictor_(predictor), |
37 url_(url), | 45 url_(url), |
38 resolver_(host_resolver) { | 46 resolver_(host_resolver) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Basic Resolve() takes an invidual name, and adds it | 119 // Basic Resolve() takes an invidual name, and adds it |
112 // to the queue. | 120 // to the queue. |
113 void Predictor::Resolve(const GURL& url, | 121 void Predictor::Resolve(const GURL& url, |
114 UrlInfo::ResolutionMotivation motivation) { | 122 UrlInfo::ResolutionMotivation motivation) { |
115 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 123 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
116 if (!url.has_host()) | 124 if (!url.has_host()) |
117 return; | 125 return; |
118 AppendToResolutionQueue(url, motivation); | 126 AppendToResolutionQueue(url, motivation); |
119 } | 127 } |
120 | 128 |
121 bool Predictor::AccruePrefetchBenefits(const GURL& referrer, | |
122 UrlInfo* navigation_info) { | |
123 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | |
124 GURL url = navigation_info->url(); | |
125 Results::iterator it = results_.find(url); | |
126 if (it == results_.end()) { | |
127 // Use UMA histogram to quantify potential future gains here. | |
128 UMA_HISTOGRAM_LONG_TIMES("DNS.UnexpectedResolutionL", | |
129 navigation_info->resolve_duration()); | |
130 navigation_info->DLogResultsStats("DNS UnexpectedResolution"); | |
131 | |
132 LearnFromNavigation(referrer, navigation_info->url()); | |
133 return false; | |
134 } | |
135 UrlInfo& prefetched_host_info(it->second); | |
136 | |
137 // Sometimes a host is used as a subresource by several referrers, so it is | |
138 // in our list, but was never motivated by a page-link-scan. In that case, it | |
139 // really is an "unexpected" navigation, and we should tally it, and augment | |
140 // our referrers_. | |
141 bool referrer_based_prefetch = !prefetched_host_info.was_linked(); | |
142 if (referrer_based_prefetch) { | |
143 // This wasn't the first time this host refered to *some* referrer. | |
144 LearnFromNavigation(referrer, navigation_info->url()); | |
145 } | |
146 | |
147 DnsBenefit benefit = prefetched_host_info.AccruePrefetchBenefits( | |
148 navigation_info); | |
149 switch (benefit) { | |
150 case PREFETCH_NAME_FOUND: | |
151 case PREFETCH_NAME_NONEXISTANT: | |
152 dns_cache_hits_.push_back(*navigation_info); | |
153 if (referrer_based_prefetch) { | |
154 if (referrer.has_host()) { | |
155 referrers_[referrer].AccrueValue( | |
156 navigation_info->benefits_remaining(), url); | |
157 } | |
158 } | |
159 return true; | |
160 | |
161 case PREFETCH_CACHE_EVICTION: | |
162 cache_eviction_map_[url] = *navigation_info; | |
163 return false; | |
164 | |
165 case PREFETCH_NO_BENEFIT: | |
166 // Prefetch never hit the network. Name was pre-cached. | |
167 return false; | |
168 | |
169 default: | |
170 NOTREACHED(); | |
171 return false; | |
172 } | |
173 } | |
174 | |
175 void Predictor::LearnFromNavigation(const GURL& referring_url, | 129 void Predictor::LearnFromNavigation(const GURL& referring_url, |
176 const GURL& target_url) { | 130 const GURL& target_url) { |
177 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 131 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
178 if (referring_url.has_host() && | 132 if (referring_url.has_host() && |
179 referring_url != target_url) { | 133 referring_url != target_url) { |
180 DCHECK(referring_url == referring_url.GetWithEmptyPath()); | 134 DCHECK(referring_url == referring_url.GetWithEmptyPath()); |
181 referrers_[referring_url].SuggestHost(target_url); | 135 referrers_[referring_url].SuggestHost(target_url); |
182 } | 136 } |
183 } | 137 } |
184 | 138 |
185 void Predictor::PredictSubresources(const GURL& url) { | 139 enum SubresourceValue { |
186 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 140 PRECONNECTION, |
187 Referrers::iterator it = referrers_.find(url); | 141 PRERESOLUTION, |
188 if (referrers_.end() == it) | 142 TOO_NEW, |
189 return; | 143 SUBRESOURCE_VALUE_MAX |
190 Referrer* referrer = &(it->second); | 144 }; |
191 referrer->IncrementUseCount(); | |
192 for (Referrer::iterator future_url = referrer->begin(); | |
193 future_url != referrer->end(); ++future_url) { | |
194 UrlInfo* queued_info = AppendToResolutionQueue( | |
195 future_url->first, | |
196 UrlInfo::LEARNED_REFERAL_MOTIVATED); | |
197 if (queued_info) | |
198 queued_info->SetReferringHostname(url); | |
199 } | |
200 } | |
201 | 145 |
202 void Predictor::PredictFrameSubresources(const GURL& url) { | 146 void Predictor::PredictFrameSubresources(const GURL& url) { |
203 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 147 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
204 DCHECK(url.GetWithEmptyPath() == url); | 148 DCHECK(url.GetWithEmptyPath() == url); |
205 Referrers::iterator it = referrers_.find(url); | 149 Referrers::iterator it = referrers_.find(url); |
206 if (referrers_.end() == it) | 150 if (referrers_.end() == it) |
207 return; | 151 return; |
208 Referrer* referrer = &(it->second); | 152 Referrer* referrer = &(it->second); |
209 referrer->IncrementUseCount(); | 153 referrer->IncrementUseCount(); |
| 154 const UrlInfo::ResolutionMotivation motivation = |
| 155 UrlInfo::LEARNED_REFERAL_MOTIVATED; |
210 for (Referrer::iterator future_url = referrer->begin(); | 156 for (Referrer::iterator future_url = referrer->begin(); |
211 future_url != referrer->end(); ++future_url) { | 157 future_url != referrer->end(); ++future_url) { |
212 if (future_url->second.IsPreconnectWorthDoing()) | 158 SubresourceValue evalution(TOO_NEW); |
213 Preconnect::PreconnectOnIOThread(future_url->first); | 159 double connection_expectation = future_url->second.subresource_use_rate(); |
| 160 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.PreconnectSubresourceExpectation", |
| 161 static_cast<int>(connection_expectation * 100), |
| 162 10, 5000, 50); |
| 163 future_url->second.ReferrerWasObserved(); |
| 164 if (preconnect_enabled_ && |
| 165 kPreconnectWorthyExpectedValue < connection_expectation) { |
| 166 evalution = PRECONNECTION; |
| 167 future_url->second.IncrementPreconnectionCount(); |
| 168 Preconnect::PreconnectOnIOThread(future_url->first, motivation); |
| 169 } else if (kDNSPreresolutionWorthyExpectedValue < connection_expectation) { |
| 170 evalution = PRERESOLUTION; |
| 171 future_url->second.preresolution_increment(); |
| 172 UrlInfo* queued_info = AppendToResolutionQueue(future_url->first, |
| 173 motivation); |
| 174 if (queued_info) |
| 175 queued_info->SetReferringHostname(url); |
| 176 } |
| 177 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectSubresourceEval", evalution, |
| 178 SUBRESOURCE_VALUE_MAX); |
214 } | 179 } |
215 } | 180 } |
216 | 181 |
217 // Provide sort order so all .com's are together, etc. | 182 // Provide sort order so all .com's are together, etc. |
218 struct RightToLeftStringSorter { | 183 struct RightToLeftStringSorter { |
219 bool operator()(const net::HostPortPair& left, | |
220 const net::HostPortPair& right) const { | |
221 return string_compare(left.host(), right.host()); | |
222 } | |
223 bool operator()(const GURL& left, | 184 bool operator()(const GURL& left, |
224 const GURL& right) const { | 185 const GURL& right) const { |
225 return string_compare(left.host(), right.host()); | 186 return string_compare(left.host(), right.host()); |
226 } | 187 } |
227 | 188 |
228 static bool string_compare(const std::string& left_host, | 189 static bool string_compare(const std::string& left_host, |
229 const std::string right_host) { | 190 const std::string right_host) { |
230 if (left_host == right_host) return true; | 191 if (left_host == right_host) return true; |
231 size_t left_already_matched = left_host.size(); | 192 size_t left_already_matched = left_host.size(); |
232 size_t right_already_matched = right_host.size(); | 193 size_t right_already_matched = right_host.size(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 for (Referrers::iterator it = referrers_.begin(); | 255 for (Referrers::iterator it = referrers_.begin(); |
295 referrers_.end() != it; ++it) | 256 referrers_.end() != it; ++it) |
296 sorted_names.insert(it->first); | 257 sorted_names.insert(it->first); |
297 | 258 |
298 output->append("<br><table border>"); | 259 output->append("<br><table border>"); |
299 output->append( | 260 output->append( |
300 "<tr><th>Host for Page</th>" | 261 "<tr><th>Host for Page</th>" |
301 "<th>Page Load<br>Count</th>" | 262 "<th>Page Load<br>Count</th>" |
302 "<th>Subresource<br>Navigations</th>" | 263 "<th>Subresource<br>Navigations</th>" |
303 "<th>Subresource<br>PreConnects</th>" | 264 "<th>Subresource<br>PreConnects</th>" |
| 265 "<th>Subresource<br>PreResolves</th>" |
304 "<th>Expected<br>Connects</th>" | 266 "<th>Expected<br>Connects</th>" |
305 "<th>DNS<br>Savings</th>" | |
306 "<th>Subresource Spec</th></tr>"); | 267 "<th>Subresource Spec</th></tr>"); |
307 | 268 |
308 for (SortedNames::iterator it = sorted_names.begin(); | 269 for (SortedNames::iterator it = sorted_names.begin(); |
309 sorted_names.end() != it; ++it) { | 270 sorted_names.end() != it; ++it) { |
310 Referrer* referrer = &(referrers_[*it]); | 271 Referrer* referrer = &(referrers_[*it]); |
311 bool first_set_of_futures = true; | 272 bool first_set_of_futures = true; |
312 for (Referrer::iterator future_url = referrer->begin(); | 273 for (Referrer::iterator future_url = referrer->begin(); |
313 future_url != referrer->end(); ++future_url) { | 274 future_url != referrer->end(); ++future_url) { |
314 output->append("<tr align=right>"); | 275 output->append("<tr align=right>"); |
315 if (first_set_of_futures) | 276 if (first_set_of_futures) |
316 StringAppendF(output, "<td rowspan=%d>%s</td><td rowspan=%d>%d</td>", | 277 StringAppendF(output, "<td rowspan=%d>%s</td><td rowspan=%d>%d</td>", |
317 static_cast<int>(referrer->size()), | 278 static_cast<int>(referrer->size()), |
318 it->spec().c_str(), | 279 it->spec().c_str(), |
319 static_cast<int>(referrer->size()), | 280 static_cast<int>(referrer->size()), |
320 static_cast<int>(referrer->use_count())); | 281 static_cast<int>(referrer->use_count())); |
321 first_set_of_futures = false; | 282 first_set_of_futures = false; |
322 StringAppendF(output, | 283 StringAppendF(output, |
323 "<td>%d</td><td>%d</td><td>%2.3f</td><td>%dms</td><td>%s</td></tr>", | 284 "<td>%d</td><td>%d</td><td>%d</td><td>%2.3f</td><td>%s</td></tr>", |
324 static_cast<int>(future_url->second.navigation_count()), | 285 static_cast<int>(future_url->second.navigation_count()), |
325 static_cast<int>(future_url->second.preconnection_count()), | 286 static_cast<int>(future_url->second.preconnection_count()), |
| 287 static_cast<int>(future_url->second.preresolution_count()), |
326 static_cast<double>(future_url->second.subresource_use_rate()), | 288 static_cast<double>(future_url->second.subresource_use_rate()), |
327 static_cast<int>(future_url->second.latency().InMilliseconds()), | |
328 future_url->first.spec().c_str()); | 289 future_url->first.spec().c_str()); |
329 } | 290 } |
330 } | 291 } |
331 output->append("</table>"); | 292 output->append("</table>"); |
332 } | 293 } |
333 | 294 |
334 void Predictor::GetHtmlInfo(std::string* output) { | 295 void Predictor::GetHtmlInfo(std::string* output) { |
335 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 296 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
336 // Local lists for calling UrlInfo | 297 // Local lists for calling UrlInfo |
337 UrlInfo::DnsInfoTable cache_hits; | 298 UrlInfo::UrlInfoTable name_not_found; |
338 UrlInfo::DnsInfoTable cache_evictions; | 299 UrlInfo::UrlInfoTable name_preresolved; |
339 UrlInfo::DnsInfoTable name_not_found; | |
340 UrlInfo::DnsInfoTable network_hits; | |
341 UrlInfo::DnsInfoTable already_cached; | |
342 | 300 |
343 // Get copies of all useful data. | 301 // Get copies of all useful data. |
344 typedef std::map<GURL, UrlInfo, RightToLeftStringSorter> | 302 typedef std::map<GURL, UrlInfo, RightToLeftStringSorter> SortedUrlInfo; |
345 Snapshot; | 303 SortedUrlInfo snapshot; |
346 Snapshot snapshot; | 304 // UrlInfo supports value semantics, so we can do a shallow copy. |
347 { | 305 for (Results::iterator it(results_.begin()); it != results_.end(); it++) |
348 // UrlInfo supports value semantics, so we can do a shallow copy. | 306 snapshot[it->first] = it->second; |
349 for (Results::iterator it(results_.begin()); it != results_.end(); it++) { | |
350 snapshot[it->first] = it->second; | |
351 } | |
352 for (Results::iterator it(cache_eviction_map_.begin()); | |
353 it != cache_eviction_map_.end(); | |
354 it++) { | |
355 cache_evictions.push_back(it->second); | |
356 } | |
357 // Reverse list as we copy cache hits, so that new hits are at the top. | |
358 size_t index = dns_cache_hits_.size(); | |
359 while (index > 0) { | |
360 index--; | |
361 cache_hits.push_back(dns_cache_hits_[index]); | |
362 } | |
363 } | |
364 | 307 |
365 // Partition the UrlInfo's into categories. | 308 // Partition the UrlInfo's into categories. |
366 for (Snapshot::iterator it(snapshot.begin()); it != snapshot.end(); it++) { | 309 for (SortedUrlInfo::iterator it(snapshot.begin()); |
| 310 it != snapshot.end(); it++) { |
367 if (it->second.was_nonexistant()) { | 311 if (it->second.was_nonexistant()) { |
368 name_not_found.push_back(it->second); | 312 name_not_found.push_back(it->second); |
369 continue; | 313 continue; |
370 } | 314 } |
371 if (!it->second.was_found()) | 315 if (!it->second.was_found()) |
372 continue; // Still being processed. | 316 continue; // Still being processed. |
373 if (TimeDelta() != it->second.benefits_remaining()) { | 317 name_preresolved.push_back(it->second); |
374 network_hits.push_back(it->second); // With no benefit yet. | |
375 continue; | |
376 } | |
377 if (UrlInfo::kMaxNonNetworkDnsLookupDuration > | |
378 it->second.resolve_duration()) { | |
379 already_cached.push_back(it->second); | |
380 continue; | |
381 } | |
382 // Remaining case is where prefetch benefit was significant, and was used. | |
383 // Since we shot those cases as historical hits, we won't bother here. | |
384 } | 318 } |
385 | 319 |
386 bool brief = false; | 320 bool brief = false; |
387 #ifdef NDEBUG | 321 #ifdef NDEBUG |
388 brief = true; | 322 brief = true; |
389 #endif // NDEBUG | 323 #endif // NDEBUG |
390 | 324 |
391 // Call for display of each table, along with title. | 325 // Call for display of each table, along with title. |
392 UrlInfo::GetHtmlTable(cache_hits, | 326 UrlInfo::GetHtmlTable(name_preresolved, |
393 "Prefetching DNS records produced benefits for ", false, output); | 327 "Preresolution DNS records performed for ", brief, output); |
394 UrlInfo::GetHtmlTable(cache_evictions, | |
395 "Cache evictions negated DNS prefetching benefits for ", brief, output); | |
396 UrlInfo::GetHtmlTable(network_hits, | |
397 "Prefetching DNS records was not yet beneficial for ", brief, output); | |
398 UrlInfo::GetHtmlTable(already_cached, | |
399 "Previously cached resolutions were found for ", brief, output); | |
400 UrlInfo::GetHtmlTable(name_not_found, | 328 UrlInfo::GetHtmlTable(name_not_found, |
401 "Prefetching DNS records revealed non-existance for ", brief, output); | 329 "Preresolving DNS records revealed non-existance for ", brief, output); |
402 } | 330 } |
403 | 331 |
404 UrlInfo* Predictor::AppendToResolutionQueue( | 332 UrlInfo* Predictor::AppendToResolutionQueue( |
405 const GURL& url, | 333 const GURL& url, |
406 UrlInfo::ResolutionMotivation motivation) { | 334 UrlInfo::ResolutionMotivation motivation) { |
407 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 335 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
408 DCHECK(url.has_host()); | 336 DCHECK(url.has_host()); |
409 | 337 |
410 if (shutdown_) | 338 if (shutdown_) |
411 return NULL; | 339 return NULL; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 if (found) | 428 if (found) |
501 info->SetFoundState(); | 429 info->SetFoundState(); |
502 else | 430 else |
503 info->SetNoSuchNameState(); | 431 info->SetNoSuchNameState(); |
504 } | 432 } |
505 } | 433 } |
506 | 434 |
507 void Predictor::DiscardAllResults() { | 435 void Predictor::DiscardAllResults() { |
508 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 436 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
509 // Delete anything listed so far in this session that shows in about:dns. | 437 // Delete anything listed so far in this session that shows in about:dns. |
510 cache_eviction_map_.clear(); | |
511 dns_cache_hits_.clear(); | |
512 referrers_.clear(); | 438 referrers_.clear(); |
513 | 439 |
514 | 440 |
515 // Try to delete anything in our work queue. | 441 // Try to delete anything in our work queue. |
516 while (!work_queue_.IsEmpty()) { | 442 while (!work_queue_.IsEmpty()) { |
517 // Emulate processing cycle as though host was not found. | 443 // Emulate processing cycle as though host was not found. |
518 GURL url = work_queue_.Pop(); | 444 GURL url = work_queue_.Pop(); |
519 UrlInfo* info = &results_[url]; | 445 UrlInfo* info = &results_[url]; |
520 DCHECK(info->HasUrl(url)); | 446 DCHECK(info->HasUrl(url)); |
521 info->SetAssignedState(); | 447 info->SetAssignedState(); |
(...skipping 30 matching lines...) Expand all Loading... |
552 it != referrers_.end(); ++it) | 478 it != referrers_.end(); ++it) |
553 urls.push_back(it->first); | 479 urls.push_back(it->first); |
554 for (size_t i = 0; i < urls.size(); ++i) | 480 for (size_t i = 0; i < urls.size(); ++i) |
555 if (!referrers_[urls[i]].Trim()) | 481 if (!referrers_[urls[i]].Trim()) |
556 referrers_.erase(urls[i]); | 482 referrers_.erase(urls[i]); |
557 } | 483 } |
558 | 484 |
559 void Predictor::SerializeReferrers(ListValue* referral_list) { | 485 void Predictor::SerializeReferrers(ListValue* referral_list) { |
560 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 486 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
561 referral_list->Clear(); | 487 referral_list->Clear(); |
562 referral_list->Append(new FundamentalValue(DNS_REFERRER_VERSION)); | 488 referral_list->Append(new FundamentalValue(PREDICTOR_REFERRER_VERSION)); |
563 for (Referrers::const_iterator it = referrers_.begin(); | 489 for (Referrers::const_iterator it = referrers_.begin(); |
564 it != referrers_.end(); ++it) { | 490 it != referrers_.end(); ++it) { |
565 // Serialize the list of subresource names. | 491 // Serialize the list of subresource names. |
566 Value* subresource_list(it->second.Serialize()); | 492 Value* subresource_list(it->second.Serialize()); |
567 | 493 |
568 // Create a list for each referer. | 494 // Create a list for each referer. |
569 ListValue* motivator(new ListValue); | 495 ListValue* motivator(new ListValue); |
570 motivator->Append(new StringValue(it->first.spec())); | 496 motivator->Append(new StringValue(it->first.spec())); |
571 motivator->Append(subresource_list); | 497 motivator->Append(subresource_list); |
572 | 498 |
573 referral_list->Append(motivator); | 499 referral_list->Append(motivator); |
574 } | 500 } |
575 } | 501 } |
576 | 502 |
577 void Predictor::DeserializeReferrers(const ListValue& referral_list) { | 503 void Predictor::DeserializeReferrers(const ListValue& referral_list) { |
578 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 504 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
579 int format_version = -1; | 505 int format_version = -1; |
580 if (referral_list.GetSize() > 0 && | 506 if (referral_list.GetSize() > 0 && |
581 referral_list.GetInteger(0, &format_version) && | 507 referral_list.GetInteger(0, &format_version) && |
582 format_version == DNS_REFERRER_VERSION) { | 508 format_version == PREDICTOR_REFERRER_VERSION) { |
583 for (size_t i = 1; i < referral_list.GetSize(); ++i) { | 509 for (size_t i = 1; i < referral_list.GetSize(); ++i) { |
584 ListValue* motivator; | 510 ListValue* motivator; |
585 if (!referral_list.GetList(i, &motivator)) { | 511 if (!referral_list.GetList(i, &motivator)) { |
586 NOTREACHED(); | 512 NOTREACHED(); |
587 return; | 513 return; |
588 } | 514 } |
589 std::string motivating_url_spec; | 515 std::string motivating_url_spec; |
590 if (!motivator->GetString(0, &motivating_url_spec)) { | 516 if (!motivator->GetString(0, &motivating_url_spec)) { |
591 NOTREACHED(); | 517 NOTREACHED(); |
592 return; | 518 return; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 GURL Predictor::HostNameQueue::Pop() { | 560 GURL Predictor::HostNameQueue::Pop() { |
635 DCHECK(!IsEmpty()); | 561 DCHECK(!IsEmpty()); |
636 std::queue<GURL> *queue(rush_queue_.empty() ? &background_queue_ | 562 std::queue<GURL> *queue(rush_queue_.empty() ? &background_queue_ |
637 : &rush_queue_); | 563 : &rush_queue_); |
638 GURL url(queue->front()); | 564 GURL url(queue->front()); |
639 queue->pop(); | 565 queue->pop(); |
640 return url; | 566 return url; |
641 } | 567 } |
642 | 568 |
643 } // namespace chrome_browser_net | 569 } // namespace chrome_browser_net |
OLD | NEW |