Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: chrome/browser/net/predictor.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // connections, and actually cost the server more than if we did a real 237 // connections, and actually cost the server more than if we did a real
238 // get with a fake request (/gen_204 might be the good path on Google). 238 // get with a fake request (/gen_204 might be the good path on Google).
239 const int kMaxSearchKeepaliveSeconds(10); 239 const int kMaxSearchKeepaliveSeconds(10);
240 if ((now - last_omnibox_preconnect_).InSeconds() < 240 if ((now - last_omnibox_preconnect_).InSeconds() <
241 kMaxSearchKeepaliveSeconds) 241 kMaxSearchKeepaliveSeconds)
242 return; // We've done a preconnect recently. 242 return; // We've done a preconnect recently.
243 last_omnibox_preconnect_ = now; 243 last_omnibox_preconnect_ = now;
244 const int kConnectionsNeeded = 1; 244 const int kConnectionsNeeded = 1;
245 PreconnectOnUIThread(CanonicalizeUrl(url), motivation, 245 PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
246 kConnectionsNeeded, 246 kConnectionsNeeded,
247 url_request_context_getter_); 247 url_request_context_getter_.get());
248 return; // Skip pre-resolution, since we'll open a connection. 248 return; // Skip pre-resolution, since we'll open a connection.
249 } 249 }
250 } else { 250 } else {
251 consecutive_omnibox_preconnect_count_ = 0; 251 consecutive_omnibox_preconnect_count_ = 0;
252 } 252 }
253 } 253 }
254 254
255 // Fall through and consider pre-resolution. 255 // Fall through and consider pre-resolution.
256 256
257 // Omnibox tends to call in pairs (just a few milliseconds apart), and we 257 // Omnibox tends to call in pairs (just a few milliseconds apart), and we
(...skipping 19 matching lines...) Expand all
277 if (!predictor_enabled_) 277 if (!predictor_enabled_)
278 return; 278 return;
279 if (!url.is_valid() || !url.has_host()) 279 if (!url.is_valid() || !url.has_host())
280 return; 280 return;
281 if (preconnect_enabled()) { 281 if (preconnect_enabled()) {
282 std::string host = url.HostNoBrackets(); 282 std::string host = url.HostNoBrackets();
283 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED); 283 UrlInfo::ResolutionMotivation motivation(UrlInfo::EARLY_LOAD_MOTIVATED);
284 const int kConnectionsNeeded = 1; 284 const int kConnectionsNeeded = 1;
285 PreconnectOnUIThread(CanonicalizeUrl(url), motivation, 285 PreconnectOnUIThread(CanonicalizeUrl(url), motivation,
286 kConnectionsNeeded, 286 kConnectionsNeeded,
287 url_request_context_getter_); 287 url_request_context_getter_.get());
288 PredictFrameSubresources(url.GetWithEmptyPath()); 288 PredictFrameSubresources(url.GetWithEmptyPath());
289 } 289 }
290 } 290 }
291 291
292 UrlList Predictor::GetPredictedUrlListAtStartup( 292 UrlList Predictor::GetPredictedUrlListAtStartup(
293 PrefService* user_prefs, 293 PrefService* user_prefs,
294 PrefService* local_state) { 294 PrefService* local_state) {
295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 295 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
296 UrlList urls; 296 UrlList urls;
297 // Recall list of URLs we learned about during last session. 297 // Recall list of URLs we learned about during last session.
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
854 Referrers::iterator it = referrers_.find(url); 854 Referrers::iterator it = referrers_.find(url);
855 if (referrers_.end() == it) { 855 if (referrers_.end() == it) {
856 // Only when we don't know anything about this url, make 2 connections 856 // Only when we don't know anything about this url, make 2 connections
857 // available. We could do this completely via learning (by prepopulating 857 // available. We could do this completely via learning (by prepopulating
858 // the referrer_ list with this expected value), but it would swell the 858 // the referrer_ list with this expected value), but it would swell the
859 // size of the list with all the "Leaf" nodes in the tree (nodes that don't 859 // size of the list with all the "Leaf" nodes in the tree (nodes that don't
860 // load any subresources). If we learn about this resource, we will instead 860 // load any subresources). If we learn about this resource, we will instead
861 // provide a more carefully estimated preconnection count. 861 // provide a more carefully estimated preconnection count.
862 if (preconnect_enabled_) { 862 if (preconnect_enabled_) {
863 PreconnectOnIOThread(url, UrlInfo::SELF_REFERAL_MOTIVATED, 2, 863 PreconnectOnIOThread(url, UrlInfo::SELF_REFERAL_MOTIVATED, 2,
864 url_request_context_getter_); 864 url_request_context_getter_.get());
865 } 865 }
866 return; 866 return;
867 } 867 }
868 868
869 Referrer* referrer = &(it->second); 869 Referrer* referrer = &(it->second);
870 referrer->IncrementUseCount(); 870 referrer->IncrementUseCount();
871 const UrlInfo::ResolutionMotivation motivation = 871 const UrlInfo::ResolutionMotivation motivation =
872 UrlInfo::LEARNED_REFERAL_MOTIVATED; 872 UrlInfo::LEARNED_REFERAL_MOTIVATED;
873 for (Referrer::iterator future_url = referrer->begin(); 873 for (Referrer::iterator future_url = referrer->begin();
874 future_url != referrer->end(); ++future_url) { 874 future_url != referrer->end(); ++future_url) {
875 SubresourceValue evalution(TOO_NEW); 875 SubresourceValue evalution(TOO_NEW);
876 double connection_expectation = future_url->second.subresource_use_rate(); 876 double connection_expectation = future_url->second.subresource_use_rate();
877 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.PreconnectSubresourceExpectation", 877 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.PreconnectSubresourceExpectation",
878 static_cast<int>(connection_expectation * 100), 878 static_cast<int>(connection_expectation * 100),
879 10, 5000, 50); 879 10, 5000, 50);
880 future_url->second.ReferrerWasObserved(); 880 future_url->second.ReferrerWasObserved();
881 if (preconnect_enabled_ && 881 if (preconnect_enabled_ &&
882 connection_expectation > kPreconnectWorthyExpectedValue) { 882 connection_expectation > kPreconnectWorthyExpectedValue) {
883 evalution = PRECONNECTION; 883 evalution = PRECONNECTION;
884 future_url->second.IncrementPreconnectionCount(); 884 future_url->second.IncrementPreconnectionCount();
885 int count = static_cast<int>(std::ceil(connection_expectation)); 885 int count = static_cast<int>(std::ceil(connection_expectation));
886 if (url.host() == future_url->first.host()) 886 if (url.host() == future_url->first.host())
887 ++count; 887 ++count;
888 PreconnectOnIOThread(future_url->first, motivation, count, 888 PreconnectOnIOThread(future_url->first, motivation, count,
889 url_request_context_getter_); 889 url_request_context_getter_.get());
890 } else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) { 890 } else if (connection_expectation > kDNSPreresolutionWorthyExpectedValue) {
891 evalution = PRERESOLUTION; 891 evalution = PRERESOLUTION;
892 future_url->second.preresolution_increment(); 892 future_url->second.preresolution_increment();
893 UrlInfo* queued_info = AppendToResolutionQueue(future_url->first, 893 UrlInfo* queued_info = AppendToResolutionQueue(future_url->first,
894 motivation); 894 motivation);
895 if (queued_info) 895 if (queued_info)
896 queued_info->SetReferringHostname(url); 896 queued_info->SetReferringHostname(url);
897 } 897 }
898 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectSubresourceEval", evalution, 898 UMA_HISTOGRAM_ENUMERATION("Net.PreconnectSubresourceEval", evalution,
899 SUBRESOURCE_VALUE_MAX); 899 SUBRESOURCE_VALUE_MAX);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 IOThread* io_thread, 1185 IOThread* io_thread,
1186 net::URLRequestContextGetter* getter) { 1186 net::URLRequestContextGetter* getter) {
1187 // Empty function for unittests. 1187 // Empty function for unittests.
1188 } 1188 }
1189 1189
1190 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) { 1190 void SimplePredictor::ShutdownOnUIThread(PrefService* user_prefs) {
1191 SetShutdown(true); 1191 SetShutdown(true);
1192 } 1192 }
1193 1193
1194 } // namespace chrome_browser_net 1194 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/nacl_host/nacl_process_host.cc ('k') | chrome/browser/net/predictor_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698