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

Side by Side Diff: components/ntp_tiles/most_visited_sites.cc

Issue 2577253003: ntp_tiles: Avoid redundant calls to TopSites (Closed)
Patch Set: Created 4 years 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 | « no previous file | components/ntp_tiles/most_visited_sites_unittest.cc » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/ntp_tiles/most_visited_sites.h" 5 #include "components/ntp_tiles/most_visited_sites.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // Get the current suggestions from cache. If the cache is empty, this will 162 // Get the current suggestions from cache. If the cache is empty, this will
163 // fall back to TopSites. 163 // fall back to TopSites.
164 OnSuggestionsProfileAvailable( 164 OnSuggestionsProfileAvailable(
165 suggestions_service_->GetSuggestionsDataFromCache().value_or( 165 suggestions_service_->GetSuggestionsDataFromCache().value_or(
166 SuggestionsProfile())); 166 SuggestionsProfile()));
167 } 167 }
168 168
169 void MostVisitedSites::InitiateTopSitesQuery() { 169 void MostVisitedSites::InitiateTopSitesQuery() {
170 if (!top_sites_) 170 if (!top_sites_)
171 return; 171 return;
172 if (weak_ptr_factory_.HasWeakPtrs())
sfiera 2016/12/16 16:15:03 This seems brittle—it assumes we won't ever use we
mastiz 2017/01/05 11:50:45 You have a point, but adding yet another state var
173 return; // Ongoing query.
172 top_sites_->GetMostVisitedURLs( 174 top_sites_->GetMostVisitedURLs(
173 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable, 175 base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable,
174 weak_ptr_factory_.GetWeakPtr()), 176 weak_ptr_factory_.GetWeakPtr()),
175 false); 177 false);
176 } 178 }
177 179
178 base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) { 180 base::FilePath MostVisitedSites::GetWhitelistLargeIconPath(const GURL& url) {
179 if (supervisor_) { 181 if (supervisor_) {
180 for (const auto& whitelist : supervisor_->whitelists()) { 182 for (const auto& whitelist : supervisor_->whitelists()) {
181 if (AreURLsEquivalent(whitelist.entry_point, url)) 183 if (AreURLsEquivalent(whitelist.entry_point, url))
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 411
410 void MostVisitedSites::TopSitesChanged(TopSites* top_sites, 412 void MostVisitedSites::TopSitesChanged(TopSites* top_sites,
411 ChangeReason change_reason) { 413 ChangeReason change_reason) {
412 if (mv_source_ == NTPTileSource::TOP_SITES) { 414 if (mv_source_ == NTPTileSource::TOP_SITES) {
413 // The displayed tiles are invalidated. 415 // The displayed tiles are invalidated.
414 InitiateTopSitesQuery(); 416 InitiateTopSitesQuery();
415 } 417 }
416 } 418 }
417 419
418 } // namespace ntp_tiles 420 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « no previous file | components/ntp_tiles/most_visited_sites_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698