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

Unified Diff: chrome/browser/android/most_visited_sites.cc

Issue 861273002: Make TopSites a RefcountedKeyedService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win compilation Created 5 years, 11 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
Index: chrome/browser/android/most_visited_sites.cc
diff --git a/chrome/browser/android/most_visited_sites.cc b/chrome/browser/android/most_visited_sites.cc
index 5b57d4bc856922bb35593eb833851b2a04f66142..ba78b1f9a7a14cf15dcf7c3e9158f5a861fd8b55 100644
--- a/chrome/browser/android/most_visited_sites.cc
+++ b/chrome/browser/android/most_visited_sites.cc
@@ -19,6 +19,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "chrome/browser/history/top_sites.h"
+#include "chrome/browser/history/top_sites_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_android.h"
#include "chrome/browser/search/suggestions/suggestions_service_factory.h"
@@ -230,7 +231,8 @@ void MostVisitedSites::SetMostVisitedURLsObserver(JNIEnv* env,
QueryMostVisitedURLs();
- history::TopSites* top_sites = profile_->GetTopSites();
+ scoped_refptr<history::TopSites> top_sites =
+ TopSitesFactory::GetForProfile(profile_);
if (top_sites) {
// TopSites updates itself after a delay. To ensure up-to-date results,
// force an update now.
@@ -238,7 +240,7 @@ void MostVisitedSites::SetMostVisitedURLsObserver(JNIEnv* env,
// Register as TopSitesObserver so that we can update ourselves when the
// TopSites changes.
- scoped_observer_.Add(top_sites);
+ scoped_observer_.Add(top_sites.get());
}
}
@@ -253,7 +255,7 @@ void MostVisitedSites::GetURLThumbnail(JNIEnv* env,
j_callback->Reset(env, j_callback_obj);
std::string url_string = ConvertJavaStringToUTF8(env, url);
- scoped_refptr<TopSites> top_sites(profile_->GetTopSites());
+ scoped_refptr<TopSites> top_sites(TopSitesFactory::GetForProfile(profile_));
// If the Suggestions service is enabled and in use, create a callback to
// fetch a server thumbnail from it, in case the local thumbnail is not found.
@@ -273,10 +275,9 @@ void MostVisitedSites::GetURLThumbnail(JNIEnv* env,
BrowserThread::PostTask(
BrowserThread::DB, FROM_HERE,
- base::Bind(
- &GetUrlThumbnailTask, url_string, top_sites,
- base::Owned(j_callback), lookup_success_callback,
- lookup_failed_callback));
+ base::Bind(&GetUrlThumbnailTask, url_string, top_sites,
+ base::Owned(j_callback), lookup_success_callback,
+ lookup_failed_callback));
}
void MostVisitedSites::BlacklistUrl(JNIEnv* env,
@@ -286,7 +287,8 @@ void MostVisitedSites::BlacklistUrl(JNIEnv* env,
switch (mv_source_) {
case TOP_SITES: {
- TopSites* top_sites = profile_->GetTopSites();
+ scoped_refptr<TopSites> top_sites =
+ TopSitesFactory::GetForProfile(profile_);
DCHECK(top_sites);
top_sites->AddBlacklistedURL(GURL(url));
break;
@@ -363,16 +365,15 @@ void MostVisitedSites::QueryMostVisitedURLs() {
}
void MostVisitedSites::InitiateTopSitesQuery() {
- TopSites* top_sites = profile_->GetTopSites();
+ scoped_refptr<TopSites> top_sites = TopSitesFactory::GetForProfile(profile_);
if (!top_sites)
return;
top_sites->GetMostVisitedURLs(
- base::Bind(
- &MostVisitedSites::OnMostVisitedURLsAvailable,
- weak_ptr_factory_.GetWeakPtr(),
- base::Owned(new ScopedJavaGlobalRef<jobject>(observer_)),
- num_sites_),
+ base::Bind(&MostVisitedSites::OnMostVisitedURLsAvailable,
+ weak_ptr_factory_.GetWeakPtr(),
+ base::Owned(new ScopedJavaGlobalRef<jobject>(observer_)),
+ num_sites_),
false);
}
« no previous file with comments | « chrome/browser/android/dev_tools_server.cc ('k') | chrome/browser/android/provider/chrome_browser_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698