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

Unified Diff: chrome/browser/thumbnails/thumbnail_list_source.cc

Issue 1021803002: [Thumbnails] Injecting TopSites into ThumbnailListSource. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensured some routines are in the IO thread. Created 5 years, 9 months 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/thumbnails/thumbnail_list_source.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/thumbnails/thumbnail_list_source.cc
diff --git a/chrome/browser/thumbnails/thumbnail_list_source.cc b/chrome/browser/thumbnails/thumbnail_list_source.cc
index 1cba5a6b06d9a6d653fc43fbeb17181892c0993d..604b3d368a5582150c49af86c34ccd9412fe8e09 100644
--- a/chrome/browser/thumbnails/thumbnail_list_source.cc
+++ b/chrome/browser/thumbnails/thumbnail_list_source.cc
@@ -18,9 +18,12 @@
#include "chrome/browser/thumbnails/thumbnail_service_factory.h"
#include "chrome/common/url_constants.h"
#include "components/history/core/browser/top_sites.h"
+#include "content/public/browser/browser_thread.h"
#include "net/base/escape.h"
#include "net/url_request/url_request.h"
+using content::BrowserThread;
+
namespace {
const char kHtmlHeader[] =
@@ -79,7 +82,7 @@ void RenderMostVisitedURLList(
ThumbnailListSource::ThumbnailListSource(Profile* profile)
: thumbnail_service_(ThumbnailServiceFactory::GetForProfile(profile)),
- profile_(profile),
+ top_sites_(TopSitesFactory::GetForProfile(profile)),
weak_ptr_factory_(this) {
}
@@ -95,14 +98,13 @@ void ThumbnailListSource::StartDataRequest(
int render_process_id,
int render_frame_id,
const content::URLDataSource::GotDataCallback& callback) {
- scoped_refptr<history::TopSites> top_sites =
- TopSitesFactory::GetForProfile(profile_);
- if (!top_sites) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (!top_sites_) {
callback.Run(NULL);
return;
}
- top_sites->GetMostVisitedURLs(
+ top_sites_->GetMostVisitedURLs(
base::Bind(&ThumbnailListSource::OnMostVisitedURLsAvailable,
weak_ptr_factory_.GetWeakPtr(), callback),
true);
@@ -133,6 +135,7 @@ bool ThumbnailListSource::ShouldReplaceExistingSource() const {
void ThumbnailListSource::OnMostVisitedURLsAvailable(
const content::URLDataSource::GotDataCallback& callback,
const history::MostVisitedURLList& mvurl_list) {
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
const size_t num_mv = mvurl_list.size();
size_t num_mv_with_thumb = 0;
« no previous file with comments | « chrome/browser/thumbnails/thumbnail_list_source.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698