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

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

Issue 2082653003: Log predictor database size on startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update histogram desc Created 4 years, 6 months 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
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // on the same thread. The predictor lives on the IO thread and will die 665 // on the same thread. The predictor lives on the IO thread and will die
666 // from there so now that we're on the IO thread we need to properly 666 // from there so now that we're on the IO thread we need to properly
667 // initialize the base::WeakPtrFactory. 667 // initialize the base::WeakPtrFactory.
668 // TODO(groby): Check if WeakPtrFactory has the same constraint. 668 // TODO(groby): Check if WeakPtrFactory has the same constraint.
669 weak_factory_.reset(new base::WeakPtrFactory<Predictor>(this)); 669 weak_factory_.reset(new base::WeakPtrFactory<Predictor>(this));
670 670
671 // Prefetch these hostnames on startup. 671 // Prefetch these hostnames on startup.
672 DnsPrefetchMotivatedList(startup_urls, UrlInfo::STARTUP_LIST_MOTIVATED); 672 DnsPrefetchMotivatedList(startup_urls, UrlInfo::STARTUP_LIST_MOTIVATED);
673 673
674 DeserializeReferrersThenDelete(referral_list); 674 DeserializeReferrersThenDelete(referral_list);
675
676 LogStartupMetrics();
675 } 677 }
676 678
677 //----------------------------------------------------------------------------- 679 //-----------------------------------------------------------------------------
678 // This section intermingles prefetch results with actual browser HTTP 680 // This section intermingles prefetch results with actual browser HTTP
679 // network activity. It supports calculating of the benefit of a prefetch, as 681 // network activity. It supports calculating of the benefit of a prefetch, as
680 // well as recording what prefetched hostname resolutions might be potentially 682 // well as recording what prefetched hostname resolutions might be potentially
681 // helpful during the next chrome-startup. 683 // helpful during the next chrome-startup.
682 //----------------------------------------------------------------------------- 684 //-----------------------------------------------------------------------------
683 685
684 void Predictor::LearnAboutInitialNavigation(const GURL& url) { 686 void Predictor::LearnAboutInitialNavigation(const GURL& url) {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 return url; 1167 return url;
1166 if (!transport_security_state_->ShouldUpgradeToSSL(url.host())) 1168 if (!transport_security_state_->ShouldUpgradeToSSL(url.host()))
1167 return url; 1169 return url;
1168 1170
1169 url::Replacements<char> replacements; 1171 url::Replacements<char> replacements;
1170 const char kNewScheme[] = "https"; 1172 const char kNewScheme[] = "https";
1171 replacements.SetScheme(kNewScheme, url::Component(0, strlen(kNewScheme))); 1173 replacements.SetScheme(kNewScheme, url::Component(0, strlen(kNewScheme)));
1172 return url.ReplaceComponents(replacements); 1174 return url.ReplaceComponents(replacements);
1173 } 1175 }
1174 1176
1177 void Predictor::LogStartupMetrics() {
1178 size_t total_bytes = 0;
1179 for (const auto& referrer : referrers_) {
1180 total_bytes += referrer.first.spec().size();
1181 total_bytes += sizeof(Referrer);
1182 for (const auto& subresource : referrer.second) {
1183 total_bytes += subresource.first.spec().size();
1184 total_bytes += sizeof(ReferrerValue);
1185 }
1186 }
1187 UMA_HISTOGRAM_CUSTOM_COUNTS("Net.Predictor.Startup.DBSize", total_bytes, 1,
1188 10 * 1000 * 1000, 50);
1189 }
1190
1191
1175 // ---------------------- End IO methods. ------------------------------------- 1192 // ---------------------- End IO methods. -------------------------------------
1176 1193
1177 //----------------------------------------------------------------------------- 1194 //-----------------------------------------------------------------------------
1178 1195
1179 bool Predictor::PreconnectEnabled() const { 1196 bool Predictor::PreconnectEnabled() const {
1180 base::AutoLock lock(preconnect_enabled_lock_); 1197 base::AutoLock lock(preconnect_enabled_lock_);
1181 return preconnect_enabled_; 1198 return preconnect_enabled_;
1182 } 1199 }
1183 1200
1184 void Predictor::SetPreconnectEnabledForTest(bool preconnect_enabled) { 1201 void Predictor::SetPreconnectEnabledForTest(bool preconnect_enabled) {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 } 1333 }
1317 1334
1318 void SimplePredictor::ShutdownOnUIThread() { 1335 void SimplePredictor::ShutdownOnUIThread() {
1319 SetShutdown(true); 1336 SetShutdown(true);
1320 } 1337 }
1321 1338
1322 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; } 1339 bool SimplePredictor::CanPrefetchAndPrerender() const { return true; }
1323 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; } 1340 bool SimplePredictor::CanPreresolveAndPreconnect() const { return true; }
1324 1341
1325 } // namespace chrome_browser_net 1342 } // namespace chrome_browser_net
OLDNEW
« no previous file with comments | « chrome/browser/net/predictor.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698