Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <cmath> | 8 #include <cmath> |
| 9 #include <iterator> | 9 #include <iterator> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <sstream> | 11 #include <sstream> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/callback.h" | |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/containers/mru_cache.h" | 17 #include "base/containers/mru_cache.h" |
| 17 #include "base/location.h" | 18 #include "base/location.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/macros.h" | 20 #include "base/macros.h" |
| 20 #include "base/memory/ptr_util.h" | 21 #include "base/memory/ptr_util.h" |
| 21 #include "base/metrics/histogram.h" | 22 #include "base/metrics/histogram.h" |
| 22 #include "base/single_thread_task_runner.h" | 23 #include "base/single_thread_task_runner.h" |
| 23 #include "base/stl_util.h" | 24 #include "base/stl_util.h" |
| 24 #include "base/strings/stringprintf.h" | 25 #include "base/strings/stringprintf.h" |
| 25 #include "base/synchronization/waitable_event.h" | 26 #include "base/synchronization/waitable_event.h" |
|
mmenke
2016/08/01 17:41:25
Header no longer needed.
Charlie Harrison
2016/08/01 17:48:09
Done.
| |
| 26 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
| 27 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
| 28 #include "base/time/time.h" | 29 #include "base/time/time.h" |
| 29 #include "base/values.h" | 30 #include "base/values.h" |
| 30 #include "chrome/browser/io_thread.h" | 31 #include "chrome/browser/io_thread.h" |
| 31 #include "chrome/browser/prefs/session_startup_pref.h" | 32 #include "chrome/browser/prefs/session_startup_pref.h" |
| 32 #include "chrome/browser/profiles/profile_io_data.h" | 33 #include "chrome/browser/profiles/profile_io_data.h" |
| 33 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 35 #include "components/pref_registry/pref_registry_syncable.h" | 36 #include "components/pref_registry/pref_registry_syncable.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 max_dns_queue_delay_( | 105 max_dns_queue_delay_( |
| 105 TimeDelta::FromMilliseconds(g_max_queueing_delay_ms)), | 106 TimeDelta::FromMilliseconds(g_max_queueing_delay_ms)), |
| 106 transport_security_state_(nullptr), | 107 transport_security_state_(nullptr), |
| 107 ssl_config_service_(nullptr), | 108 ssl_config_service_(nullptr), |
| 108 proxy_service_(nullptr), | 109 proxy_service_(nullptr), |
| 109 preconnect_enabled_(preconnect_enabled), | 110 preconnect_enabled_(preconnect_enabled), |
| 110 consecutive_omnibox_preconnect_count_(0), | 111 consecutive_omnibox_preconnect_count_(0), |
| 111 referrers_(kMaxReferrers), | 112 referrers_(kMaxReferrers), |
| 112 observer_(nullptr), | 113 observer_(nullptr), |
| 113 timed_cache_(new TimedCache(base::TimeDelta::FromSeconds( | 114 timed_cache_(new TimedCache(base::TimeDelta::FromSeconds( |
| 114 kMaxUnusedSocketLifetimeSecondsWithoutAGet))) { | 115 kMaxUnusedSocketLifetimeSecondsWithoutAGet))), |
| 116 ui_weak_factory_(new base::WeakPtrFactory<Predictor>(this)) { | |
| 115 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 116 } | 118 } |
| 117 | 119 |
| 118 Predictor::~Predictor() { | 120 Predictor::~Predictor() { |
| 119 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 121 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 120 DCHECK(shutdown_); | 122 DCHECK(shutdown_); |
| 121 } | 123 } |
| 122 | 124 |
| 123 // static | 125 // static |
| 124 Predictor* Predictor::CreatePredictor(bool preconnect_enabled, | 126 Predictor* Predictor::CreatePredictor(bool preconnect_enabled, |
| 125 bool predictor_enabled, | 127 bool predictor_enabled, |
| 126 bool simple_shutdown) { | 128 bool simple_shutdown) { |
| 127 if (simple_shutdown) | 129 if (simple_shutdown) |
| 128 return new SimplePredictor(preconnect_enabled, predictor_enabled); | 130 return new SimplePredictor(preconnect_enabled, predictor_enabled); |
| 129 return new Predictor(preconnect_enabled, predictor_enabled); | 131 return new Predictor(preconnect_enabled, predictor_enabled); |
| 130 } | 132 } |
| 131 | 133 |
| 132 void Predictor::RegisterProfilePrefs( | 134 void Predictor::RegisterProfilePrefs( |
| 133 user_prefs::PrefRegistrySyncable* registry) { | 135 user_prefs::PrefRegistrySyncable* registry) { |
| 134 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList); | 136 registry->RegisterListPref(prefs::kDnsPrefetchingStartupList, |
| 135 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList); | 137 PrefRegistry::LOSSY_PREF); |
| 138 registry->RegisterListPref(prefs::kDnsPrefetchingHostReferralList, | |
| 139 PrefRegistry::LOSSY_PREF); | |
| 136 } | 140 } |
| 137 | 141 |
| 138 // --------------------- Start UI methods. ------------------------------------ | 142 // --------------------- Start UI methods. ------------------------------------ |
| 139 | 143 |
| 140 void Predictor::InitNetworkPredictor(PrefService* user_prefs, | 144 void Predictor::InitNetworkPredictor(PrefService* user_prefs, |
| 141 IOThread* io_thread, | 145 IOThread* io_thread, |
| 142 net::URLRequestContextGetter* getter, | 146 net::URLRequestContextGetter* getter, |
| 143 ProfileIOData* profile_io_data) { | 147 ProfileIOData* profile_io_data) { |
| 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 148 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 145 | 149 |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 303 } | 307 } |
| 304 | 308 |
| 305 if (urls.empty()) | 309 if (urls.empty()) |
| 306 urls.push_back(GURL("http://www.google.com:80")); | 310 urls.push_back(GURL("http://www.google.com:80")); |
| 307 | 311 |
| 308 return urls; | 312 return urls; |
| 309 } | 313 } |
| 310 | 314 |
| 311 void Predictor::DiscardAllResultsAndClearPrefsOnUIThread() { | 315 void Predictor::DiscardAllResultsAndClearPrefsOnUIThread() { |
| 312 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 316 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 313 BrowserThread::PostTask( | 317 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
| 314 BrowserThread::IO, FROM_HERE, | 318 base::Bind(&Predictor::DiscardAllResults, |
| 315 base::Bind(&Predictor::DiscardAllResults, weak_factory_->GetWeakPtr())); | 319 io_weak_factory_->GetWeakPtr())); |
| 316 ClearPrefsOnUIThread(); | 320 ClearPrefsOnUIThread(); |
| 317 } | 321 } |
| 318 | 322 |
| 319 void Predictor::ClearPrefsOnUIThread() { | 323 void Predictor::ClearPrefsOnUIThread() { |
| 320 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 324 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 321 user_prefs_->ClearPref(prefs::kDnsPrefetchingStartupList); | 325 user_prefs_->ClearPref(prefs::kDnsPrefetchingStartupList); |
| 322 user_prefs_->ClearPref(prefs::kDnsPrefetchingHostReferralList); | 326 user_prefs_->ClearPref(prefs::kDnsPrefetchingHostReferralList); |
| 323 } | 327 } |
| 324 | 328 |
| 325 void Predictor::set_max_queueing_delay(int max_queueing_delay_ms) { | 329 void Predictor::set_max_queueing_delay(int max_queueing_delay_ms) { |
| 326 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 330 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 327 g_max_queueing_delay_ms = max_queueing_delay_ms; | 331 g_max_queueing_delay_ms = max_queueing_delay_ms; |
| 328 } | 332 } |
| 329 | 333 |
| 330 void Predictor::set_max_parallel_resolves(size_t max_parallel_resolves) { | 334 void Predictor::set_max_parallel_resolves(size_t max_parallel_resolves) { |
| 331 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 335 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 332 g_max_parallel_resolves = max_parallel_resolves; | 336 g_max_parallel_resolves = max_parallel_resolves; |
| 333 } | 337 } |
| 334 | 338 |
| 335 void Predictor::ShutdownOnUIThread() { | 339 void Predictor::ShutdownOnUIThread() { |
| 336 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 340 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 341 ui_weak_factory_->InvalidateWeakPtrs(); | |
| 337 BrowserThread::PostTask( | 342 BrowserThread::PostTask( |
| 338 BrowserThread::IO, | 343 BrowserThread::IO, |
| 339 FROM_HERE, | 344 FROM_HERE, |
| 340 base::Bind(&Predictor::Shutdown, base::Unretained(this))); | 345 base::Bind(&Predictor::Shutdown, base::Unretained(this))); |
| 341 } | 346 } |
| 342 | 347 |
| 343 // ---------------------- End UI methods. ------------------------------------- | 348 // ---------------------- End UI methods. ------------------------------------- |
| 344 | 349 |
| 345 // --------------------- Start IO methods. ------------------------------------ | 350 // --------------------- Start IO methods. ------------------------------------ |
| 346 | 351 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 UrlInfo::GetHtmlTable(name_preresolved, | 533 UrlInfo::GetHtmlTable(name_preresolved, |
| 529 "Preresolution DNS records performed for ", brief, output); | 534 "Preresolution DNS records performed for ", brief, output); |
| 530 UrlInfo::GetHtmlTable(name_not_found, | 535 UrlInfo::GetHtmlTable(name_not_found, |
| 531 "Preresolving DNS records revealed non-existence for ", brief, output); | 536 "Preresolving DNS records revealed non-existence for ", brief, output); |
| 532 } | 537 } |
| 533 | 538 |
| 534 // Iterating through a MRUCache goes through most recent first. Iterate | 539 // Iterating through a MRUCache goes through most recent first. Iterate |
| 535 // backwards here so that adding items in order "Just Works" when deserializing. | 540 // backwards here so that adding items in order "Just Works" when deserializing. |
| 536 void Predictor::SerializeReferrers(base::ListValue* referral_list) { | 541 void Predictor::SerializeReferrers(base::ListValue* referral_list) { |
| 537 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 542 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 538 referral_list->Clear(); | 543 DCHECK(referral_list->empty()); |
| 539 referral_list->AppendInteger(kPredictorReferrerVersion); | 544 referral_list->AppendInteger(kPredictorReferrerVersion); |
| 540 for (Referrers::const_reverse_iterator it = referrers_.rbegin(); | 545 for (Referrers::const_reverse_iterator it = referrers_.rbegin(); |
| 541 it != referrers_.rend(); ++it) { | 546 it != referrers_.rend(); ++it) { |
| 542 // Serialize the list of subresource names. | 547 // Serialize the list of subresource names. |
| 543 base::Value* subresource_list(it->second.Serialize()); | 548 base::Value* subresource_list(it->second.Serialize()); |
| 544 | 549 |
| 545 // Create a list for each referer. | 550 // Create a list for each referer. |
| 546 std::unique_ptr<base::ListValue> motivator(new base::ListValue); | 551 std::unique_ptr<base::ListValue> motivator(new base::ListValue); |
| 547 motivator->AppendString(it->first.spec()); | 552 motivator->AppendString(it->first.spec()); |
| 548 motivator->Append(subresource_list); | 553 motivator->Append(subresource_list); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 597 profile_io_data_ = profile_io_data; | 602 profile_io_data_ = profile_io_data; |
| 598 initial_observer_.reset(new InitialObserver()); | 603 initial_observer_.reset(new InitialObserver()); |
| 599 | 604 |
| 600 net::URLRequestContext* context = | 605 net::URLRequestContext* context = |
| 601 url_request_context_getter_->GetURLRequestContext(); | 606 url_request_context_getter_->GetURLRequestContext(); |
| 602 transport_security_state_ = context->transport_security_state(); | 607 transport_security_state_ = context->transport_security_state(); |
| 603 ssl_config_service_ = context->ssl_config_service(); | 608 ssl_config_service_ = context->ssl_config_service(); |
| 604 proxy_service_ = context->proxy_service(); | 609 proxy_service_ = context->proxy_service(); |
| 605 | 610 |
| 606 // base::WeakPtrFactory instances need to be created and destroyed | 611 // base::WeakPtrFactory instances need to be created and destroyed |
| 607 // on the same thread. The predictor lives on the IO thread and will die | 612 // on the same thread. Initialize the IO thread weak factory now. |
| 608 // from there so now that we're on the IO thread we need to properly | 613 io_weak_factory_.reset(new base::WeakPtrFactory<Predictor>(this)); |
| 609 // initialize the base::WeakPtrFactory. | |
| 610 // TODO(groby): Check if WeakPtrFactory has the same constraint. | |
| 611 weak_factory_.reset(new base::WeakPtrFactory<Predictor>(this)); | |
| 612 | 614 |
| 613 // Prefetch these hostnames on startup. | 615 // Prefetch these hostnames on startup. |
| 614 DnsPrefetchMotivatedList(startup_urls, UrlInfo::STARTUP_LIST_MOTIVATED); | 616 DnsPrefetchMotivatedList(startup_urls, UrlInfo::STARTUP_LIST_MOTIVATED); |
| 615 | 617 |
| 616 DeserializeReferrers(*referral_list); | 618 DeserializeReferrers(*referral_list); |
| 617 | 619 |
| 618 LogStartupMetrics(); | 620 LogStartupMetrics(); |
| 619 } | 621 } |
| 620 | 622 |
| 621 //----------------------------------------------------------------------------- | 623 //----------------------------------------------------------------------------- |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 FROM_HERE, | 671 FROM_HERE, |
| 670 base::Bind(&Predictor::ResolveList, base::Unretained(this), | 672 base::Bind(&Predictor::ResolveList, base::Unretained(this), |
| 671 urls, motivation)); | 673 urls, motivation)); |
| 672 } | 674 } |
| 673 } | 675 } |
| 674 | 676 |
| 675 //----------------------------------------------------------------------------- | 677 //----------------------------------------------------------------------------- |
| 676 // Functions to handle saving of hostnames from one session to the next, to | 678 // Functions to handle saving of hostnames from one session to the next, to |
| 677 // expedite startup times. | 679 // expedite startup times. |
| 678 | 680 |
| 679 static void SaveDnsPrefetchStateForNextStartupOnIOThread( | |
| 680 base::ListValue* startup_list, | |
| 681 base::ListValue* referral_list, | |
| 682 base::WaitableEvent* completion, | |
| 683 Predictor* predictor) { | |
| 684 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 685 | |
| 686 if (nullptr == predictor) { | |
| 687 completion->Signal(); | |
| 688 return; | |
| 689 } | |
| 690 predictor->SaveDnsPrefetchStateForNextStartup(startup_list, referral_list, | |
| 691 completion); | |
| 692 } | |
| 693 | |
| 694 void Predictor::SaveStateForNextStartup() { | 681 void Predictor::SaveStateForNextStartup() { |
| 682 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
| 695 if (!predictor_enabled_) | 683 if (!predictor_enabled_) |
| 696 return; | 684 return; |
| 697 if (!CanPreresolveAndPreconnect()) | 685 if (!CanPreresolveAndPreconnect()) |
| 698 return; | 686 return; |
| 699 | 687 |
| 700 base::WaitableEvent completion( | 688 std::unique_ptr<base::ListValue> startup_list(new base::ListValue); |
| 701 base::WaitableEvent::ResetPolicy::MANUAL, | 689 std::unique_ptr<base::ListValue> referral_list(new base::ListValue); |
| 702 base::WaitableEvent::InitialState::NOT_SIGNALED); | |
| 703 | 690 |
| 704 ListPrefUpdate update_startup_list(user_prefs_, | 691 // Get raw pointers to pass to the first task. Ownership of the unique_ptrs |
| 705 prefs::kDnsPrefetchingStartupList); | 692 // will be passed to the reply task. |
| 706 ListPrefUpdate update_referral_list(user_prefs_, | 693 base::ListValue* startup_list_raw = startup_list.get(); |
| 707 prefs::kDnsPrefetchingHostReferralList); | 694 base::ListValue* referral_list_raw = referral_list.get(); |
| 708 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | |
| 709 SaveDnsPrefetchStateForNextStartupOnIOThread(update_startup_list.Get(), | |
| 710 update_referral_list.Get(), | |
| 711 &completion, this); | |
| 712 } else { | |
| 713 bool posted = BrowserThread::PostTask( | |
| 714 BrowserThread::IO, FROM_HERE, | |
| 715 base::Bind(&SaveDnsPrefetchStateForNextStartupOnIOThread, | |
| 716 update_startup_list.Get(), update_referral_list.Get(), | |
| 717 &completion, this)); | |
| 718 | 695 |
| 719 // TODO(jar): Synchronous waiting for the IO thread is a potential source | 696 BrowserThread::PostTaskAndReply( |
| 720 // to deadlocks and should be investigated. See http://crbug.com/78451. | 697 BrowserThread::IO, FROM_HERE, |
| 721 DCHECK(posted); | 698 base::Bind(&Predictor::WriteDnsPrefetchState, |
| 722 if (posted) { | 699 io_weak_factory_->GetWeakPtr(), startup_list_raw, |
| 723 // http://crbug.com/124954 | 700 referral_list_raw), |
| 724 base::ThreadRestrictions::ScopedAllowWait allow_wait; | 701 base::Bind(&Predictor::UpdatePrefsOnUIThread, |
| 725 completion.Wait(); | 702 ui_weak_factory_->GetWeakPtr(), |
| 726 } | 703 base::Passed(std::move(startup_list)), |
| 727 } | 704 base::Passed(std::move(referral_list)))); |
| 728 } | 705 } |
| 729 | 706 |
| 730 void Predictor::SaveDnsPrefetchStateForNextStartup( | 707 void Predictor::UpdatePrefsOnUIThread( |
| 731 base::ListValue* startup_list, | 708 std::unique_ptr<base::ListValue> startup_list, |
| 732 base::ListValue* referral_list, | 709 std::unique_ptr<base::ListValue> referral_list) { |
| 733 base::WaitableEvent* completion) { | 710 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 711 user_prefs_->Set(prefs::kDnsPrefetchingStartupList, *startup_list); | |
| 712 user_prefs_->Set(prefs::kDnsPrefetchingHostReferralList, *referral_list); | |
| 713 } | |
| 714 | |
| 715 void Predictor::WriteDnsPrefetchState(base::ListValue* startup_list, | |
| 716 base::ListValue* referral_list) { | |
| 734 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 717 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 735 if (initial_observer_.get()) | 718 if (initial_observer_.get()) |
| 736 initial_observer_->GetInitialDnsResolutionList(startup_list); | 719 initial_observer_->GetInitialDnsResolutionList(startup_list); |
| 737 | 720 |
| 738 SerializeReferrers(referral_list); | 721 SerializeReferrers(referral_list); |
| 739 | |
| 740 completion->Signal(); | |
| 741 } | 722 } |
| 742 | 723 |
| 743 void Predictor::PreconnectUrl(const GURL& url, | 724 void Predictor::PreconnectUrl(const GURL& url, |
| 744 const GURL& first_party_for_cookies, | 725 const GURL& first_party_for_cookies, |
| 745 UrlInfo::ResolutionMotivation motivation, | 726 UrlInfo::ResolutionMotivation motivation, |
| 746 bool allow_credentials, | 727 bool allow_credentials, |
| 747 int count) { | 728 int count) { |
| 748 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 729 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 749 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 730 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 750 | 731 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1025 info->SetAssignedState(); | 1006 info->SetAssignedState(); |
| 1026 | 1007 |
| 1027 if (CongestionControlPerformed(info)) { | 1008 if (CongestionControlPerformed(info)) { |
| 1028 DCHECK(work_queue_.IsEmpty()); | 1009 DCHECK(work_queue_.IsEmpty()); |
| 1029 return; | 1010 return; |
| 1030 } | 1011 } |
| 1031 | 1012 |
| 1032 int status = | 1013 int status = |
| 1033 content::PreresolveUrl(profile_io_data_->GetResourceContext(), url, | 1014 content::PreresolveUrl(profile_io_data_->GetResourceContext(), url, |
| 1034 base::Bind(&Predictor::OnLookupFinished, | 1015 base::Bind(&Predictor::OnLookupFinished, |
| 1035 weak_factory_->GetWeakPtr(), url)); | 1016 io_weak_factory_->GetWeakPtr(), url)); |
| 1036 if (status == net::ERR_IO_PENDING) { | 1017 if (status == net::ERR_IO_PENDING) { |
| 1037 // Will complete asynchronously. | 1018 // Will complete asynchronously. |
| 1038 num_pending_lookups_++; | 1019 num_pending_lookups_++; |
| 1039 peak_pending_lookups_ = | 1020 peak_pending_lookups_ = |
| 1040 std::max(peak_pending_lookups_, num_pending_lookups_); | 1021 std::max(peak_pending_lookups_, num_pending_lookups_); |
| 1041 } else { | 1022 } else { |
| 1042 // Completed synchronously (was already cached by HostResolver), or else | 1023 // Completed synchronously (was already cached by HostResolver), or else |
| 1043 // there was (equivalently) some network error that prevents us from | 1024 // there was (equivalently) some network error that prevents us from |
| 1044 // finding the name. Status net::OK means it was "found." | 1025 // finding the name. Status net::OK means it was "found." |
| 1045 LookupFinished(url, status == net::OK); | 1026 LookupFinished(url, status == net::OK); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1148 DCHECK(url.SchemeIsHTTPOrHTTPS()); | 1129 DCHECK(url.SchemeIsHTTPOrHTTPS()); |
| 1149 DCHECK_EQ(url, Predictor::CanonicalizeUrl(url)); | 1130 DCHECK_EQ(url, Predictor::CanonicalizeUrl(url)); |
| 1150 if (first_navigations_.find(url) == first_navigations_.end()) | 1131 if (first_navigations_.find(url) == first_navigations_.end()) |
| 1151 first_navigations_[url] = base::TimeTicks::Now(); | 1132 first_navigations_[url] = base::TimeTicks::Now(); |
| 1152 } | 1133 } |
| 1153 | 1134 |
| 1154 void Predictor::InitialObserver::GetInitialDnsResolutionList( | 1135 void Predictor::InitialObserver::GetInitialDnsResolutionList( |
| 1155 base::ListValue* startup_list) { | 1136 base::ListValue* startup_list) { |
| 1156 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1137 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1157 DCHECK(startup_list); | 1138 DCHECK(startup_list); |
| 1158 startup_list->Clear(); | 1139 DCHECK(startup_list->empty()); |
| 1159 DCHECK_EQ(0u, startup_list->GetSize()); | 1140 DCHECK_EQ(0u, startup_list->GetSize()); |
| 1160 startup_list->AppendInteger(kPredictorStartupFormatVersion); | 1141 startup_list->AppendInteger(kPredictorStartupFormatVersion); |
| 1161 for (FirstNavigations::iterator it = first_navigations_.begin(); | 1142 for (FirstNavigations::iterator it = first_navigations_.begin(); |
| 1162 it != first_navigations_.end(); | 1143 it != first_navigations_.end(); |
| 1163 ++it) { | 1144 ++it) { |
| 1164 DCHECK(it->first == Predictor::CanonicalizeUrl(it->first)); | 1145 DCHECK(it->first == Predictor::CanonicalizeUrl(it->first)); |
| 1165 startup_list->AppendString(it->first.spec()); | 1146 startup_list->AppendString(it->first.spec()); |
| 1166 } | 1147 } |
| 1167 } | 1148 } |
| 1168 | 1149 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 } | 1203 } |
| 1223 | 1204 |
| 1224 void SimplePredictor::ShutdownOnUIThread() { | 1205 void SimplePredictor::ShutdownOnUIThread() { |
| 1225 SetShutdown(true); | 1206 SetShutdown(true); |
| 1226 } | 1207 } |
| 1227 | 1208 |
| 1228 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } | 1209 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } |
| 1229 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } | 1210 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } |
| 1230 | 1211 |
| 1231 } // namespace chrome_browser_net | 1212 } // namespace chrome_browser_net |
| OLD | NEW |