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

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

Issue 285233012: Abstract history dependencies on bookmarks through HistoryClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit tests Created 6 years, 7 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/history/history_service.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/history/history_service_factory.cc
diff --git a/chrome/browser/history/history_service_factory.cc b/chrome/browser/history/history_service_factory.cc
index 13f137f60611fe466847634efc7373a1b892cebf..7e74f72006bed195f0db030dac3e7f397c3a3077 100644
--- a/chrome/browser/history/history_service_factory.cc
+++ b/chrome/browser/history/history_service_factory.cc
@@ -6,12 +6,15 @@
#include "base/prefs/pref_service.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
+#include "chrome/browser/history/chrome_history_client.h"
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/common/pref_names.h"
#include "components/bookmarks/browser/bookmark_model.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
+using history::ChromeHistoryClient;
+
// static
HistoryService* HistoryServiceFactory::GetForProfile(
Profile* profile, Profile::ServiceAccessType sat) {
@@ -20,8 +23,9 @@ HistoryService* HistoryServiceFactory::GetForProfile(
sat != Profile::EXPLICIT_ACCESS)
return NULL;
- return static_cast<HistoryService*>(
+ ChromeHistoryClient* history_client = static_cast<ChromeHistoryClient*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
+ return history_client ? history_client->history_service() : NULL;
}
// static
@@ -33,15 +37,17 @@ HistoryServiceFactory::GetForProfileIfExists(
sat != Profile::EXPLICIT_ACCESS)
return NULL;
- return static_cast<HistoryService*>(
+ ChromeHistoryClient* history_client = static_cast<ChromeHistoryClient*>(
GetInstance()->GetServiceForBrowserContext(profile, false));
+ return history_client ? history_client->history_service() : NULL;
}
// static
HistoryService*
HistoryServiceFactory::GetForProfileWithoutCreating(Profile* profile) {
- return static_cast<HistoryService*>(
+ ChromeHistoryClient* history_client = static_cast<ChromeHistoryClient*>(
GetInstance()->GetServiceForBrowserContext(profile, false));
+ return history_client ? history_client->history_service() : NULL;
}
// static
@@ -67,12 +73,13 @@ HistoryServiceFactory::~HistoryServiceFactory() {
KeyedService* HistoryServiceFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = static_cast<Profile*>(context);
- HistoryService* history_service = new HistoryService(profile);
- if (!history_service->Init(profile->GetPath(),
- BookmarkModelFactory::GetForProfile(profile))) {
+ scoped_ptr<ChromeHistoryClient> history_client(
blundell 2014/05/23 11:37:55 There's no reason to make this change. The History
sdefresne 2014/05/23 13:59:30 Done.
+ new ChromeHistoryClient(profile));
+ HistoryService* history_service = history_client->history_service();
+ if (!history_service->Init(profile->GetPath())) {
return NULL;
}
- return history_service;
+ return history_client.release();
}
content::BrowserContext* HistoryServiceFactory::GetBrowserContextToUse(
« no previous file with comments | « chrome/browser/history/history_service.cc ('k') | chrome/browser/history/history_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698