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

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

Issue 53283004: Adding support for forced URLs to TopSites. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Corrected minor spacing problem. Created 7 years, 1 month 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_cache.cc
diff --git a/chrome/browser/history/top_sites_cache.cc b/chrome/browser/history/top_sites_cache.cc
index 27d0c860173c8ae9ef320242dee6eb9336007eaf..7742d95d7a09a168e05e6307fc8fb0308227f7ab 100644
--- a/chrome/browser/history/top_sites_cache.cc
+++ b/chrome/browser/history/top_sites_cache.cc
@@ -31,6 +31,7 @@ TopSitesCache::~TopSitesCache() {
void TopSitesCache::SetTopSites(const MostVisitedURLList& top_sites) {
top_sites_ = top_sites;
+ CountForcedURLs();
GenerateCanonicalURLs();
}
@@ -148,6 +149,31 @@ size_t TopSitesCache::GetURLIndex(const GURL& url) const {
return GetCanonicalURLsIterator(url)->second;
}
+size_t TopSitesCache::GetNbNonForcedURLs() const {
+ return top_sites_.size() - nb_forced_urls_;
+}
+
+size_t TopSitesCache::GetNbForcedURLs() const {
+ return nb_forced_urls_;
+}
+
+void TopSitesCache::CountForcedURLs() {
+ nb_forced_urls_ = 0;
brettw 2013/11/08 22:56:07 As above, I'd use "num" instead. I've never seen a
beaudoin 2013/11/11 21:58:09 Probably a French thing. Sorry. :) Done.
+ while (nb_forced_urls_ < top_sites_.size()) {
+ // Forced sites are all at the beginning.
+ if (top_sites_[nb_forced_urls_].last_forced_time.is_null())
+ break;
+ nb_forced_urls_++;
+ }
+ // In debug, ensure the cache user is has no forced URLs pass that point.
brettw 2013/11/08 22:56:07 Grammar: "is has"
beaudoin 2013/11/11 21:58:09 Done.
+ if (DCHECK_IS_ON()) {
+ for (size_t i = nb_forced_urls_; i < top_sites_.size(); ++i) {
+ DCHECK(top_sites_[i].last_forced_time.is_null())
+ << "All the forced URLs must appear before non-forced URLs.";
+ }
+ }
+}
+
void TopSitesCache::GenerateCanonicalURLs() {
canonical_urls_.clear();
for (size_t i = 0; i < top_sites_.size(); i++)

Powered by Google App Engine
This is Rietveld 408576698