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..645e62c6a3c36138b61b46ddb1dac22802a2efde 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::fomOtherPlaces); |
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::TopSitesCalledLocation location) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
MostVisitedURLList top_sites(new_top_sites); |
@@ -762,7 +764,16 @@ void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) { |
TopSitesDelta delta; |
DiffMostVisited(cache_->top_sites(), top_sites, &delta); |
if (!delta.deleted.empty() || !delta.added.empty() || !delta.moved.empty()) { |
- backend_->UpdateTopSites(delta); |
+ backend_->UpdateTopSites(delta, location); |
+ } |
+ |
+ // Record the delta size into a histogram if this function is called from |
+ // function OnGotMostVisitedThumbnails. |
+ if (location == TopSitesBackend::fromOnGotMostVisitedThumbnails) { |
+ size_t delta_size = |
+ delta.deleted.size() + delta.added.size() + delta.moved.size(); |
+ UMA_HISTOGRAM_COUNTS_100( |
+ "History.UpdateTopSitesOnDBThread_Startup_DeltaSize", delta_size); |
sky
2015/04/01 22:51:48
The name seems to indicate you want this only at s
yao
2015/04/02 17:20:31
Right, I guess we could get the number of profiles
sky
2015/04/02 18:22:18
What about a static?
yao
2015/04/02 19:37:30
Like a static class member, that indicates whether
|
} |
last_num_urls_changed_ = delta.added.size() + delta.moved.size(); |
@@ -879,7 +890,8 @@ 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::fromOnGotMostVisitedThumbnails); |
cache_->SetThumbnails(thumbnails->url_to_images_map); |
ResetThreadSafeImageCache(); |
@@ -894,7 +906,7 @@ void TopSitesImpl::OnGotMostVisitedThumbnails( |
void TopSitesImpl::OnTopSitesAvailableFromHistory( |
const MostVisitedURLList* pages) { |
DCHECK(pages); |
- SetTopSites(*pages); |
+ SetTopSites(*pages, TopSitesBackend::fomOtherPlaces); |
} |
void TopSitesImpl::OnURLsDeleted(HistoryService* history_service, |
@@ -906,7 +918,7 @@ void TopSitesImpl::OnURLsDeleted(HistoryService* history_service, |
return; |
if (all_history) { |
- SetTopSites(MostVisitedURLList()); |
+ SetTopSites(MostVisitedURLList(), TopSitesBackend::fomOtherPlaces); |
backend_->ResetDatabase(); |
} else { |
std::set<size_t> indices_to_delete; // Indices into top_sites_. |
@@ -923,7 +935,7 @@ 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::fomOtherPlaces); |
} |
StartQueryForMostVisited(); |
} |