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