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

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: Removed GetAllMostVisited. 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
« no previous file with comments | « chrome/browser/history/top_sites_cache.h ('k') | chrome/browser/history/top_sites_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 5914d9910c1966729724223aaad4cd52d0dea75a..4448c89e939bba9484294042cd3078c5cd878e10 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();
}
@@ -119,6 +120,31 @@ size_t TopSitesCache::GetURLIndex(const GURL& url) const {
return GetCanonicalURLsIterator(url)->second;
}
+size_t TopSitesCache::GetNumNonForcedURLs() const {
+ return top_sites_.size() - num_forced_urls_;
+}
+
+size_t TopSitesCache::GetNumForcedURLs() const {
+ return num_forced_urls_;
+}
+
+void TopSitesCache::CountForcedURLs() {
+ num_forced_urls_ = 0;
+ while (num_forced_urls_ < top_sites_.size()) {
+ // Forced sites are all at the beginning.
+ if (top_sites_[num_forced_urls_].last_forced_time.is_null())
+ break;
+ num_forced_urls_++;
+ }
+ // In debug, ensure the cache user has no forced URLs pass that point.
+ if (DCHECK_IS_ON()) {
+ for (size_t i = num_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++)
« no previous file with comments | « chrome/browser/history/top_sites_cache.h ('k') | chrome/browser/history/top_sites_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698