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

Unified Diff: chrome/browser/history/top_sites_impl.cc

Issue 1005873011: Only record the execution time during startup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a static member to make sure the histogram is recorded only once. Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/history/top_sites_impl.cc
diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc
index 2cad9e33fbef645cfcc91427f0957dfaae3cf286..306505904f0787abc89a84325f22c3662ef690cd 100644
--- a/chrome/browser/history/top_sites_impl.cc
+++ b/chrome/browser/history/top_sites_impl.cc
@@ -625,7 +625,7 @@ bool TopSitesImpl::AddForcedURL(const GURL& url, const base::Time& time) {
new_list.insert(mid, new_url);
mid = new_list.begin() + num_forced; // Mid was invalidated.
std::inplace_merge(new_list.begin(), mid, mid + 1, ForcedURLComparator);
- SetTopSites(new_list);
+ SetTopSites(new_list, TopSitesBackend::CALL_LOCATION_FROM_OTHER_PLACES);
return true;
}
@@ -752,7 +752,9 @@ void TopSitesImpl::Observe(int type,
}
}
-void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) {
+void TopSitesImpl::SetTopSites(
+ const MostVisitedURLList& new_top_sites,
+ const TopSitesBackend::CallLocation location) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
MostVisitedURLList top_sites(new_top_sites);
@@ -761,8 +763,25 @@ void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) {
TopSitesDelta delta;
DiffMostVisited(cache_->top_sites(), top_sites, &delta);
+
+ // Record the delta size into a histogram if this function is called from
+ // function OnGotMostVisitedThumbnails and no histogram value has been
+ // recorded before.
+ if (location ==
+ TopSitesBackend::CALL_LOCATION_FROM_ON_GOT_MOST_VISITED_THUMBNAILS &&
+ backend_->histogram_recorded() ==
+ TopSitesBackend::HISTOGRAM_RECORDING_NOT_YET) {
+ size_t delta_size =
+ delta.deleted.size() + delta.added.size() + delta.moved.size();
+ UMA_HISTOGRAM_COUNTS_100(
+ "History.UpdateTopSitesOnDBThread_Startup_DeltaSize", delta_size);
+ // Increase the enum value so that TopSitesBackend knows that it should
+ // record the relevant histogram value as well.
+ backend_->IncraseHistogramRecordingStatus();
+ }
+
if (!delta.deleted.empty() || !delta.added.empty() || !delta.moved.empty()) {
- backend_->UpdateTopSites(delta);
+ backend_->UpdateTopSites(delta, location);
}
last_num_urls_changed_ = delta.added.size() + delta.moved.size();
@@ -879,7 +898,9 @@ void TopSitesImpl::OnGotMostVisitedThumbnails(
// Set the top sites directly in the cache so that SetTopSites diffs
// correctly.
cache_->SetTopSites(thumbnails->most_visited);
- SetTopSites(thumbnails->most_visited);
+ SetTopSites(
+ thumbnails->most_visited,
+ TopSitesBackend::CALL_LOCATION_FROM_ON_GOT_MOST_VISITED_THUMBNAILS);
cache_->SetThumbnails(thumbnails->url_to_images_map);
ResetThreadSafeImageCache();
@@ -894,7 +915,7 @@ void TopSitesImpl::OnGotMostVisitedThumbnails(
void TopSitesImpl::OnTopSitesAvailableFromHistory(
const MostVisitedURLList* pages) {
DCHECK(pages);
- SetTopSites(*pages);
+ SetTopSites(*pages, TopSitesBackend::CALL_LOCATION_FROM_OTHER_PLACES);
}
void TopSitesImpl::OnURLsDeleted(HistoryService* history_service,
@@ -906,7 +927,8 @@ void TopSitesImpl::OnURLsDeleted(HistoryService* history_service,
return;
if (all_history) {
- SetTopSites(MostVisitedURLList());
+ SetTopSites(MostVisitedURLList(),
+ TopSitesBackend::CALL_LOCATION_FROM_OTHER_PLACES);
backend_->ResetDatabase();
} else {
std::set<size_t> indices_to_delete; // Indices into top_sites_.
@@ -923,7 +945,8 @@ void TopSitesImpl::OnURLsDeleted(HistoryService* history_service,
i != indices_to_delete.rend(); i++) {
new_top_sites.erase(new_top_sites.begin() + *i);
}
- SetTopSites(new_top_sites);
+ SetTopSites(new_top_sites,
+ TopSitesBackend::CALL_LOCATION_FROM_OTHER_PLACES);
}
StartQueryForMostVisited();
}

Powered by Google App Engine
This is Rietveld 408576698