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

Unified Diff: chrome/browser/history/top_sites_factory.cc

Issue 815983002: Topsites become keyedService based. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the review comments Created 6 years 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/history/top_sites_factory.cc
diff --git a/chrome/browser/history/top_sites_factory.cc b/chrome/browser/history/top_sites_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..712a4a79ad2ca4e96654ea3fb4cdef365ad62c5f
--- /dev/null
+++ b/chrome/browser/history/top_sites_factory.cc
@@ -0,0 +1,48 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/history/top_sites_factory.h"
+
+#include "chrome/browser/history/top_sites_impl.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/chrome_constants.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+
+using namespace history;
+
+// static
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfile(
+ Profile* profile) {
+ return static_cast<history::TopSites*>(
+ GetInstance()->GetServiceForBrowserContext(profile, true).get());
+}
+
+// static
+scoped_refptr<history::TopSites> TopSitesFactory::GetForProfileIfExists(
+ Profile* profile) {
+ return static_cast<history::TopSites*>(
+ GetInstance()->GetServiceForBrowserContext(profile, false).get());
+}
+
+// static
+TopSitesFactory* TopSitesFactory::GetInstance() {
+ return Singleton<TopSitesFactory>::get();
+}
+
+TopSitesFactory::TopSitesFactory()
+ : RefcountedBrowserContextKeyedServiceFactory(
+ "TopSitesService",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+TopSitesFactory::~TopSitesFactory() {
+}
+
+scoped_refptr<RefcountedKeyedService>
Bernhard Bauer 2015/01/06 11:10:30 Can you move this above the constructor and destru
Jitu( very slow this week) 2015/01/08 09:38:25 Done.
+TopSitesFactory::BuildServiceInstanceFor(
+ content::BrowserContext* profile) const {
+ TopSitesImpl* top_sites = new TopSitesImpl(static_cast<Profile*>(profile));
+ top_sites->Init(profile->GetPath().Append(chrome::kTopSitesFilename));
+ return scoped_refptr<history::TopSites>(top_sites);
+}

Powered by Google App Engine
This is Rietveld 408576698