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

Unified Diff: chrome/browser/win/jumplist.cc

Issue 2323603002: Convert JumpList to a KeyedService. (Closed)
Patch Set: Clang fixes Created 4 years, 3 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/win/jumplist.h ('k') | chrome/browser/win/jumplist_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist.cc
diff --git a/chrome/browser/win/jumplist.cc b/chrome/browser/win/jumplist.cc
index 753c8e55fa6202c0f830a1a7b52b8a008e80b520..37790c4abcc7eb4b5c04a8223587187d3918b288 100644
--- a/chrome/browser/win/jumplist.cc
+++ b/chrome/browser/win/jumplist.cc
@@ -261,7 +261,9 @@ JumpList::JumpListData::JumpListData() {}
JumpList::JumpListData::~JumpListData() {}
JumpList::JumpList(Profile* profile)
- : profile_(profile),
+ : RefcountedKeyedService(content::BrowserThread::GetTaskRunnerForThread(
+ content::BrowserThread::UI)),
+ profile_(profile),
jumplist_data_(new base::RefCountedData<JumpListData>),
task_id_(base::CancelableTaskTracker::kBadTaskId),
weak_ptr_factory_(this) {
@@ -287,14 +289,9 @@ JumpList::JumpList(Profile* profile)
// your profile is empty. Ask TopSites to update itself when jumplist is
// initialized.
top_sites->SyncWithHistory();
- registrar_.reset(new content::NotificationRegistrar);
// Register as TopSitesObserver so that we can update ourselves when the
// TopSites changes.
top_sites->AddObserver(this);
- // Register for notification when profile is destroyed to ensure that all
- // observers are detatched at that time.
- registrar_->Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED,
- content::Source<Profile>(profile_));
}
tab_restore_service->AddObserver(this);
pref_change_registrar_.reset(new PrefChangeRegistrar);
@@ -314,15 +311,6 @@ bool JumpList::Enabled() {
return JumpListUpdater::IsEnabled();
}
-void JumpList::Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK(CalledOnValidThread());
- DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type);
- // Profile was destroyed, do clean-up.
- Terminate();
-}
-
void JumpList::CancelPendingUpdate() {
DCHECK(CalledOnValidThread());
if (task_id_ != base::CancelableTaskTracker::kBadTaskId) {
@@ -343,12 +331,16 @@ void JumpList::Terminate() {
TopSitesFactory::GetForProfile(profile_);
if (top_sites)
top_sites->RemoveObserver(this);
- registrar_.reset();
pref_change_registrar_.reset();
}
profile_ = NULL;
}
+void JumpList::ShutdownOnUIThread() {
+ DCHECK(CalledOnValidThread());
+ Terminate();
+}
+
void JumpList::OnMostVisitedURLsAvailable(
const history::MostVisitedURLList& urls) {
DCHECK(CalledOnValidThread());
« no previous file with comments | « chrome/browser/win/jumplist.h ('k') | chrome/browser/win/jumplist_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698