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

Unified Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2577253003: ntp_tiles: Avoid redundant calls to TopSites (Closed)
Patch Set: Renamed weak ptr factory. Created 3 years, 11 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
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_tiles/most_visited_sites.cc
diff --git a/components/ntp_tiles/most_visited_sites.cc b/components/ntp_tiles/most_visited_sites.cc
index 47918739aca14ab147eb3cd8b53317b70c7b1cef..6f5504cf5792fe285357ef8244b746727b91b821 100644
--- a/components/ntp_tiles/most_visited_sites.cc
+++ b/components/ntp_tiles/most_visited_sites.cc
@@ -63,7 +63,7 @@ MostVisitedSites::MostVisitedSites(
num_sites_(0),
top_sites_observer_(this),
mv_source_(NTPTileSource::TOP_SITES),
- weak_ptr_factory_(this) {
+ top_sites_weak_ptr_factory_(this) {
DCHECK(prefs_);
// top_sites_ can be null in tests.
// TODO(sfiera): have iOS use a dummy TopSites in its tests.
@@ -169,9 +169,11 @@ void MostVisitedSites::BuildCurrentTiles() {
void MostVisitedSites::InitiateTopSitesQuery() {
if (!top_sites_)
return;
+ if (top_sites_weak_ptr_factory_.HasWeakPtrs())
+ return; // Ongoing query.
top_sites_->GetMostVisitedURLs(
base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable,
- weak_ptr_factory_.GetWeakPtr()),
+ top_sites_weak_ptr_factory_.GetWeakPtr()),
false);
}
« no previous file with comments | « components/ntp_tiles/most_visited_sites.h ('k') | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698