diff options
| author | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:01:10 +0000 |
|---|---|---|
| committer | rlp@chromium.org <rlp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-19 00:01:10 +0000 |
| commit | 9d2db766194046d9a60e6e9e18376f678c2ae1d4 (patch) | |
| tree | e97672da4768cd776aba17c4fc3f85040486e778 | |
| parent | 43478cf1c2990389ac8b41630044ff533be11486 (diff) | |
| download | chromium_src-9d2db766194046d9a60e6e9e18376f678c2ae1d4.zip chromium_src-9d2db766194046d9a60e6e9e18376f678c2ae1d4.tar.gz chromium_src-9d2db766194046d9a60e6e9e18376f678c2ae1d4.tar.bz2 | |
Removing usage of profile_->GetHistory() from the codebase in order to remove that function.
BUG=97804
TEST=existing unittests
Review URL: https://chromiumcodereview.appspot.com/10557021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142866 0039d316-1c4b-4281-b951-d872f2087c98
15 files changed, 52 insertions, 22 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_browsertest.cc b/chrome/browser/autocomplete/autocomplete_browsertest.cc index f5c1962..4fa8dcd 100644 --- a/chrome/browser/autocomplete/autocomplete_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_browsertest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/unpacked_installer.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" @@ -103,7 +104,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, MAYBE_Autocomplete) { // The results depend on the history backend being loaded. Make sure it is // loaded so that the autocomplete results are consistent. ui_test_utils::WaitForHistoryToLoad( - browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); + HistoryServiceFactory::GetForProfile(browser()->profile(), + Profile::EXPLICIT_ACCESS)); LocationBar* location_bar = GetLocationBar(); AutocompleteController* autocomplete_controller = GetAutocompleteController(); @@ -266,7 +268,8 @@ IN_PROC_BROWSER_TEST_F(AutocompleteBrowserTest, ExtensionAppProvider) { // The results depend on the history backend being loaded. Make sure it is // loaded so that the autocomplete results are consistent. ui_test_utils::WaitForHistoryToLoad( - browser()->profile()->GetHistoryService(Profile::EXPLICIT_ACCESS)); + HistoryServiceFactory::GetForProfile(browser()->profile(), + Profile::EXPLICIT_ACCESS)); AutocompleteController* autocomplete_controller = GetAutocompleteController(); diff --git a/chrome/browser/autocomplete/extension_app_provider.cc b/chrome/browser/autocomplete/extension_app_provider.cc index 6d38b2d8..d11c5aa 100644 --- a/chrome/browser/autocomplete/extension_app_provider.cc +++ b/chrome/browser/autocomplete/extension_app_provider.cc @@ -12,6 +12,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_system_factory.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/url_database.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/extensions/application_launch.h" @@ -206,7 +207,7 @@ int ExtensionAppProvider::CalculateRelevance(AutocompleteInput::Type type, // provider (boost is between 200-400). double type_count_boost = 0; HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); history::URLDatabase* url_db = history_service ? history_service->InMemoryDatabase() : NULL; if (url_db) { diff --git a/chrome/browser/autocomplete/extension_app_provider_unittest.cc b/chrome/browser/autocomplete/extension_app_provider_unittest.cc index 6d25e34..a818628 100644 --- a/chrome/browser/autocomplete/extension_app_provider_unittest.cc +++ b/chrome/browser/autocomplete/extension_app_provider_unittest.cc @@ -8,6 +8,7 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/extension_app_provider.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/url_database.h" #include "chrome/test/base/testing_profile.h" #include "testing/gtest/include/gtest/gtest.h" @@ -39,7 +40,9 @@ void ExtensionAppProviderTest::SetUp() { profile_.reset(new TestingProfile()); profile_->CreateHistoryService(true, false); profile_->BlockUntilHistoryProcessesPendingRequests(); - history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + history_service_ = + HistoryServiceFactory::GetForProfile(profile_.get(), + Profile::EXPLICIT_ACCESS); app_provider_ = new ExtensionAppProvider(NULL, profile_.get()); diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc index c851f42..70c6d56 100644 --- a/chrome/browser/autocomplete/history_contents_provider.cc +++ b/chrome/browser/autocomplete/history_contents_provider.cc @@ -12,6 +12,7 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/url_constants.h" #include "googleurl/src/url_util.h" @@ -66,7 +67,8 @@ void HistoryContentsProvider::Start(const AutocompleteInput& input, (input.type() == AutocompleteInput::FORCED_QUERY) || !profile_ || // The history service or bookmark bar model must exist. - !(profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) || + !(HistoryServiceFactory::GetForProfile(profile_, + Profile::EXPLICIT_ACCESS) || profile_->GetBookmarkModel())) { Stop(); return; @@ -129,7 +131,8 @@ void HistoryContentsProvider::Start(const AutocompleteInput& input, if (input.matches_requested() == AutocompleteInput::ALL_MATCHES) { HistoryService* history = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, + Profile::EXPLICIT_ACCESS); if (history) { done_ = false; diff --git a/chrome/browser/autocomplete/history_contents_provider_unittest.cc b/chrome/browser/autocomplete/history_contents_provider_unittest.cc index 0c4349d..e678fb8 100644 --- a/chrome/browser/autocomplete/history_contents_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_contents_provider_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 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. @@ -12,6 +12,7 @@ #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" #include "content/public/test/test_browser_thread.h" @@ -65,7 +66,8 @@ class HistoryContentsProviderTest : public testing::Test, profile_->CreateHistoryService(false, false); HistoryService* history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_.get(), + Profile::EXPLICIT_ACCESS); // Populate history. for (size_t i = 0; i < arraysize(test_entries); i++) { diff --git a/chrome/browser/autocomplete/history_provider.cc b/chrome/browser/autocomplete/history_provider.cc index eab7c65..fcbc713 100644 --- a/chrome/browser/autocomplete/history_provider.cc +++ b/chrome/browser/autocomplete/history_provider.cc @@ -11,6 +11,7 @@ #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/profiles/profile.h" #include "chrome/common/url_constants.h" @@ -31,7 +32,7 @@ void HistoryProvider::DeleteMatch(const AutocompleteMatch& match) { DCHECK(match.deletable); HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); // Delete the match from the history DB. DCHECK(history_service); diff --git a/chrome/browser/autocomplete/history_quick_provider.cc b/chrome/browser/autocomplete/history_quick_provider.cc index 7f97d77..dd7fb1d 100644 --- a/chrome/browser/autocomplete/history_quick_provider.cc +++ b/chrome/browser/autocomplete/history_quick_provider.cc @@ -18,6 +18,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/autocomplete/autocomplete_field_trial.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/in_memory_url_index.h" #include "chrome/browser/history/in_memory_url_index_types.h" #include "chrome/browser/history/scored_history_match.h" @@ -239,7 +240,7 @@ history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { return index_for_testing_.get(); HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); if (!history_service) return NULL; diff --git a/chrome/browser/autocomplete/history_quick_provider_unittest.cc b/chrome/browser/autocomplete/history_quick_provider_unittest.cc index 5005df9..9105e1c 100644 --- a/chrome/browser/autocomplete/history_quick_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_quick_provider_unittest.cc @@ -16,6 +16,7 @@ #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/in_memory_url_index.h" #include "chrome/browser/history/url_database.h" #include "chrome/browser/history/url_index_private_data.h" @@ -136,7 +137,9 @@ void HistoryQuickProviderTest::SetUp() { profile_->CreateHistoryService(true, false); profile_->CreateBookmarkModel(true); profile_->BlockUntilBookmarkModelLoaded(); - history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + history_service_ = + HistoryServiceFactory::GetForProfile(profile_.get(), + Profile::EXPLICIT_ACCESS); EXPECT_TRUE(history_service_); provider_ = new HistoryQuickProvider(this, profile_.get()); FillData(); diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index b50893e..ff96896 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -17,6 +17,7 @@ #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_backend.h" #include "chrome/browser/history/history_database.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/history_types.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" @@ -534,7 +535,7 @@ void HistoryURLProvider::RunAutocompletePasses( if (!profile_) return; HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); if (!history_service) return; diff --git a/chrome/browser/autocomplete/history_url_provider_unittest.cc b/chrome/browser/autocomplete/history_url_provider_unittest.cc index b67c831..3efbce2a 100644 --- a/chrome/browser/autocomplete/history_url_provider_unittest.cc +++ b/chrome/browser/autocomplete/history_url_provider_unittest.cc @@ -14,6 +14,7 @@ #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/autocomplete/history_quick_provider.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/test/base/testing_browser_process.h" #include "chrome/test/base/testing_profile.h" @@ -189,7 +190,9 @@ void HistoryURLProviderTest::OnProviderUpdate(bool updated_matches) { void HistoryURLProviderTest::SetUpImpl(bool no_db) { profile_.reset(new TestingProfile()); profile_->CreateHistoryService(true, no_db); - history_service_ = profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + history_service_ = + HistoryServiceFactory::GetForProfile(profile_.get(), + Profile::EXPLICIT_ACCESS); autocomplete_ = new HistoryURLProvider(this, profile_.get(), "en-US,en,ko"); diff --git a/chrome/browser/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc index 9d1281b..4da6005 100644 --- a/chrome/browser/autocomplete/search_provider.cc +++ b/chrome/browser/autocomplete/search_provider.cc @@ -25,6 +25,7 @@ #include "chrome/browser/autocomplete/keyword_provider.h" #include "chrome/browser/autocomplete/url_prefix.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/history/in_memory_database.h" #include "chrome/browser/instant/instant_controller.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -392,7 +393,7 @@ void SearchProvider::DoHistoryQuery(bool minimal_changes) { default_history_results_.clear(); HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); history::URLDatabase* url_db = history_service ? history_service->InMemoryDatabase() : NULL; if (!url_db) diff --git a/chrome/browser/autocomplete/search_provider_unittest.cc b/chrome/browser/autocomplete/search_provider_unittest.cc index 227c163..d1b335d 100644 --- a/chrome/browser/autocomplete/search_provider_unittest.cc +++ b/chrome/browser/autocomplete/search_provider_unittest.cc @@ -12,6 +12,7 @@ #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" #include "chrome/browser/autocomplete/autocomplete_match.h" #include "chrome/browser/history/history.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_service.h" @@ -225,7 +226,8 @@ GURL SearchProviderTest::AddSearchToHistory(TemplateURL* t_url, string16 term, int visit_count) { HistoryService* history = - profile_.GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(&profile_, + Profile::EXPLICIT_ACCESS); GURL search(t_url->url_ref().ReplaceSearchTerms(term, TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())); static base::Time last_added_time; @@ -500,9 +502,9 @@ TEST_F(SearchProviderTest, DontAutocompleteURLLikeTerms) { ASCIIToUTF16("docs.google.com"), 1); // Add the term as a url. - profile_.GetHistoryService(Profile::EXPLICIT_ACCESS)->AddPageWithDetails( - GURL("http://docs.google.com"), string16(), 1, 1, base::Time::Now(), - false, history::SOURCE_BROWSED); + HistoryServiceFactory::GetForProfile(&profile_, Profile::EXPLICIT_ACCESS)-> + AddPageWithDetails(GURL("http://docs.google.com"), string16(), 1, 1, + base::Time::Now(), false, history::SOURCE_BROWSED); profile_.BlockUntilHistoryProcessesPendingRequests(); AutocompleteMatch wyt_match; diff --git a/chrome/browser/autocomplete/shortcuts_provider.cc b/chrome/browser/autocomplete/shortcuts_provider.cc index e9dd5a5..7fcd83c 100644 --- a/chrome/browser/autocomplete/shortcuts_provider.cc +++ b/chrome/browser/autocomplete/shortcuts_provider.cc @@ -19,6 +19,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_notifications.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -100,7 +101,7 @@ void ShortcutsProvider::DeleteMatch(const AutocompleteMatch& match) { // Delete the match from the history DB. This will eventually result in a // second call to DeleteShortcutsWithURLs(), which is harmless. HistoryService* const history_service = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); DCHECK(history_service && match.destination_url.is_valid()); history_service->DeleteURL(match.destination_url); diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc index 36a7a3b..59fe329 100644 --- a/chrome/browser/search_engines/template_url_service.cc +++ b/chrome/browser/search_engines/template_url_service.cc @@ -20,6 +20,7 @@ #include "chrome/browser/google/google_url_tracker.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_notifications.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -1292,7 +1293,9 @@ void TemplateURLService::SetKeywordSearchTermsForURL(const TemplateURL* t_url, const GURL& url, const string16& term) { HistoryService* history = profile_ ? - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS) : NULL; + HistoryServiceFactory::GetForProfile(profile_, + Profile::EXPLICIT_ACCESS) : + NULL; if (!history) return; history->SetKeywordSearchTermsForURL(url, t_url->id(), term); @@ -1794,7 +1797,7 @@ void TemplateURLService::AddTabToSearchVisit(const TemplateURL& t_url) { return; HistoryService* history = - profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); if (!history) return; diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc index fb43f83..92bdb37 100644 --- a/chrome/browser/search_engines/template_url_service_unittest.cc +++ b/chrome/browser/search_engines/template_url_service_unittest.cc @@ -14,6 +14,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_notifications.h" +#include "chrome/browser/history/history_service_factory.h" #include "chrome/browser/search_engines/search_host_to_urls_map.h" #include "chrome/browser/search_engines/search_terms_data.h" #include "chrome/browser/search_engines/template_url.h" @@ -1058,7 +1059,8 @@ TEST_F(TemplateURLServiceTest, GenerateVisitOnKeyword) { // Add a visit that matches the url of the keyword. HistoryService* history = - test_util_.profile()->GetHistoryService(Profile::EXPLICIT_ACCESS); + HistoryServiceFactory::GetForProfile(test_util_.profile(), + Profile::EXPLICIT_ACCESS); history->AddPage( GURL(t_url->url_ref().ReplaceSearchTerms(ASCIIToUTF16("blah"), TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), |
