Index: chrome/browser/history/history_service.cc |
diff --git a/chrome/browser/history/history_service.cc b/chrome/browser/history/history_service.cc |
index 9277196d8301421edcd9066253b2374dc812cf6c..bb91c5a36949a92c41cdfb04bc53fe7538569e4a 100644 |
--- a/chrome/browser/history/history_service.cc |
+++ b/chrome/browser/history/history_service.cc |
@@ -221,22 +221,20 @@ class HistoryService::BackendDelegate : public HistoryBackend::Delegate { |
HistoryService::HistoryService() |
: thread_(new base::Thread(kHistoryThreadName)), |
history_client_(NULL), |
- profile_(NULL), |
backend_loaded_(false), |
no_db_(false), |
weak_ptr_factory_(this) { |
} |
-HistoryService::HistoryService(history::HistoryClient* client, Profile* profile) |
+HistoryService::HistoryService( |
+ history::HistoryClient* history_client, Profile* profile) |
: thread_(new base::Thread(kHistoryThreadName)), |
- history_client_(client), |
- profile_(profile), |
+ history_client_(history_client), |
visitedlink_master_(new visitedlink::VisitedLinkMaster( |
profile, this, true)), |
backend_loaded_(false), |
no_db_(false), |
weak_ptr_factory_(this) { |
- DCHECK(profile_); |
} |
HistoryService::~HistoryService() { |
@@ -967,6 +965,7 @@ void HistoryService::RebuildTable( |
bool HistoryService::Init( |
bool no_db, |
+ PrefService* prefs, |
const history::HistoryDatabaseParams& history_database_params) { |
DCHECK(thread_) << "History service being called after cleanup"; |
DCHECK(thread_checker_.CalledOnValidThread()); |
@@ -980,9 +979,10 @@ bool HistoryService::Init( |
history_dir_ = history_database_params.history_dir; |
no_db_ = no_db; |
- if (profile_) { |
- std::string languages = |
- profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
+ std::string languages; |
+ if (prefs) { |
+ // During unit testing, there may not be a PrefService. |
+ languages = prefs->GetString(prefs::kAcceptLanguages); |
in_memory_url_index_.reset(new history::InMemoryURLIndex( |
this, history_dir_, languages, history_client_)); |
in_memory_url_index_->Init(); |
@@ -995,13 +995,6 @@ bool HistoryService::Init( |
history_client_)); |
history_backend_.swap(backend); |
- // There may not be a profile when unit testing. |
- std::string languages; |
- if (profile_) { |
- PrefService* prefs = profile_->GetPrefs(); |
- languages = prefs->GetString(prefs::kAcceptLanguages); |
- } |
- |
ScheduleTask(PRIORITY_UI, |
base::Bind(&HistoryBackend::Init, history_backend_.get(), |
languages, no_db_, history_database_params)); |