Index: chrome/browser/history/top_sites_impl.cc |
diff --git a/chrome/browser/history/top_sites_impl.cc b/chrome/browser/history/top_sites_impl.cc |
index ba422eeef1502295ed52669de5e4224b25502e9a..af69aeff58e9529e852a3ef9e525a737a975ecd4 100644 |
--- a/chrome/browser/history/top_sites_impl.cc |
+++ b/chrome/browser/history/top_sites_impl.cc |
@@ -115,8 +115,7 @@ TopSitesImpl::TopSitesImpl(Profile* profile) |
} |
for (int i = 0; i < kPrepopulatedPagesCount; i++) { |
int url_id = kPrepopulatedPages[i].url_id; |
- prepopulated_page_urls_.push_back( |
- GURL(l10n_util::GetStringUTF8(url_id))); |
+ prepopulated_page_urls_.push_back(GURL(l10n_util::GetStringUTF8(url_id))); |
} |
} |
@@ -214,11 +213,9 @@ void TopSitesImpl::GetMostVisitedURLs( |
if (!loaded_) { |
// A request came in before we finished loading. Store the callback and |
// we'll run it on current thread when we finish loading. |
- pending_callbacks_.push_back( |
- base::Bind(&RunOrPostGetMostVisitedURLsCallback, |
- base::MessageLoopProxy::current(), |
- include_forced_urls, |
- callback)); |
+ pending_callbacks_.push_back(base::Bind( |
+ &RunOrPostGetMostVisitedURLsCallback, |
+ base::MessageLoopProxy::current(), include_forced_urls, callback)); |
return; |
} |
if (include_forced_urls) { |
@@ -247,10 +244,9 @@ bool TopSitesImpl::GetPageThumbnail( |
// Resource bundle is thread safe. |
for (int i = 0; i < kPrepopulatedPagesCount; i++) { |
if (url == prepopulated_page_urls_[i]) { |
- *bytes = ResourceBundle::GetSharedInstance(). |
- LoadDataResourceBytesForScale( |
- kPrepopulatedPages[i].thumbnail_id, |
- ui::SCALE_FACTOR_100P); |
+ *bytes = |
+ ResourceBundle::GetSharedInstance().LoadDataResourceBytesForScale( |
+ kPrepopulatedPages[i].thumbnail_id, ui::SCALE_FACTOR_100P); |
return true; |
} |
} |
@@ -298,7 +294,6 @@ bool TopSitesImpl::GetTemporaryPageThumbnailScore(const GURL& url, |
return false; |
} |
- |
// 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++) { |
@@ -386,7 +381,6 @@ void TopSitesImpl::Shutdown() { |
void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, |
const MostVisitedURLList& new_list, |
TopSitesDelta* delta) { |
- |
// Add all the old URLs for quick lookup. This maps URLs to the corresponding |
// index in the input. |
std::map<GURL, size_t> all_old_urls; |
@@ -421,8 +415,8 @@ void TopSitesImpl::DiffMostVisited(const MostVisitedURLList& old_list, |
} else { |
DCHECK(found->second != kAlreadyFoundMarker) |
<< "Same URL appears twice in the new list."; |
- int old_rank = found->second >= num_old_forced ? |
- found->second - num_old_forced : -1; |
+ int old_rank = |
+ found->second >= num_old_forced ? found->second - num_old_forced : -1; |
if (old_rank != rank || |
old_list[found->second].last_forced_time != |
new_list[i].last_forced_time) { |
@@ -449,13 +443,12 @@ base::CancelableTaskTracker::TaskId TopSitesImpl::StartQueryForMostVisited() { |
if (!profile_) |
return base::CancelableTaskTracker::kBadTaskId; |
- HistoryService* hs = HistoryServiceFactory::GetForProfile( |
- profile_, Profile::EXPLICIT_ACCESS); |
+ HistoryService* hs = |
+ HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
// |hs| may be null during unit tests. |
if (hs) { |
return hs->QueryMostVisitedURLs( |
- num_results_to_request_from_history(), |
- kDaysOfHistory, |
+ num_results_to_request_from_history(), kDaysOfHistory, |
base::Bind(&TopSitesImpl::OnTopSitesAvailableFromHistory, |
base::Unretained(this)), |
&cancelable_task_tracker_); |
@@ -526,8 +519,7 @@ bool TopSitesImpl::SetPageThumbnailEncoded( |
size_t index = cache_->GetURLIndex(url); |
int url_rank = index - cache_->GetNumForcedURLs(); |
const MostVisitedURL& most_visited = cache_->top_sites()[index]; |
- backend_->SetPageThumbnail(most_visited, |
- url_rank < 0 ? -1 : url_rank, |
+ backend_->SetPageThumbnail(most_visited, url_rank < 0 ? -1 : url_rank, |
*(cache_->GetImage(most_visited.url))); |
return true; |
} |
@@ -637,6 +629,12 @@ bool TopSitesImpl::AddForcedURL(const GURL& url, const base::Time& time) { |
return true; |
} |
+void TopSitesImpl::ShutdownOnUIThread() { |
+ DCHECK(!BrowserThread::IsThreadInitialized(BrowserThread::UI) || |
+ BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ registrar_.RemoveAll(); |
+} |
+ |
bool TopSitesImpl::AddPrepopulatedPages(MostVisitedURLList* urls, |
size_t num_forced_urls) { |
bool added = false; |
@@ -676,9 +674,9 @@ size_t TopSitesImpl::MergeCachedForcedURLs(MostVisitedURLList* new_list) { |
// Prepend forced URLs and sort in order of ascending |last_forced_time|. |
new_list->insert(new_list->begin(), filtered_forced_urls.begin(), |
filtered_forced_urls.end()); |
- std::inplace_merge( |
- new_list->begin(), new_list->begin() + filtered_forced_urls.size(), |
- new_list->begin() + num_forced, ForcedURLComparator); |
+ std::inplace_merge(new_list->begin(), |
+ new_list->begin() + filtered_forced_urls.size(), |
+ new_list->begin() + num_forced, ForcedURLComparator); |
// Drop older forced URLs if the list overflows. Since forced URLs are always |
// sort in increasing order of |last_forced_time|, drop the first ones. |
@@ -816,8 +814,8 @@ void TopSitesImpl::SetTopSites(const MostVisitedURLList& new_top_sites) { |
for (TempImages::iterator it = temp_images_.begin(); |
it != temp_images_.end(); ++it) { |
if (canonical_url == cache_->GetCanonicalURL(it->first)) { |
- SetPageThumbnailEncoded( |
- mv.url, it->second.thumbnail.get(), it->second.thumbnail_score); |
+ SetPageThumbnailEncoded(mv.url, it->second.thumbnail.get(), |
+ it->second.thumbnail_score); |
temp_images_.erase(it); |
break; |
} |