Index: chrome/browser/history/top_sites.cc |
diff --git a/chrome/browser/history/top_sites.cc b/chrome/browser/history/top_sites.cc |
index 668c4df50e0e98d0f767663733edfb86b3f268ca..328ca77bb9e64b79689d3cebec99aa0aa1ff89d6 100644 |
--- a/chrome/browser/history/top_sites.cc |
+++ b/chrome/browser/history/top_sites.cc |
@@ -127,7 +127,7 @@ class LoadThumbnailsFromHistoryTask : public HistoryDBTask { |
} // namespace |
TopSites::TopSites(Profile* profile) |
- : backend_(new TopSitesBackend()), |
+ : backend_(NULL), |
cache_(new TopSitesCache()), |
thread_safe_cache_(new TopSitesCache()), |
profile_(profile), |
@@ -154,6 +154,7 @@ TopSites::TopSites(Profile* profile) |
} |
void TopSites::Init(const FilePath& db_name) { |
+ backend_ = new TopSitesBackend; |
satorux1
2011/01/26 10:53:59
Moved instantiation here.
brettw
2011/01/26 16:40:32
Can you add a comment why it's here rather than in
satorux1
2011/01/27 02:02:11
Good point. Added a comment.
|
backend_->Init(db_name); |
backend_->GetMostVisitedThumbnails( |
&cancelable_consumer_, |
@@ -181,8 +182,8 @@ bool TopSites::SetPageThumbnail(const GURL& url, |
} |
bool add_temp_thumbnail = false; |
- if (!cache_->IsKnownURL(url)) { |
- if (cache_->top_sites().size() < kTopSitesNumber) { |
+ if (!IsKnownURL(url)) { |
+ if (!IsFull()) { |
add_temp_thumbnail = true; |
} else { |
return false; // This URL is not known to us. |
@@ -237,6 +238,13 @@ bool TopSites::GetPageThumbnail(const GURL& url, |
return thread_safe_cache_->GetPageThumbnail(url, bytes); |
} |
+bool TopSites::GetPageThumbnailScore(const GURL& url, |
+ ThumbnailScore* score) { |
+ // WARNING: this may be invoked on any thread. |
+ base::AutoLock lock(lock_); |
+ return thread_safe_cache_->GetPageThumbnailScore(url, score); |
+} |
+ |
// Returns the index of |url| in |urls|, or -1 if not found. |
static int IndexOf(const MostVisitedURLList& urls, const GURL& url) { |
for (size_t i = 0; i < urls.size(); i++) { |
@@ -449,6 +457,14 @@ CancelableRequestProvider::Handle TopSites::StartQueryForMostVisited() { |
return 0; |
} |
+bool TopSites::IsKnownURL(const GURL& url) { |
+ return loaded_ && cache_->IsKnownURL(url); |
+} |
+ |
+bool TopSites::IsFull() { |
+ return loaded_ && cache_->top_sites().size() >= kTopSitesNumber; |
+} |
+ |
TopSites::~TopSites() { |
} |
@@ -724,7 +740,7 @@ void TopSites::Observe(NotificationType type, |
} |
StartQueryForMostVisited(); |
} else if (type == NotificationType::NAV_ENTRY_COMMITTED) { |
- if (cache_->top_sites().size() < kTopSitesNumber) { |
+ if (!IsFull()) { |
NavigationController::LoadCommittedDetails* load_details = |
Details<NavigationController::LoadCommittedDetails>(details).ptr(); |
if (!load_details) |