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 <set> | 9 #include <set> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 FROM_HERE, | 222 FROM_HERE, |
| 223 base::Bind( | 223 base::Bind( |
| 224 &Predictor::FinalizeInitializationOnIOThread, | 224 &Predictor::FinalizeInitializationOnIOThread, |
| 225 base::Unretained(this), | 225 base::Unretained(this), |
| 226 urls, referral_list, | 226 urls, referral_list, |
| 227 io_thread, profile_io_data)); | 227 io_thread, profile_io_data)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { | 230 void Predictor::AnticipateOmniboxUrl(const GURL& url, bool preconnectable) { |
| 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 232 if (!predictor_enabled_) | 232 if (!preconnect_enabled_ || !CanPreresolveAndPreconnectUI()) |
|
mmenke
2014/08/12 17:38:10
I think !preconnect_enabled_ should go down to whe
Bence
2014/08/12 20:21:56
Done.
| |
| 233 return; | 233 return; |
| 234 if (!url.is_valid() || !url.has_host()) | 234 if (!url.is_valid() || !url.has_host()) |
| 235 return; | 235 return; |
| 236 if (!CanPredictNetworkActionsUI()) | |
| 237 return; | |
| 238 | 236 |
| 239 std::string host = url.HostNoBrackets(); | 237 std::string host = url.HostNoBrackets(); |
| 240 bool is_new_host_request = (host != last_omnibox_host_); | 238 bool is_new_host_request = (host != last_omnibox_host_); |
| 241 last_omnibox_host_ = host; | 239 last_omnibox_host_ = host; |
| 242 | 240 |
| 243 UrlInfo::ResolutionMotivation motivation(UrlInfo::OMNIBOX_MOTIVATED); | 241 UrlInfo::ResolutionMotivation motivation(UrlInfo::OMNIBOX_MOTIVATED); |
| 244 base::TimeTicks now = base::TimeTicks::Now(); | 242 base::TimeTicks now = base::TimeTicks::Now(); |
| 245 | 243 |
| 246 if (preconnect_enabled_) { | 244 if (preconnectable && !is_new_host_request) { |
| 247 if (preconnectable && !is_new_host_request) { | 245 ++consecutive_omnibox_preconnect_count_; |
| 248 ++consecutive_omnibox_preconnect_count_; | 246 // The omnibox suggests a search URL (for which we can preconnect) after |
| 249 // The omnibox suggests a search URL (for which we can preconnect) after | 247 // one or two characters are typed, even though such typing often (1 in |
| 250 // one or two characters are typed, even though such typing often (1 in | 248 // 3?) becomes a real URL. This code waits till is has more evidence of a |
| 251 // 3?) becomes a real URL. This code waits till is has more evidence of a | 249 // preconnectable URL (search URL) before forming a preconnection, so as |
| 252 // preconnectable URL (search URL) before forming a preconnection, so as | 250 // to reduce the useless preconnect rate. |
| 253 // to reduce the useless preconnect rate. | 251 // Perchance this logic should be pushed back into the omnibox, where the |
| 254 // Perchance this logic should be pushed back into the omnibox, where the | 252 // actual characters typed, such as a space, can better forcast whether |
| 255 // actual characters typed, such as a space, can better forcast whether | 253 // we need to search/preconnect or not. By waiting for at least 4 |
| 256 // we need to search/preconnect or not. By waiting for at least 4 | 254 // characters in a row that have lead to a search proposal, we avoid |
| 257 // characters in a row that have lead to a search proposal, we avoid | 255 // preconnections for a prefix like "www." and we also wait until we have |
| 258 // preconnections for a prefix like "www." and we also wait until we have | 256 // at least a 4 letter word to search for. |
| 259 // at least a 4 letter word to search for. | 257 // Each character typed appears to induce 2 calls to |
| 260 // Each character typed appears to induce 2 calls to | 258 // AnticipateOmniboxUrl(), so we double 4 characters and limit at 8 |
| 261 // AnticipateOmniboxUrl(), so we double 4 characters and limit at 8 | 259 // requests. |
| 262 // requests. | 260 // TODO(jar): Use an A/B test to optimize this. |
| 263 // TODO(jar): Use an A/B test to optimize this. | 261 const int kMinConsecutiveRequests = 8; |
| 264 const int kMinConsecutiveRequests = 8; | 262 if (consecutive_omnibox_preconnect_count_ >= kMinConsecutiveRequests) { |
| 265 if (consecutive_omnibox_preconnect_count_ >= kMinConsecutiveRequests) { | 263 // TODO(jar): Perhaps we should do a GET to leave the socket open in the |
| 266 // TODO(jar): Perhaps we should do a GET to leave the socket open in the | 264 // pool. Currently, we just do a connect, which MAY be reset if we |
| 267 // pool. Currently, we just do a connect, which MAY be reset if we | 265 // don't use it in 10 secondes!!! As a result, we may do more |
| 268 // don't use it in 10 secondes!!! As a result, we may do more | 266 // connections, and actually cost the server more than if we did a real |
| 269 // connections, and actually cost the server more than if we did a real | 267 // get with a fake request (/gen_204 might be the good path on Google). |
| 270 // get with a fake request (/gen_204 might be the good path on Google). | 268 const int kMaxSearchKeepaliveSeconds(10); |
| 271 const int kMaxSearchKeepaliveSeconds(10); | 269 if ((now - last_omnibox_preconnect_).InSeconds() < |
| 272 if ((now - last_omnibox_preconnect_).InSeconds() < | 270 kMaxSearchKeepaliveSeconds) |
| 273 kMaxSearchKeepaliveSeconds) | 271 return; // We've done a preconnect recently. |
| 274 return; // We've done a preconnect recently. | 272 last_omnibox_preconnect_ = now; |
| 275 last_omnibox_preconnect_ = now; | 273 const int kConnectionsNeeded = 1; |
| 276 const int kConnectionsNeeded = 1; | 274 PreconnectUrl( |
| 277 PreconnectUrl(CanonicalizeUrl(url), GURL(), motivation, | 275 CanonicalizeUrl(url), GURL(), motivation, kConnectionsNeeded); |
| 278 kConnectionsNeeded); | 276 return; // Skip pre-resolution, since we'll open a connection. |
| 279 return; // Skip pre-resolution, since we'll open a connection. | |
| 280 } | |
| 281 } else { | |
| 282 consecutive_omnibox_preconnect_count_ = 0; | |
| 283 } | 277 } |
| 278 } else { | |
| 279 consecutive_omnibox_preconnect_count_ = 0; | |
| 284 } | 280 } |
| 285 | 281 |
| 286 // Fall through and consider pre-resolution. | 282 // Fall through and consider pre-resolution. |
| 287 | 283 |
| 288 // Omnibox tends to call in pairs (just a few milliseconds apart), and we | 284 // Omnibox tends to call in pairs (just a few milliseconds apart), and we |
| 289 // really don't need to keep resolving a name that often. | 285 // really don't need to keep resolving a name that often. |
| 290 // TODO(jar): A/B tests could check for perf impact of the early returns. | 286 // TODO(jar): A/B tests could check for perf impact of the early returns. |
| 291 if (!is_new_host_request) { | 287 if (!is_new_host_request) { |
| 292 const int kMinPreresolveSeconds(10); | 288 const int kMinPreresolveSeconds(10); |
| 293 if (kMinPreresolveSeconds > (now - last_omnibox_preresolve_).InSeconds()) | 289 if (kMinPreresolveSeconds > (now - last_omnibox_preresolve_).InSeconds()) |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 304 | 300 |
| 305 void Predictor::PreconnectUrlAndSubresources(const GURL& url, | 301 void Predictor::PreconnectUrlAndSubresources(const GURL& url, |
| 306 const GURL& first_party_for_cookies) { | 302 const GURL& first_party_for_cookies) { |
| 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 303 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 308 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 304 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 309 if (!predictor_enabled_ || !preconnect_enabled_ || | 305 if (!predictor_enabled_ || !preconnect_enabled_ || |
| 310 !url.is_valid() || !url.has_host()) | 306 !url.is_valid() || !url.has_host()) |
| 311 return; | 307 return; |
| 312 | 308 |
| 313 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 309 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 314 if (!CanPredictNetworkActionsUI()) | 310 if (!CanPreresolveAndPreconnectUI()) |
| 315 return; | 311 return; |
| 316 } else { | 312 } else { |
| 317 if (!CanPredictNetworkActionsIO()) | 313 if (!CanPreresolveAndPreconnectIO()) |
| 318 return; | 314 return; |
| 319 } | 315 } |
| 320 | 316 |
| 321 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); | 317 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); |
| 322 const int kConnectionsNeeded = 1; | 318 const int kConnectionsNeeded = 1; |
| 323 PreconnectUrl(CanonicalizeUrl(url), first_party_for_cookies, | 319 PreconnectUrl(CanonicalizeUrl(url), first_party_for_cookies, |
| 324 motivation, kConnectionsNeeded); | 320 motivation, kConnectionsNeeded); |
| 325 PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies); | 321 PredictFrameSubresources(url.GetWithEmptyPath(), first_party_for_cookies); |
| 326 } | 322 } |
| 327 | 323 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 UrlInfo::ResolutionMotivation motivation) { | 462 UrlInfo::ResolutionMotivation motivation) { |
| 467 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 463 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 468 if (!url.has_host()) | 464 if (!url.has_host()) |
| 469 return; | 465 return; |
| 470 AppendToResolutionQueue(url, motivation); | 466 AppendToResolutionQueue(url, motivation); |
| 471 } | 467 } |
| 472 | 468 |
| 473 void Predictor::LearnFromNavigation(const GURL& referring_url, | 469 void Predictor::LearnFromNavigation(const GURL& referring_url, |
| 474 const GURL& target_url) { | 470 const GURL& target_url) { |
| 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 471 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 476 if (!predictor_enabled_ || !CanPredictNetworkActionsIO()) | 472 if (!predictor_enabled_ || !CanPrefetchAndPrerenderIO()) |
| 477 return; | 473 return; |
| 478 DCHECK_EQ(referring_url, Predictor::CanonicalizeUrl(referring_url)); | 474 DCHECK_EQ(referring_url, Predictor::CanonicalizeUrl(referring_url)); |
| 479 DCHECK_NE(referring_url, GURL::EmptyGURL()); | 475 DCHECK_NE(referring_url, GURL::EmptyGURL()); |
| 480 DCHECK_EQ(target_url, Predictor::CanonicalizeUrl(target_url)); | 476 DCHECK_EQ(target_url, Predictor::CanonicalizeUrl(target_url)); |
| 481 DCHECK_NE(target_url, GURL::EmptyGURL()); | 477 DCHECK_NE(target_url, GURL::EmptyGURL()); |
| 482 | 478 |
| 483 referrers_[referring_url].SuggestHost(target_url); | 479 referrers_[referring_url].SuggestHost(target_url); |
| 484 // Possibly do some referrer trimming. | 480 // Possibly do some referrer trimming. |
| 485 TrimReferrers(); | 481 TrimReferrers(); |
| 486 } | 482 } |
| 487 | 483 |
| 488 //----------------------------------------------------------------------------- | 484 //----------------------------------------------------------------------------- |
| 489 // This section supports the about:dns page. | 485 // This section supports the about:dns page. |
| 490 | 486 |
| 491 void Predictor::PredictorGetHtmlInfo(Predictor* predictor, | 487 void Predictor::PredictorGetHtmlInfo(Predictor* predictor, |
| 492 std::string* output) { | 488 std::string* output) { |
| 493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 494 | 490 |
| 495 output->append("<html><head><title>About DNS</title>" | 491 output->append("<html><head><title>About DNS</title>" |
| 496 // We'd like the following no-cache... but it doesn't work. | 492 // We'd like the following no-cache... but it doesn't work. |
| 497 // "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" | 493 // "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" |
| 498 "</head><body>"); | 494 "</head><body>"); |
| 499 if (predictor && predictor->predictor_enabled() && | 495 if (predictor && predictor->predictor_enabled() && |
| 500 predictor->CanPredictNetworkActionsIO()) { | 496 predictor->CanPrefetchAndPrerenderIO()) { |
| 501 predictor->GetHtmlInfo(output); | 497 predictor->GetHtmlInfo(output); |
| 502 } else { | 498 } else { |
| 503 output->append("DNS pre-resolution and TCP pre-connection is disabled."); | 499 output->append("DNS pre-resolution and TCP pre-connection is disabled."); |
| 504 } | 500 } |
| 505 output->append("</body></html>"); | 501 output->append("</body></html>"); |
| 506 } | 502 } |
| 507 | 503 |
| 508 // Provide sort order so all .com's are together, etc. | 504 // Provide sort order so all .com's are together, etc. |
| 509 struct RightToLeftStringSorter { | 505 struct RightToLeftStringSorter { |
| 510 bool operator()(const GURL& left, const GURL& right) const { | 506 bool operator()(const GURL& left, const GURL& right) const { |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 721 //----------------------------------------------------------------------------- | 717 //----------------------------------------------------------------------------- |
| 722 // This section intermingles prefetch results with actual browser HTTP | 718 // This section intermingles prefetch results with actual browser HTTP |
| 723 // network activity. It supports calculating of the benefit of a prefetch, as | 719 // network activity. It supports calculating of the benefit of a prefetch, as |
| 724 // well as recording what prefetched hostname resolutions might be potentially | 720 // well as recording what prefetched hostname resolutions might be potentially |
| 725 // helpful during the next chrome-startup. | 721 // helpful during the next chrome-startup. |
| 726 //----------------------------------------------------------------------------- | 722 //----------------------------------------------------------------------------- |
| 727 | 723 |
| 728 void Predictor::LearnAboutInitialNavigation(const GURL& url) { | 724 void Predictor::LearnAboutInitialNavigation(const GURL& url) { |
| 729 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 725 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 730 if (!predictor_enabled_ || NULL == initial_observer_.get() || | 726 if (!predictor_enabled_ || NULL == initial_observer_.get() || |
| 731 !CanPredictNetworkActionsIO()) | 727 !CanPrefetchAndPrerenderIO()) |
| 732 return; | 728 return; |
|
mmenke
2014/08/12 17:38:10
nit: While you're here, mind adding braces?
Bence
2014/08/12 20:21:56
Done.
| |
| 733 initial_observer_->Append(url, this); | 729 initial_observer_->Append(url, this); |
| 734 } | 730 } |
| 735 | 731 |
| 736 // This API is only used in the browser process. | 732 // This API is only used in the browser process. |
| 737 // It is called from an IPC message originating in the renderer. It currently | 733 // It is called from an IPC message originating in the renderer. It currently |
| 738 // includes both Page-Scan, and Link-Hover prefetching. | 734 // includes both Page-Scan, and Link-Hover prefetching. |
| 739 // TODO(jar): Separate out link-hover prefetching, and page-scan results. | 735 // TODO(jar): Separate out link-hover prefetching, and page-scan results. |
| 740 void Predictor::DnsPrefetchList(const NameList& hostnames) { | 736 void Predictor::DnsPrefetchList(const NameList& hostnames) { |
| 741 // TODO(jar): Push GURL transport further back into renderer, but this will | 737 // TODO(jar): Push GURL transport further back into renderer, but this will |
| 742 // require a Webkit change in the observer :-/. | 738 // require a Webkit change in the observer :-/. |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 753 | 749 |
| 754 void Predictor::DnsPrefetchMotivatedList( | 750 void Predictor::DnsPrefetchMotivatedList( |
| 755 const UrlList& urls, | 751 const UrlList& urls, |
| 756 UrlInfo::ResolutionMotivation motivation) { | 752 UrlInfo::ResolutionMotivation motivation) { |
| 757 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 753 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 758 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 754 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 759 if (!predictor_enabled_) | 755 if (!predictor_enabled_) |
| 760 return; | 756 return; |
| 761 | 757 |
| 762 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 758 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 763 if (!CanPredictNetworkActionsUI()) | 759 if (!CanPrefetchAndPrerenderUI()) |
| 764 return; | 760 return; |
| 765 } else { | 761 } else { |
| 766 if (!CanPredictNetworkActionsIO()) | 762 if (!CanPrefetchAndPrerenderIO()) |
| 767 return; | 763 return; |
| 768 } | 764 } |
| 769 | 765 |
| 770 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 766 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 771 ResolveList(urls, motivation); | 767 ResolveList(urls, motivation); |
| 772 } else { | 768 } else { |
| 773 BrowserThread::PostTask( | 769 BrowserThread::PostTask( |
| 774 BrowserThread::IO, | 770 BrowserThread::IO, |
| 775 FROM_HERE, | 771 FROM_HERE, |
| 776 base::Bind(&Predictor::ResolveList, base::Unretained(this), | 772 base::Bind(&Predictor::ResolveList, base::Unretained(this), |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 795 } | 791 } |
| 796 predictor->SaveDnsPrefetchStateForNextStartupAndTrim( | 792 predictor->SaveDnsPrefetchStateForNextStartupAndTrim( |
| 797 startup_list, referral_list, completion); | 793 startup_list, referral_list, completion); |
| 798 } | 794 } |
| 799 | 795 |
| 800 void Predictor::SaveStateForNextStartupAndTrim() { | 796 void Predictor::SaveStateForNextStartupAndTrim() { |
| 801 if (!predictor_enabled_) | 797 if (!predictor_enabled_) |
| 802 return; | 798 return; |
| 803 | 799 |
| 804 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 800 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 805 if (!CanPredictNetworkActionsUI()) | 801 if (!CanPrefetchAndPrerenderUI()) |
| 806 return; | 802 return; |
| 807 } else { | 803 } else { |
| 808 if (!CanPredictNetworkActionsIO()) | 804 if (!CanPrefetchAndPrerenderIO()) |
| 809 return; | 805 return; |
| 810 } | 806 } |
| 811 | 807 |
| 812 base::WaitableEvent completion(true, false); | 808 base::WaitableEvent completion(true, false); |
| 813 | 809 |
| 814 ListPrefUpdate update_startup_list(user_prefs_, | 810 ListPrefUpdate update_startup_list(user_prefs_, |
| 815 prefs::kDnsPrefetchingStartupList); | 811 prefs::kDnsPrefetchingStartupList); |
| 816 ListPrefUpdate update_referral_list(user_prefs_, | 812 ListPrefUpdate update_referral_list(user_prefs_, |
| 817 prefs::kDnsPrefetchingHostReferralList); | 813 prefs::kDnsPrefetchingHostReferralList); |
| 818 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 814 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 901 } | 897 } |
| 902 | 898 |
| 903 void Predictor::PredictFrameSubresources(const GURL& url, | 899 void Predictor::PredictFrameSubresources(const GURL& url, |
| 904 const GURL& first_party_for_cookies) { | 900 const GURL& first_party_for_cookies) { |
| 905 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || | 901 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || |
| 906 BrowserThread::CurrentlyOn(BrowserThread::IO)); | 902 BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 907 if (!predictor_enabled_) | 903 if (!predictor_enabled_) |
| 908 return; | 904 return; |
| 909 | 905 |
| 910 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 906 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
| 911 if (!CanPredictNetworkActionsUI()) | 907 if (!CanPrefetchAndPrerenderUI()) |
| 912 return; | 908 return; |
| 913 } else { | 909 } else { |
| 914 if (!CanPredictNetworkActionsIO()) | 910 if (!CanPrefetchAndPrerenderIO()) |
| 915 return; | 911 return; |
| 916 } | 912 } |
| 917 DCHECK_EQ(url.GetWithEmptyPath(), url); | 913 DCHECK_EQ(url.GetWithEmptyPath(), url); |
| 918 // Add one pass through the message loop to allow current navigation to | 914 // Add one pass through the message loop to allow current navigation to |
| 919 // proceed. | 915 // proceed. |
| 920 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 916 if (BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 921 PrepareFrameSubresources(url, first_party_for_cookies); | 917 PrepareFrameSubresources(url, first_party_for_cookies); |
| 922 } else { | 918 } else { |
| 923 BrowserThread::PostTask( | 919 BrowserThread::PostTask( |
| 924 BrowserThread::IO, | 920 BrowserThread::IO, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 941 AdviseProxyOnIOThread(url, motivation, is_preconnect); | 937 AdviseProxyOnIOThread(url, motivation, is_preconnect); |
| 942 } else { | 938 } else { |
| 943 BrowserThread::PostTask( | 939 BrowserThread::PostTask( |
| 944 BrowserThread::IO, | 940 BrowserThread::IO, |
| 945 FROM_HERE, | 941 FROM_HERE, |
| 946 base::Bind(&Predictor::AdviseProxyOnIOThread, | 942 base::Bind(&Predictor::AdviseProxyOnIOThread, |
| 947 base::Unretained(this), url, motivation, is_preconnect)); | 943 base::Unretained(this), url, motivation, is_preconnect)); |
| 948 } | 944 } |
| 949 } | 945 } |
| 950 | 946 |
| 951 bool Predictor::CanPredictNetworkActionsUI() { | 947 bool Predictor::CanPrefetchAndPrerenderUI() const { |
|
mmenke
2014/08/12 17:38:10
Suggest adding DCHECKs for which thread we're on i
mmenke
2014/08/12 17:38:10
optional: It's marginally slower, but you might w
Bence
2014/08/12 20:21:55
Done.
Bence
2014/08/12 20:21:56
Done.
| |
| 952 return chrome_browser_net::CanPredictNetworkActionsUI(user_prefs_); | 948 return chrome_browser_net::CanPrefetchAndPrerenderUI(user_prefs_); |
| 953 } | 949 } |
| 954 | 950 |
| 955 bool Predictor::CanPredictNetworkActionsIO() { | 951 bool Predictor::CanPrefetchAndPrerenderIO() const { |
| 956 return chrome_browser_net::CanPredictNetworkActionsIO(profile_io_data_); | 952 return chrome_browser_net::CanPrefetchAndPrerenderIO(profile_io_data_); |
| 953 } | |
| 954 | |
| 955 bool Predictor::CanPreresolveAndPreconnectUI() const { | |
| 956 return chrome_browser_net::CanPreresolveAndPreconnectUI(user_prefs_); | |
| 957 } | |
| 958 | |
| 959 bool Predictor::CanPreresolveAndPreconnectIO() const { | |
| 960 return chrome_browser_net::CanPreresolveAndPreconnectIO(profile_io_data_); | |
| 957 } | 961 } |
| 958 | 962 |
| 959 enum SubresourceValue { | 963 enum SubresourceValue { |
| 960 PRECONNECTION, | 964 PRECONNECTION, |
| 961 PRERESOLUTION, | 965 PRERESOLUTION, |
| 962 TOO_NEW, | 966 TOO_NEW, |
| 963 SUBRESOURCE_VALUE_MAX | 967 SUBRESOURCE_VALUE_MAX |
| 964 }; | 968 }; |
| 965 | 969 |
| 966 void Predictor::PrepareFrameSubresources(const GURL& original_url, | 970 void Predictor::PrepareFrameSubresources(const GURL& original_url, |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 IOThread* io_thread, | 1342 IOThread* io_thread, |
| 1339 net::URLRequestContextGetter* getter, | 1343 net::URLRequestContextGetter* getter, |
| 1340 ProfileIOData* profile_io_data) { | 1344 ProfileIOData* profile_io_data) { |
| 1341 // Empty function for unittests. | 1345 // Empty function for unittests. |
| 1342 } | 1346 } |
| 1343 | 1347 |
| 1344 void SimplePredictor::ShutdownOnUIThread() { | 1348 void SimplePredictor::ShutdownOnUIThread() { |
| 1345 SetShutdown(true); | 1349 SetShutdown(true); |
| 1346 } | 1350 } |
| 1347 | 1351 |
| 1348 bool SimplePredictor::CanPredictNetworkActionsUI() { return true; } | 1352 bool SimplePredictor::CanPrefetchAndPrerenderUI() const { return true; } |
| 1349 bool SimplePredictor::CanPredictNetworkActionsIO() { return true; } | 1353 bool SimplePredictor::CanPrefetchAndPrerenderIO() const { return true; } |
| 1354 bool SimplePredictor::CanPreresolveAndPreconnectUI() const { return true; } | |
| 1355 bool SimplePredictor::CanPreresolveAndPreconnectIO() const { return true; } | |
| 1350 | 1356 |
| 1351 } // namespace chrome_browser_net | 1357 } // namespace chrome_browser_net |
| OLD | NEW |