summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 07:36:36 +0000
committeryusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-11 07:36:36 +0000
commit2d99a984b6323cf6cc5c9a4c359d3c3f61f59612 (patch)
tree9f6007622beded72c5d742196efeaae651aa1fbc
parent294dd0316b3246c30e4558e8ec380479c9e82481 (diff)
downloadchromium_src-2d99a984b6323cf6cc5c9a4c359d3c3f61f59612.zip
chromium_src-2d99a984b6323cf6cc5c9a4c359d3c3f61f59612.tar.gz
chromium_src-2d99a984b6323cf6cc5c9a4c359d3c3f61f59612.tar.bz2
Revert 136499 - Taking over issue 10006037.
Moved WebDataService to ProfileKeyedService James: chrome\browser\ui\intents Peter: chrome\browser\ui\search_engines chrome\browser\search_engines Nicolas: chrome\browser\sync Rachel/Elliot: chrome\browser\profiles and the whole cl BUG=112234 TEST=unit-tests TBR=jhawkins@chromium.org,pkasting@chromium.org,zea@chromium.org,erg@chromium.org,isherman@chromium.org Review URL: https://chromiumcodereview.appspot.com/10185008 Reason of the revert: The CL broke the following linux_chromeos browser_tests. EnterpriseLoginBlocksForEnterpriseUser_0 EnterpriseLoginBlocksForEnterpriseUser_1 EnterpriseLoginBlocksForEnterpriseUser_2 EnterpriseLoginBlocksForEnterpriseUser_3 EnterpriseLoginBlocksForEnterpriseUser_4 EnterpriseLoginBlocksForEnterpriseUser_5 EnterpriseLoginDoesntBlockForNormalUser NormalLoginDoesntBlock sample log: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%282%29/builds/1071/steps/browser_tests/logs/stdio [14648:14648:0510/212507:358430278:FATAL:web_data_service.cc(96)] Check failed: BrowserThread::IsWellKnownThread(BrowserThread::DB). Backtrace: base::debug::StackTrace::StackTrace() [0x7ff2e9b74e76] logging::LogMessage::~LogMessage() [0x7ff2e9ba6627] WebDataService::WebDataService() [0x144d7a7] TBR=rlp@chromium.org Review URL: https://chromiumcodereview.appspot.com/10382123 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136522 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/autocomplete_history_manager.cc4
-rw-r--r--chrome/browser/autocomplete_history_manager_unittest.cc4
-rw-r--r--chrome/browser/autofill/autofill_metrics_unittest.cc1
-rw-r--r--chrome/browser/autofill/personal_data_manager.cc95
-rw-r--r--chrome/browser/autofill/personal_data_manager_factory.cc4
-rw-r--r--chrome/browser/autofill/personal_data_manager_unittest.cc8
-rw-r--r--chrome/browser/browser_process_impl.h1
-rw-r--r--chrome/browser/browsing_data_remover.cc8
-rw-r--r--chrome/browser/extensions/app_notify_channel_setup_unittest.cc17
-rw-r--r--chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc13
-rw-r--r--chrome/browser/importer/profile_writer.cc4
-rw-r--r--chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc15
-rw-r--r--chrome/browser/intents/web_intents_registry_factory.cc7
-rw-r--r--chrome/browser/intents/web_intents_registry_unittest.cc14
-rw-r--r--chrome/browser/memory_purger.cc8
-rw-r--r--chrome/browser/password_manager/password_store_factory.cc9
-rw-r--r--chrome/browser/password_manager/password_store_win_unittest.cc9
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.cc13
-rw-r--r--chrome/browser/profiles/off_the_record_profile_impl.h2
-rw-r--r--chrome/browser/profiles/profile.h11
-rw-r--r--chrome/browser/profiles/profile_dependency_manager.cc4
-rw-r--r--chrome/browser/profiles/profile_impl.cc34
-rw-r--r--chrome/browser/profiles/profile_impl.h5
-rw-r--r--chrome/browser/search_engines/search_provider_install_data.cc4
-rw-r--r--chrome/browser/search_engines/template_url_service.cc13
-rw-r--r--chrome/browser/search_engines/template_url_service_factory.cc3
-rw-r--r--chrome/browser/search_engines/template_url_service_test_util.cc35
-rw-r--r--chrome/browser/search_engines/template_url_service_unittest.cc6
-rw-r--r--chrome/browser/signin/token_service.cc4
-rw-r--r--chrome/browser/signin/token_service_factory.cc5
-rw-r--r--chrome/browser/signin/token_service_unittest.cc14
-rw-r--r--chrome/browser/signin/ubertoken_fetcher_unittest.cc2
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller.cc4
-rw-r--r--chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc28
-rw-r--r--chrome/browser/sync/glue/autofill_profile_data_type_controller.cc7
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.cc22
-rw-r--r--chrome/browser/sync/profile_sync_components_factory_impl.h4
-rw-r--r--chrome/browser/sync/profile_sync_service_autofill_unittest.cc30
-rw-r--r--chrome/browser/sync/profile_sync_service_factory.cc3
-rw-r--r--chrome/browser/sync/profile_sync_service_startup_unittest.cc2
-rw-r--r--chrome/browser/sync/profile_sync_service_unittest.cc2
-rw-r--r--chrome/browser/sync/test/integration/autofill_helper.cc13
-rw-r--r--chrome/browser/sync/test/integration/autofill_helper.h3
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc7
-rw-r--r--chrome/browser/ui/intents/web_intents_model_unittest.cc9
-rw-r--r--chrome/browser/webdata/web_data_service.cc41
-rw-r--r--chrome/browser/webdata/web_data_service.h14
-rw-r--r--chrome/browser/webdata/web_data_service_factory.cc61
-rw-r--r--chrome/browser/webdata/web_data_service_factory.h44
-rw-r--r--chrome/browser/webdata/web_data_service_unittest.cc8
-rw-r--r--chrome/chrome_browser.gypi2
-rw-r--r--chrome/test/base/browser_with_test_window_test.cc10
-rw-r--r--chrome/test/base/browser_with_test_window_test.h1
-rw-r--r--chrome/test/base/profile_mock.h1
-rw-r--r--chrome/test/base/testing_profile.cc40
-rw-r--r--chrome/test/base/testing_profile.h19
56 files changed, 268 insertions, 483 deletions
diff --git a/chrome/browser/autocomplete_history_manager.cc b/chrome/browser/autocomplete_history_manager.cc
index b026753..b287c89 100644
--- a/chrome/browser/autocomplete_history_manager.cc
+++ b/chrome/browser/autocomplete_history_manager.cc
@@ -13,7 +13,6 @@
#include "chrome/browser/autofill/credit_card.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/autofill_messages.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/render_view_host.h"
@@ -116,8 +115,7 @@ AutocompleteHistoryManager::AutocompleteHistoryManager(
external_delegate_(NULL) {
profile_ = Profile::FromBrowserContext(web_contents->GetBrowserContext());
// May be NULL in unit tests.
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
+ web_data_service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
autofill_enabled_.Init(prefs::kAutofillEnabled, profile_->GetPrefs(), NULL);
}
diff --git a/chrome/browser/autocomplete_history_manager_unittest.cc b/chrome/browser/autocomplete_history_manager_unittest.cc
index 41185ec..0e68d69 100644
--- a/chrome/browser/autocomplete_history_manager_unittest.cc
+++ b/chrome/browser/autocomplete_history_manager_unittest.cc
@@ -37,8 +37,7 @@ class MockWebDataService : public WebDataService {
class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
protected:
AutocompleteHistoryManagerTest()
- : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
- db_thread_(BrowserThread::DB) {
+ : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {
}
virtual void SetUp() {
@@ -49,7 +48,6 @@ class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness {
}
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
TestingProfile profile_;
scoped_refptr<MockWebDataService> web_data_service_;
diff --git a/chrome/browser/autofill/autofill_metrics_unittest.cc b/chrome/browser/autofill/autofill_metrics_unittest.cc
index d6abecc..df71b84 100644
--- a/chrome/browser/autofill/autofill_metrics_unittest.cc
+++ b/chrome/browser/autofill/autofill_metrics_unittest.cc
@@ -930,7 +930,6 @@ TEST_F(AutofillMetricsTest, AutofillIsEnabledAtStartup) {
EXPECT_CALL(*personal_data_.metric_logger(),
LogIsAutofillEnabledAtStartup(true)).Times(1);
personal_data_.Init(profile());
- personal_data_.Shutdown();
personal_data_.set_autofill_enabled(false);
EXPECT_CALL(*personal_data_.metric_logger(),
diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
index 1bc4ded..7ab1285 100644
--- a/chrome/browser/autofill/personal_data_manager.cc
+++ b/chrome/browser/autofill/personal_data_manager.cc
@@ -25,7 +25,6 @@
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -171,11 +170,10 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
if (sync_service && (!sync_service->HasSyncSetupCompleted() ||
!profile_->GetPrefs()->GetBoolean(prefs::kSyncAutofill))) {
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_,
- Profile::EXPLICIT_ACCESS);
- if (web_data_service)
- web_data_service->RemoveExpiredFormElements();
+ WebDataService* wds =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (wds)
+ wds->RemoveExpiredFormElements();
}
}
}
@@ -200,9 +198,9 @@ void PersonalDataManager::OnStateChanged() {
if (!profile_ || profile_->IsOffTheRecord())
return;
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get()) {
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service) {
NOTREACHED();
return;
}
@@ -228,12 +226,12 @@ void PersonalDataManager::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(type, chrome::NOTIFICATION_AUTOFILL_MULTIPLE_CHANGED);
- scoped_refptr<WebDataService> web_data_service =
+ WebDataService* web_data_service =
content::Source<WebDataService>(source).ptr();
- DCHECK(web_data_service.get() &&
- web_data_service.get() == WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS).get());
+ DCHECK(web_data_service &&
+ web_data_service ==
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS));
Refresh();
}
@@ -366,9 +364,8 @@ void PersonalDataManager::AddProfile(const AutofillProfile& profile) {
if (FindByGUID<AutofillProfile>(web_profiles_, profile.guid()))
return;
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Don't add a duplicate.
@@ -394,9 +391,8 @@ void PersonalDataManager::UpdateProfile(const AutofillProfile& profile) {
return;
}
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Make the update.
@@ -413,9 +409,8 @@ void PersonalDataManager::RemoveProfile(const std::string& guid) {
if (!FindByGUID<AutofillProfile>(web_profiles_, guid))
return;
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Remove the profile.
@@ -445,9 +440,8 @@ void PersonalDataManager::AddCreditCard(const CreditCard& credit_card) {
if (FindByGUID<CreditCard>(credit_cards_, credit_card.guid()))
return;
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Don't add a duplicate.
@@ -473,9 +467,8 @@ void PersonalDataManager::UpdateCreditCard(const CreditCard& credit_card) {
return;
}
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Make the update.
@@ -492,9 +485,8 @@ void PersonalDataManager::RemoveCreditCard(const std::string& guid) {
if (!FindByGUID<CreditCard>(credit_cards_, guid))
return;
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Remove the credit card.
@@ -580,9 +572,9 @@ void PersonalDataManager::Init(Profile* profile) {
metric_logger_->LogIsAutofillEnabledAtStartup(IsAutofillEnabled());
// WebDataService may not be available in tests.
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get())
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service)
return;
LoadProfiles();
@@ -675,9 +667,8 @@ void PersonalDataManager::SetProfiles(std::vector<AutofillProfile>* profiles) {
address_of<AutofillProfile>);
AutofillProfile::AdjustInferredLabels(&profile_pointers);
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Any profiles that are not in the new profile list should be removed from
@@ -727,9 +718,8 @@ void PersonalDataManager::SetCreditCards(
std::mem_fun_ref(&CreditCard::IsEmpty)),
credit_cards->end());
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS);
- if (!wds.get())
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!wds)
return;
// Any credit cards that are not in the new credit card list should be
@@ -767,9 +757,9 @@ void PersonalDataManager::SetCreditCards(
}
void PersonalDataManager::LoadProfiles() {
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get()) {
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service) {
NOTREACHED();
return;
}
@@ -787,9 +777,9 @@ void PersonalDataManager::LoadAuxiliaryProfiles() const {
#endif
void PersonalDataManager::LoadCreditCards() {
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get()) {
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service) {
NOTREACHED();
return;
}
@@ -838,10 +828,9 @@ void PersonalDataManager::ReceiveLoadedCreditCards(
void PersonalDataManager::CancelPendingQuery(WebDataService::Handle* handle) {
if (*handle) {
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_,
- Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get()) {
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service) {
NOTREACHED();
return;
}
@@ -909,9 +898,9 @@ void PersonalDataManager::EmptyMigrationTrash() {
if (!profile_ || profile_->IsOffTheRecord())
return;
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
- if (!web_data_service.get()) {
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ if (!web_data_service) {
NOTREACHED();
return;
}
diff --git a/chrome/browser/autofill/personal_data_manager_factory.cc b/chrome/browser/autofill/personal_data_manager_factory.cc
index 5d13138..6ea4ded 100644
--- a/chrome/browser/autofill/personal_data_manager_factory.cc
+++ b/chrome/browser/autofill/personal_data_manager_factory.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
// static
PersonalDataManager* PersonalDataManagerFactory::GetForProfile(
@@ -25,7 +24,8 @@ PersonalDataManagerFactory* PersonalDataManagerFactory::GetInstance() {
PersonalDataManagerFactory::PersonalDataManagerFactory()
: ProfileKeyedServiceFactory("PersonalDataManager",
ProfileDependencyManager::GetInstance()) {
- DependsOn(WebDataServiceFactory::GetInstance());
+ // TODO(erg): For Shutdown() order, we need to:
+ // DependsOn(WebDataServiceFactory::GetInstance());
}
PersonalDataManagerFactory::~PersonalDataManagerFactory() {
diff --git a/chrome/browser/autofill/personal_data_manager_unittest.cc b/chrome/browser/autofill/personal_data_manager_unittest.cc
index be512d0..0daccb7 100644
--- a/chrome/browser/autofill/personal_data_manager_unittest.cc
+++ b/chrome/browser/autofill/personal_data_manager_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/autofill/personal_data_manager.h"
#include "chrome/browser/autofill/personal_data_manager_observer.h"
#include "chrome/browser/password_manager/encryptor.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/guid.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile.h"
@@ -55,7 +54,7 @@ class PersonalDataManagerTest : public testing::Test {
db_thread_.Start();
profile_.reset(new TestingProfile);
- profile_->CreateWebDataService();
+ profile_->CreateWebDataService(false);
autofill_test::DisableSystemServices(profile_.get());
ResetPersonalDataManager();
@@ -439,9 +438,8 @@ TEST_F(PersonalDataManagerTest, Refresh) {
profile_pointers.push_back(&profile2);
AutofillProfile::AdjustInferredLabels(&profile_pointers);
- scoped_refptr<WebDataService> wds = WebDataServiceFactory::GetForProfile(
- profile_.get(), Profile::EXPLICIT_ACCESS);
- ASSERT_TRUE(wds.get());
+ WebDataService* wds = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
+ ASSERT_TRUE(wds);
wds->AddAutofillProfile(profile2);
personal_data_->Refresh();
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 16685e4..93dc0f4 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -127,6 +127,7 @@ class BrowserProcessImpl : public BrowserProcess,
#endif
void CreateTemplateURLService();
void CreateProfileManager();
+ void CreateWebDataService();
void CreateLocalState();
void CreateViewedPageTracker();
void CreateIconManager();
diff --git a/chrome/browser/browsing_data_remover.cc b/chrome/browser/browsing_data_remover.cc
index 0772e9f..60c0863 100644
--- a/chrome/browser/browsing_data_remover.cc
+++ b/chrome/browser/browsing_data_remover.cc
@@ -40,7 +40,6 @@
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -344,11 +343,10 @@ void BrowsingDataRemover::RemoveImpl(int remove_mask,
if (remove_mask & REMOVE_FORM_DATA) {
content::RecordAction(UserMetricsAction("ClearBrowsingData_Autofill"));
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfile(profile_,
- Profile::EXPLICIT_ACCESS);
+ WebDataService* web_data_service =
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
- if (web_data_service.get()) {
+ if (web_data_service) {
web_data_service->RemoveFormElementsAddedBetween(delete_begin_,
delete_end_);
web_data_service->RemoveAutofillProfilesAndCreditCardsModifiedBetween(
diff --git a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
index dcfa45f..6407243 100644
--- a/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
+++ b/chrome/browser/extensions/app_notify_channel_setup_unittest.cc
@@ -7,7 +7,6 @@
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/message_loop.h"
-#include "base/synchronization/waitable_event.h"
#include "chrome/browser/extensions/app_notify_channel_setup.h"
#include "chrome/browser/extensions/app_notify_channel_ui.h"
#include "chrome/browser/signin/token_service_factory.h"
@@ -173,7 +172,6 @@ class TestUI : public AppNotifyChannelUI {
class AppNotifyChannelSetupTest : public testing::Test {
public:
AppNotifyChannelSetupTest() : ui_thread_(BrowserThread::UI, &message_loop_),
- db_thread_(BrowserThread::DB),
ui_(new TestUI()) {
}
@@ -235,24 +233,9 @@ class AppNotifyChannelSetupTest : public testing::Test {
delegate_.ExpectWasCalled(expected_code, expected_error);
}
- virtual void SetUp() OVERRIDE {
- db_thread_.Start();
- }
-
- virtual void TearDown() OVERRIDE {
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
- db_thread_.Stop();
- }
-
protected:
MessageLoop message_loop_;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
TestProfile profile_;
TestDelegate delegate_;
scoped_ptr<TestUI> ui_;
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index 07a6257..9bbbee4 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/hash_tables.h"
#include "base/memory/scoped_vector.h"
-#include "base/synchronization/waitable_event.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h"
@@ -141,7 +140,6 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness {
virtual void TearDown() OVERRIDE;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
// A map between renderer child id and a pair represending the bridge id and
// whether the requested permission was allowed.
@@ -150,8 +148,7 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness {
GeolocationPermissionContextTests::GeolocationPermissionContextTests()
: TabContentsWrapperTestHarness(),
- ui_thread_(BrowserThread::UI, MessageLoop::current()),
- db_thread_(BrowserThread::DB) {
+ ui_thread_(BrowserThread::UI, MessageLoop::current()) {
}
GeolocationPermissionContextTests::~GeolocationPermissionContextTests() {
@@ -231,7 +228,6 @@ void GeolocationPermissionContextTests::CheckTabContentsState(
}
void GeolocationPermissionContextTests::SetUp() {
- db_thread_.Start();
TabContentsWrapperTestHarness::SetUp();
geolocation_permission_context_ =
new ChromeGeolocationPermissionContext(profile());
@@ -240,13 +236,6 @@ void GeolocationPermissionContextTests::SetUp() {
void GeolocationPermissionContextTests::TearDown() {
extra_tabs_.reset();
TabContentsWrapperTestHarness::TearDown();
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
- db_thread_.Stop();
}
diff --git a/chrome/browser/importer/profile_writer.cc b/chrome/browser/importer/profile_writer.cc
index eb3b659..8519432 100644
--- a/chrome/browser/importer/profile_writer.cc
+++ b/chrome/browser/importer/profile_writer.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
@@ -95,8 +94,7 @@ void ProfileWriter::AddPasswordForm(const webkit::forms::PasswordForm& form) {
#if defined(OS_WIN)
void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) {
- WebDataServiceFactory::GetForProfile(
- profile_, Profile::EXPLICIT_ACCESS)->AddIE7Login(info);
+ profile_->GetWebDataService(Profile::EXPLICIT_ACCESS)->AddIE7Login(info);
}
#endif
diff --git a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
index 41986ca..559a09e 100644
--- a/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
+++ b/chrome/browser/intents/register_intent_handler_infobar_delegate_unittest.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/synchronization/waitable_event.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
#include "chrome/browser/intents/web_intents_registry.h"
@@ -39,14 +38,12 @@ class RegisterIntentHandlerInfoBarDelegateTest
: public TabContentsWrapperTestHarness {
protected:
RegisterIntentHandlerInfoBarDelegateTest()
- : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()),
- db_thread_(BrowserThread::DB) {}
+ : ui_thread_(BrowserThread::UI, MessageLoopForUI::current()) {}
virtual void SetUp() {
- db_thread_.Start();
TabContentsWrapperTestHarness::SetUp();
- profile()->CreateWebDataService();
+ profile()->CreateWebDataService(false);
web_intents_registry_ = BuildForProfile(profile());
}
@@ -54,20 +51,12 @@ class RegisterIntentHandlerInfoBarDelegateTest
web_intents_registry_ = NULL;
TabContentsWrapperTestHarness::TearDown();
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
- db_thread_.Stop();
}
MockWebIntentsRegistry* web_intents_registry_;
private:
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
DISALLOW_COPY_AND_ASSIGN(RegisterIntentHandlerInfoBarDelegateTest);
};
diff --git a/chrome/browser/intents/web_intents_registry_factory.cc b/chrome/browser/intents/web_intents_registry_factory.cc
index 7bbbdb4..f6e75c9 100644
--- a/chrome/browser/intents/web_intents_registry_factory.cc
+++ b/chrome/browser/intents/web_intents_registry_factory.cc
@@ -9,7 +9,6 @@
#include "chrome/browser/intents/web_intents_registry.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
// static
WebIntentsRegistry* WebIntentsRegistryFactory::GetForProfile(Profile* profile) {
@@ -20,7 +19,8 @@ WebIntentsRegistry* WebIntentsRegistryFactory::GetForProfile(Profile* profile) {
WebIntentsRegistryFactory::WebIntentsRegistryFactory()
: ProfileKeyedServiceFactory("WebIntentsRegistry",
ProfileDependencyManager::GetInstance()) {
- DependsOn(WebDataServiceFactory::GetInstance());
+ // TODO(erg): For Shutdown() order, we need to:
+ // DependsOn(WebDataServiceFactory::GetInstance());
DependsOn(ExtensionSystemFactory::GetInstance());
}
@@ -35,8 +35,7 @@ WebIntentsRegistryFactory* WebIntentsRegistryFactory::GetInstance() {
ProfileKeyedService* WebIntentsRegistryFactory::BuildServiceInstanceFor(
Profile* profile) const {
WebIntentsRegistry* registry = new WebIntentsRegistry;
- registry->Initialize(WebDataServiceFactory::GetForProfile(
- profile, Profile::EXPLICIT_ACCESS),
+ registry->Initialize(profile->GetWebDataService(Profile::EXPLICIT_ACCESS),
profile->GetExtensionService());
return registry;
}
diff --git a/chrome/browser/intents/web_intents_registry_unittest.cc b/chrome/browser/intents/web_intents_registry_unittest.cc
index fb4eaf5..0554029 100644
--- a/chrome/browser/intents/web_intents_registry_unittest.cc
+++ b/chrome/browser/intents/web_intents_registry_unittest.cc
@@ -8,7 +8,6 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
-#include "base/synchronization/waitable_event.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/test_extension_service.h"
#include "chrome/browser/intents/default_web_intent_service.h"
@@ -103,16 +102,9 @@ class WebIntentsRegistryTest : public testing::Test {
}
virtual void TearDown() {
- // Clear all references to wds to force it destruction.
- wds_->ShutdownOnUIThread();
- wds_ = NULL;
-
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
+ if (wds_.get())
+ wds_->Shutdown();
+
db_thread_.Stop();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
diff --git a/chrome/browser/memory_purger.cc b/chrome/browser/memory_purger.cc
index d00ee17..21cf2e9 100644
--- a/chrome/browser/memory_purger.cc
+++ b/chrome/browser/memory_purger.cc
@@ -15,7 +15,6 @@
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/render_messages.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host.h"
@@ -115,10 +114,9 @@ void MemoryPurger::PurgeBrowser() {
history_service->UnloadBackend();
// Unload all web databases (freeing memory used to cache sqlite).
- scoped_refptr<WebDataService> web_data_service =
- WebDataServiceFactory::GetForProfileIfExists(
- profiles[i], Profile::EXPLICIT_ACCESS);
- if (web_data_service.get())
+ WebDataService* web_data_service =
+ profiles[i]->GetWebDataServiceWithoutCreating();
+ if (web_data_service)
web_data_service->UnloadDatabase();
BrowserContext::PurgeMemory(profiles[i]);
diff --git a/chrome/browser/password_manager/password_store_factory.cc b/chrome/browser/password_manager/password_store_factory.cc
index 57a135c..3878b63 100644
--- a/chrome/browser/password_manager/password_store_factory.cc
+++ b/chrome/browser/password_manager/password_store_factory.cc
@@ -11,8 +11,6 @@
#include "chrome/browser/password_manager/password_store_default.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
@@ -65,7 +63,10 @@ PasswordStoreFactory::PasswordStoreFactory()
: RefcountedProfileKeyedServiceFactory(
"PasswordStore",
ProfileDependencyManager::GetInstance()) {
- DependsOn(WebDataServiceFactory::GetInstance());
+ // TODO(erg): We must always depend on WebDB; we don't want the dependency
+ // graph to be different based on platform.
+ //
+ // DependsOn(WebDataServiceFactory::GetInstance());
}
PasswordStoreFactory::~PasswordStoreFactory() {}
@@ -107,7 +108,7 @@ PasswordStoreFactory::BuildServiceInstanceFor(Profile* profile) const {
#if defined(OS_WIN)
ps = new PasswordStoreWin(
login_db, profile,
- WebDataServiceFactory::GetForProfile(profile, Profile::IMPLICIT_ACCESS));
+ profile->GetWebDataService(Profile::IMPLICIT_ACCESS));
#elif defined(OS_MACOSX)
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseMockKeychain)) {
ps = new PasswordStoreMac(new crypto::MockKeychain(), login_db);
diff --git a/chrome/browser/password_manager/password_store_win_unittest.cc b/chrome/browser/password_manager/password_store_win_unittest.cc
index ddcfa60..0d03e20 100644
--- a/chrome/browser/password_manager/password_store_win_unittest.cc
+++ b/chrome/browser/password_manager/password_store_win_unittest.cc
@@ -120,12 +120,8 @@ class PasswordStoreWinTest : public testing::Test {
virtual void TearDown() {
if (store_.get())
store_->ShutdownOnUIThread();
- wds_->ShutdownOnUIThread();
- wds_ = NULL;
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
+ if (wds_.get())
+ wds_->Shutdown();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
db_thread_.Stop();
@@ -254,6 +250,7 @@ TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) {
// Release the PSW and the WDS before the query can return.
store_->ShutdownOnUIThread();
store_ = NULL;
+ wds_->Shutdown();
wds_ = NULL;
MessageLoop::current()->RunAllPending();
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc
index 533c192..04550c7 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.cc
+++ b/chrome/browser/profiles/off_the_record_profile_impl.cc
@@ -246,6 +246,19 @@ history::ShortcutsBackend* OffTheRecordProfileImpl::GetShortcutsBackend() {
return NULL;
}
+WebDataService* OffTheRecordProfileImpl::GetWebDataService(
+ ServiceAccessType sat) {
+ if (sat == EXPLICIT_ACCESS)
+ return profile_->GetWebDataService(sat);
+
+ NOTREACHED() << "This profile is OffTheRecord";
+ return NULL;
+}
+
+WebDataService* OffTheRecordProfileImpl::GetWebDataServiceWithoutCreating() {
+ return profile_->GetWebDataServiceWithoutCreating();
+}
+
PrefService* OffTheRecordProfileImpl::GetPrefs() {
return prefs_;
}
diff --git a/chrome/browser/profiles/off_the_record_profile_impl.h b/chrome/browser/profiles/off_the_record_profile_impl.h
index 9fd2f1e..a0193ca 100644
--- a/chrome/browser/profiles/off_the_record_profile_impl.h
+++ b/chrome/browser/profiles/off_the_record_profile_impl.h
@@ -52,6 +52,8 @@ class OffTheRecordProfileImpl : public Profile,
virtual FaviconService* GetFaviconService(ServiceAccessType sat) OVERRIDE;
virtual AutocompleteClassifier* GetAutocompleteClassifier() OVERRIDE;
virtual history::ShortcutsBackend* GetShortcutsBackend() OVERRIDE;
+ virtual WebDataService* GetWebDataService(ServiceAccessType sat) OVERRIDE;
+ virtual WebDataService* GetWebDataServiceWithoutCreating() OVERRIDE;
virtual PrefService* GetPrefs() OVERRIDE;
virtual PrefService* GetOffTheRecordPrefs() OVERRIDE;
virtual net::URLRequestContextGetter*
diff --git a/chrome/browser/profiles/profile.h b/chrome/browser/profiles/profile.h
index a08a48b..e20f4f2 100644
--- a/chrome/browser/profiles/profile.h
+++ b/chrome/browser/profiles/profile.h
@@ -262,6 +262,17 @@ class Profile : public content::BrowserContext {
// this profile need to be sure they refcount the returned value.
virtual history::ShortcutsBackend* GetShortcutsBackend() = 0;
+ // Returns the WebDataService for this profile. This is owned by
+ // the Profile. Callers that outlive the life of this profile need to be
+ // sure they refcount the returned value.
+ //
+ // |access| defines what the caller plans to do with the service. See
+ // the ServiceAccessType definition above.
+ virtual WebDataService* GetWebDataService(ServiceAccessType access) = 0;
+
+ // Similar to GetWebDataService(), but won't create the web data service if it
+ // doesn't already exist.
+ virtual WebDataService* GetWebDataServiceWithoutCreating() = 0;
// Retrieves a pointer to the PrefService that manages the preferences
// for this user profile. The PrefService is lazily created the first
diff --git a/chrome/browser/profiles/profile_dependency_manager.cc b/chrome/browser/profiles/profile_dependency_manager.cc
index 9f55e94..27b0da1 100644
--- a/chrome/browser/profiles/profile_dependency_manager.cc
+++ b/chrome/browser/profiles/profile_dependency_manager.cc
@@ -43,10 +43,11 @@
#include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
#include "chrome/browser/user_style_sheet_watcher_factory.h"
+
#if defined(USE_AURA)
#include "chrome/browser/ui/gesture_prefs_observer_factory_aura.h"
#endif
-#include "chrome/browser/webdata/web_data_service_factory.h"
+
#ifndef NDEBUG
#include "base/command_line.h"
#include "base/file_util.h"
@@ -228,7 +229,6 @@ void ProfileDependencyManager::AssertFactoriesBuilt() {
#if defined(ENABLE_WEB_INTENTS)
WebIntentsRegistryFactory::GetInstance();
#endif
- WebDataServiceFactory::GetInstance();
built_factories_ = true;
}
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 9585dd0..143c96d 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -226,6 +226,7 @@ ProfileImpl::ProfileImpl(const FilePath& path,
host_content_settings_map_(NULL),
history_service_created_(false),
favicon_service_created_(false),
+ created_web_data_service_(false),
clear_local_state_on_exit_(false),
start_time_(Time::Now()),
delegate_(delegate),
@@ -509,12 +510,14 @@ ProfileImpl::~ProfileImpl() {
ProfileDependencyManager::GetInstance()->DestroyProfileServices(this);
- // The HistoryService maintains threads for background processing. Its
- // possible each thread still has tasks on it that have increased the ref
- // count of the service. In such a situation, when we decrement the refcount,
- // it won't be 0, and the threads/databases aren't properly shut down. By
- // explicitly calling Cleanup/Shutdown we ensure the databases are properly
- // closed.
+ // Both HistoryService and WebDataService maintain threads for background
+ // processing. Its possible each thread still has tasks on it that have
+ // increased the ref count of the service. In such a situation, when we
+ // decrement the refcount, it won't be 0, and the threads/databases aren't
+ // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
+ // databases are properly closed.
+ if (web_data_service_.get())
+ web_data_service_->Shutdown();
if (top_sites_.get())
top_sites_->Shutdown();
@@ -829,6 +832,25 @@ history::ShortcutsBackend* ProfileImpl::GetShortcutsBackend() {
return shortcuts_backend_.get();
}
+WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) {
+ if (!created_web_data_service_)
+ CreateWebDataService();
+ return web_data_service_.get();
+}
+
+WebDataService* ProfileImpl::GetWebDataServiceWithoutCreating() {
+ return web_data_service_.get();
+}
+
+void ProfileImpl::CreateWebDataService() {
+ DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL);
+ created_web_data_service_ = true;
+ scoped_refptr<WebDataService> wds(new WebDataService());
+ if (!wds->Init(GetPath()))
+ return;
+ web_data_service_.swap(wds);
+}
+
DownloadManager* ProfileImpl::GetDownloadManager() {
return DownloadServiceFactory::GetForProfile(this)->GetDownloadManager();
}
diff --git a/chrome/browser/profiles/profile_impl.h b/chrome/browser/profiles/profile_impl.h
index 8662ea0..a9f51b2 100644
--- a/chrome/browser/profiles/profile_impl.h
+++ b/chrome/browser/profiles/profile_impl.h
@@ -89,6 +89,8 @@ class ProfileImpl : public Profile,
virtual HistoryService* GetHistoryServiceWithoutCreating() OVERRIDE;
virtual AutocompleteClassifier* GetAutocompleteClassifier() OVERRIDE;
virtual history::ShortcutsBackend* GetShortcutsBackend() OVERRIDE;
+ virtual WebDataService* GetWebDataService(ServiceAccessType sat) OVERRIDE;
+ virtual WebDataService* GetWebDataServiceWithoutCreating() OVERRIDE;
virtual PrefService* GetPrefs() OVERRIDE;
virtual PrefService* GetOffTheRecordPrefs() OVERRIDE;
virtual net::URLRequestContextGetter*
@@ -153,6 +155,7 @@ class ProfileImpl : public Profile,
// Does final prefs initialization and calls Init().
void OnPrefsLoaded(bool success);
+ void CreateWebDataService();
FilePath GetPrefFilePath();
#if defined(ENABLE_SESSION_SERVICE)
@@ -222,8 +225,10 @@ class ProfileImpl : public Profile,
scoped_ptr<FaviconService> favicon_service_;
scoped_ptr<AutocompleteClassifier> autocomplete_classifier_;
scoped_refptr<history::ShortcutsBackend> shortcuts_backend_;
+ scoped_refptr<WebDataService> web_data_service_;
bool history_service_created_;
bool favicon_service_created_;
+ bool created_web_data_service_;
bool clear_local_state_on_exit_;
// Whether or not the last session exited cleanly. This is set only once.
diff --git a/chrome/browser/search_engines/search_provider_install_data.cc b/chrome/browser/search_engines/search_provider_install_data.cc
index 7a0b0aa..c50ad08 100644
--- a/chrome/browser/search_engines/search_provider_install_data.cc
+++ b/chrome/browser/search_engines/search_provider_install_data.cc
@@ -20,7 +20,6 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/util.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h"
@@ -159,8 +158,7 @@ SearchProviderInstallData::SearchProviderInstallData(
Profile* profile,
int ui_death_notification,
const content::NotificationSource& ui_death_source)
- : web_service_(WebDataServiceFactory::GetForProfile(profile,
- Profile::EXPLICIT_ACCESS)),
+ : web_service_(profile->GetWebDataService(Profile::EXPLICIT_ACCESS)),
load_handle_(0),
google_base_url_(UIThreadSearchTermsData(profile).GoogleBaseURLValue()) {
// GoogleURLObserver is responsible for killing itself when
diff --git a/chrome/browser/search_engines/template_url_service.cc b/chrome/browser/search_engines/template_url_service.cc
index 688e681..530c6d8 100644
--- a/chrome/browser/search_engines/template_url_service.cc
+++ b/chrome/browser/search_engines/template_url_service.cc
@@ -35,7 +35,6 @@
#include "chrome/browser/search_engines/util.h"
#include "chrome/browser/sync/api/sync_change.h"
#include "chrome/browser/sync/api/sync_error_factory.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
@@ -556,10 +555,8 @@ void TemplateURLService::Load() {
if (loaded_ || load_handle_)
return;
- if (!service_.get()) {
- service_ = WebDataServiceFactory::GetForProfile(profile_,
- Profile::EXPLICIT_ACCESS);
- }
+ if (!service_.get())
+ service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
if (service_.get()) {
load_handle_ = service_->GetKeywords(this);
@@ -899,9 +896,9 @@ SyncError TemplateURLService::ProcessSyncChanges(
// . Trying to ADD a search engine that already exists.
NOTREACHED() << "Unexpected sync change state.";
error = sync_error_factory_->CreateAndUploadError(
- FROM_HERE,
- "ProcessSyncChanges failed on ChangeType " +
- SyncChange::ChangeTypeToString(iter->change_type()));
+ FROM_HERE,
+ "ProcessSyncChanges failed on ChangeType " +
+ SyncChange::ChangeTypeToString(iter->change_type()));
}
}
PreventDuplicateGUIDUpdates(&new_changes);
diff --git a/chrome/browser/search_engines/template_url_service_factory.cc b/chrome/browser/search_engines/template_url_service_factory.cc
index b4c533f..5292074 100644
--- a/chrome/browser/search_engines/template_url_service_factory.cc
+++ b/chrome/browser/search_engines/template_url_service_factory.cc
@@ -8,7 +8,6 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/search_engines/template_url_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/pref_names.h"
TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) {
@@ -24,8 +23,8 @@ TemplateURLServiceFactory::TemplateURLServiceFactory()
: ProfileKeyedServiceFactory("TemplateURLServiceFactory",
ProfileDependencyManager::GetInstance()) {
DependsOn(GoogleURLTrackerFactory::GetInstance());
- DependsOn(WebDataServiceFactory::GetInstance());
// TODO(erg): For Shutdown() order, we need to:
+ // DependsOn(WebDataServiceFactory::GetInstance());
// DependsOn(HistoryService::GetInstance());
// DependsOn(ExtensionService::GetInstance());
}
diff --git a/chrome/browser/search_engines/template_url_service_test_util.cc b/chrome/browser/search_engines/template_url_service_test_util.cc
index f562c25..881300c 100644
--- a/chrome/browser/search_engines/template_url_service_test_util.cc
+++ b/chrome/browser/search_engines/template_url_service_test_util.cc
@@ -8,12 +8,10 @@
#include "base/message_loop.h"
#include "base/path_service.h"
#include "base/scoped_temp_dir.h"
-#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
#include "chrome/browser/search_engines/search_terms_data.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/testing_pref_service.h"
@@ -64,8 +62,9 @@ class TemplateURLServiceTestingProfile : public TestingProfile {
io_thread_.StartIOThread();
}
- static scoped_refptr<RefcountedProfileKeyedService>
- GetWebDataServiceForTemplateURLServiceTestingProfile(Profile* profile);
+ virtual WebDataService* GetWebDataService(ServiceAccessType access) {
+ return service_.get();
+ }
private:
scoped_refptr<WebDataService> service_;
@@ -74,7 +73,6 @@ class TemplateURLServiceTestingProfile : public TestingProfile {
content::TestBrowserThread io_thread_;
};
-
// Trivial subclass of TemplateURLService that records the last invocation of
// SetKeywordSearchTermsForURL.
class TestingTemplateURLService : public TemplateURLService {
@@ -130,31 +128,15 @@ void TemplateURLServiceTestingProfile::TearDown() {
io_thread_.Stop();
// Clean up the test directory.
- if (service_.get()) {
- service_->ShutdownOnUIThread();
- service_ = NULL;
- }
+ if (service_.get())
+ service_->Shutdown();
// Note that we must ensure the DB thread is stopped after WDS
// shutdown (so it can commit pending transactions) but before
// deleting the test profile directory, otherwise we may not be
// able to delete it due to an open transaction.
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
db_thread_.Stop();
}
-scoped_refptr<RefcountedProfileKeyedService>
-TemplateURLServiceTestingProfile::
- GetWebDataServiceForTemplateURLServiceTestingProfile(Profile* profile) {
- TemplateURLServiceTestingProfile* test_profile =
- reinterpret_cast<TemplateURLServiceTestingProfile*>(profile);
- return test_profile->service_;
-}
-
TemplateURLServiceTestUtil::TemplateURLServiceTestUtil()
: ui_thread_(BrowserThread::UI, &message_loop_),
changed_count_(0) {
@@ -165,10 +147,6 @@ TemplateURLServiceTestUtil::~TemplateURLServiceTestUtil() {
void TemplateURLServiceTestUtil::SetUp() {
profile_.reset(new TemplateURLServiceTestingProfile());
- WebDataServiceFactory::GetInstance()->SetTestingFactory(
- profile_.get(), TemplateURLServiceTestingProfile::
- GetWebDataServiceForTemplateURLServiceTestingProfile);
-
profile_->SetUp();
TemplateURLService* service = static_cast<TemplateURLService*>(
TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
@@ -219,8 +197,7 @@ void TemplateURLServiceTestUtil::ChangeModelToLoadState() {
model()->ChangeToLoadedState();
// Initialize the web data service so that the database gets updated with
// any changes made.
- model()->service_ = WebDataServiceFactory::GetForProfile(
- profile_.get(), Profile::EXPLICIT_ACCESS);
+ model()->service_ = profile_->GetWebDataService(Profile::EXPLICIT_ACCESS);
}
void TemplateURLServiceTestUtil::ClearModel() {
diff --git a/chrome/browser/search_engines/template_url_service_unittest.cc b/chrome/browser/search_engines/template_url_service_unittest.cc
index c37fc07..9bf29c6 100644
--- a/chrome/browser/search_engines/template_url_service_unittest.cc
+++ b/chrome/browser/search_engines/template_url_service_unittest.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_test_util.h"
#include "chrome/browser/webdata/web_database.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/testing_profile.h"
#include "content/test/test_browser_thread.h"
@@ -1257,9 +1256,8 @@ TEST_F(TemplateURLServiceTest, FailedInit) {
test_util_.VerifyLoad();
test_util_.ClearModel();
- scoped_refptr<WebDataService> web_service =
- WebDataServiceFactory::GetForProfile(test_util_.profile(),
- Profile::EXPLICIT_ACCESS);
+ WebDataService* web_service =
+ test_util_.profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
web_service->UnloadDatabase();
web_service->set_failed_init(true);
diff --git a/chrome/browser/signin/token_service.cc b/chrome/browser/signin/token_service.cc
index 39a1a7a..c52e42c 100644
--- a/chrome/browser/signin/token_service.cc
+++ b/chrome/browser/signin/token_service.cc
@@ -9,7 +9,6 @@
#include "base/string_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/gaia_auth_fetcher.h"
@@ -65,8 +64,7 @@ void TokenService::Initialize(const char* const source,
getter_ = profile->GetRequestContext();
// Since the user can create a bookmark in incognito, sync may be running.
// Thus we have to go for explicit access.
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- profile, Profile::EXPLICIT_ACCESS);
+ web_data_service_ = profile->GetWebDataService(Profile::EXPLICIT_ACCESS);
source_ = std::string(source);
CommandLine* cmd_line = CommandLine::ForCurrentProcess();
diff --git a/chrome/browser/signin/token_service_factory.cc b/chrome/browser/signin/token_service_factory.cc
index bbf4b86..54d6581 100644
--- a/chrome/browser/signin/token_service_factory.cc
+++ b/chrome/browser/signin/token_service_factory.cc
@@ -6,12 +6,13 @@
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/signin/token_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
TokenServiceFactory::TokenServiceFactory()
: ProfileKeyedServiceFactory("TokenService",
ProfileDependencyManager::GetInstance()) {
- DependsOn(WebDataServiceFactory::GetInstance());
+ // TODO(rlp): TokenService depends on WebDataService - when this is
+ // converted to the ProfileKeyedService framework, uncomment this dependency.
+ // DependsOn(WebDataServiceFactory::GetInstance());
}
TokenServiceFactory::~TokenServiceFactory() {}
diff --git a/chrome/browser/signin/token_service_unittest.cc b/chrome/browser/signin/token_service_unittest.cc
index 763233f..c8c2882 100644
--- a/chrome/browser/signin/token_service_unittest.cc
+++ b/chrome/browser/signin/token_service_unittest.cc
@@ -13,7 +13,6 @@
#include "base/synchronization/waitable_event.h"
#include "chrome/browser/password_manager/encryptor.h"
#include "chrome/browser/signin/token_service_factory.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/net/gaia/mock_url_fetcher_factory.h"
@@ -73,8 +72,7 @@ void TokenServiceTestHarness::SetUp() {
ASSERT_TRUE(db_thread_.Start());
profile_.reset(new TestingProfile());
- profile_->CreateWebDataService();
-
+ profile_->CreateWebDataService(false);
WaitForDBLoadCompletion();
service_ = TokenServiceFactory::GetForProfile(profile_.get());
@@ -91,12 +89,6 @@ void TokenServiceTestHarness::TearDown() {
if (profile_.get()) {
profile_.reset(NULL);
}
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
db_thread_.Stop();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
@@ -104,10 +96,6 @@ void TokenServiceTestHarness::TearDown() {
}
void TokenServiceTestHarness::WaitForDBLoadCompletion() {
- // Force the loading of the WebDataService.
- WebDataServiceFactory::GetForProfile(profile_.get(),
- Profile::IMPLICIT_ACCESS);
-
// The WebDB does all work on the DB thread. This will add an event
// to the end of the DB thread, so when we reach this task, all DB
// operations should be complete.
diff --git a/chrome/browser/signin/ubertoken_fetcher_unittest.cc b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
index 27de717..b1b04e0 100644
--- a/chrome/browser/signin/ubertoken_fetcher_unittest.cc
+++ b/chrome/browser/signin/ubertoken_fetcher_unittest.cc
@@ -11,8 +11,6 @@
#include "content/test/test_url_fetcher_factory.h"
#include "testing/gtest/include/gtest/gtest.h"
-using content::BrowserThread;
-
class MockUbertokenConsumer : public UbertokenConsumer {
public:
MockUbertokenConsumer()
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller.cc b/chrome/browser/sync/glue/autofill_data_type_controller.cc
index ac24c0e..b614b09 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller.cc
@@ -10,7 +10,6 @@
#include "chrome/browser/sync/api/sync_error.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_source.h"
@@ -66,8 +65,7 @@ bool AutofillDataTypeController::StartModels() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(MODEL_STARTING, state());
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- profile(), Profile::IMPLICIT_ACCESS);
+ web_data_service_ = profile()->GetWebDataService(Profile::IMPLICIT_ACCESS);
if (web_data_service_->IsDatabaseLoaded()) {
return true;
} else {
diff --git a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
index be9d27d..ba157ca 100644
--- a/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
+++ b/chrome/browser/sync/glue/autofill_data_type_controller_unittest.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/sync/profile_sync_components_factory_mock.h"
#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/profile_mock.h"
#include "content/public/browser/notification_service.h"
@@ -55,8 +54,6 @@ class FakeWebDataService : public WebDataService {
return is_database_loaded_;
}
- virtual void ShutdownOnUIThread() OVERRIDE {}
-
private:
virtual ~FakeWebDataService() {}
@@ -70,7 +67,6 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
SyncAutofillDataTypeControllerTest()
: weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
ui_thread_(BrowserThread::UI, &message_loop_),
- db_thread_(BrowserThread::DB),
last_start_result_(DataTypeController::OK) {}
virtual ~SyncAutofillDataTypeControllerTest() {}
@@ -85,8 +81,10 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
CreateSharedChangeProcessor()).
WillRepeatedly(Return(change_processor_.get()));
- WebDataServiceFactory::GetInstance()->SetTestingFactory(
- &profile_, BuildWebDataService);
+ web_data_service_ = new FakeWebDataService();
+
+ EXPECT_CALL(profile_, GetWebDataService(_)).
+ WillRepeatedly(Return(web_data_service_.get()));
autofill_dtc_ =
new AutofillDataTypeController(&profile_sync_factory_,
@@ -103,24 +101,20 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
virtual void TearDown() {
autofill_dtc_ = NULL;
+ web_data_service_ = NULL;
change_processor_ = NULL;
}
- static scoped_refptr<RefcountedProfileKeyedService>
- BuildWebDataService(Profile* profile) {
- return new FakeWebDataService();
- }
-
protected:
base::WeakPtrFactory<SyncAutofillDataTypeControllerTest> weak_ptr_factory_;
MessageLoopForUI message_loop_;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
scoped_refptr<NiceMock<SharedChangeProcessorMock> > change_processor_;
ProfileSyncComponentsFactoryMock profile_sync_factory_;
ProfileSyncServiceMock service_;
ProfileMock profile_;
+ scoped_refptr<FakeWebDataService> web_data_service_;
scoped_refptr<AutofillDataTypeController> autofill_dtc_;
// Stores arguments of most recent call of OnStartFinished().
@@ -132,10 +126,7 @@ class SyncAutofillDataTypeControllerTest : public testing::Test {
// immediately try to start association and fail (due to missing DB
// thread).
TEST_F(SyncAutofillDataTypeControllerTest, StartWDSReady) {
- FakeWebDataService* web_db =
- static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile(
- &profile_, Profile::EXPLICIT_ACCESS).get());
- web_db->LoadDatabase();
+ web_data_service_->LoadDatabase();
autofill_dtc_->Start(
base::Bind(&SyncAutofillDataTypeControllerTest::OnStartFinished,
weak_ptr_factory_.GetWeakPtr()));
@@ -158,10 +149,7 @@ TEST_F(SyncAutofillDataTypeControllerTest, StartWDSNotReady) {
EXPECT_FALSE(last_start_error_.IsSet());
EXPECT_EQ(DataTypeController::MODEL_STARTING, autofill_dtc_->state());
- FakeWebDataService* web_db =
- static_cast<FakeWebDataService*>(WebDataServiceFactory::GetForProfile(
- &profile_, Profile::EXPLICIT_ACCESS).get());
- web_db->LoadDatabase();
+ web_data_service_->LoadDatabase();
EXPECT_EQ(DataTypeController::ASSOCIATION_FAILED, last_start_result_);
EXPECT_TRUE(last_start_error_.IsSet());
diff --git a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
index 0c04694..4e891e4 100644
--- a/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
+++ b/chrome/browser/sync/glue/autofill_profile_data_type_controller.cc
@@ -14,7 +14,6 @@
#include "chrome/browser/sync/profile_sync_components_factory.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
@@ -55,8 +54,7 @@ void AutofillProfileDataTypeController::OnPersonalDataChanged() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
DCHECK_EQ(state(), MODEL_STARTING);
personal_data_->RemoveObserver(this);
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- profile(), Profile::IMPLICIT_ACCESS);
+ web_data_service_ = profile()->GetWebDataService(Profile::IMPLICIT_ACCESS);
if (web_data_service_.get() && web_data_service_->IsDatabaseLoaded()) {
DoStartAssociationAsync();
} else {
@@ -86,8 +84,7 @@ bool AutofillProfileDataTypeController::StartModels() {
return false;
}
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- profile(), Profile::IMPLICIT_ACCESS);
+ web_data_service_ = profile()->GetWebDataService(Profile::IMPLICIT_ACCESS);
if (web_data_service_.get() && web_data_service_->IsDatabaseLoaded()) {
return true;
} else {
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.cc b/chrome/browser/sync/profile_sync_components_factory_impl.cc
index f3f5e0d..e3e182df 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.cc
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.cc
@@ -47,7 +47,6 @@
#include "chrome/browser/webdata/autocomplete_syncable_service.h"
#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/browser_thread.h"
@@ -88,12 +87,7 @@ ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
: profile_(profile),
command_line_(command_line),
extension_system_(
- ExtensionSystemFactory::GetForProfile(profile)),
- web_data_service_(WebDataServiceFactory::GetForProfile(
- profile_, Profile::IMPLICIT_ACCESS)) {
-}
-
-ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
+ ExtensionSystem::Get(profile)) {
}
void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
@@ -233,14 +227,14 @@ base::WeakPtr<SyncableService> ProfileSyncComponentsFactoryImpl::
return profile_->GetPrefs()->GetSyncableService()->AsWeakPtr();
case syncable::AUTOFILL:
case syncable::AUTOFILL_PROFILE: {
- if (!web_data_service_.get())
+ WebDataService* wds =
+ profile_->GetWebDataService(Profile::IMPLICIT_ACCESS);
+ if (!wds)
return base::WeakPtr<SyncableService>();
- if (type == syncable::AUTOFILL) {
- return web_data_service_->GetAutocompleteSyncableService()->AsWeakPtr();
- } else {
- return web_data_service_->
- GetAutofillProfileSyncableService()->AsWeakPtr();
- }
+ if (type == syncable::AUTOFILL)
+ return wds->GetAutocompleteSyncableService()->AsWeakPtr();
+ else
+ return wds->GetAutofillProfileSyncableService()->AsWeakPtr();
}
case syncable::APPS:
case syncable::EXTENSIONS:
diff --git a/chrome/browser/sync/profile_sync_components_factory_impl.h b/chrome/browser/sync/profile_sync_components_factory_impl.h
index d5aa6a0..7e7ccf2 100644
--- a/chrome/browser/sync/profile_sync_components_factory_impl.h
+++ b/chrome/browser/sync/profile_sync_components_factory_impl.h
@@ -11,7 +11,6 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "chrome/browser/sync/profile_sync_components_factory.h"
-#include "chrome/browser/webdata/web_data_service.h"
class CommandLine;
class ExtensionSystem;
@@ -21,7 +20,7 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
public:
ProfileSyncComponentsFactoryImpl(Profile* profile,
CommandLine* command_line);
- virtual ~ProfileSyncComponentsFactoryImpl();
+ virtual ~ProfileSyncComponentsFactoryImpl() {}
virtual void RegisterDataTypes(ProfileSyncService* pss) OVERRIDE;
@@ -67,7 +66,6 @@ class ProfileSyncComponentsFactoryImpl : public ProfileSyncComponentsFactory {
// Set on the UI thread (since ExtensionSystemFactory is non-threadsafe);
// accessed on both the UI and FILE threads in GetSyncableServiceForType.
ExtensionSystem* extension_system_;
- scoped_refptr<WebDataService> web_data_service_;
DISALLOW_COPY_AND_ASSIGN(ProfileSyncComponentsFactoryImpl);
};
diff --git a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
index 2e42c17..ee33b8c 100644
--- a/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_autofill_unittest.cc
@@ -42,8 +42,6 @@
#include "chrome/browser/webdata/autofill_profile_syncable_service.h"
#include "chrome/browser/webdata/autofill_table.h"
#include "chrome/browser/webdata/web_database.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/net/gaia/gaia_constants.h"
#include "content/public/browser/notification_source.h"
@@ -162,19 +160,11 @@ syncable::ModelType GetModelType<AutofillProfile>() {
class WebDataServiceFake : public WebDataService {
public:
- WebDataServiceFake()
- : web_database_(NULL),
+ explicit WebDataServiceFake(WebDatabase* web_database)
+ : web_database_(web_database),
syncable_service_created_or_destroyed_(false, false) {
}
- static scoped_refptr<RefcountedProfileKeyedService> Build(Profile* profile) {
- return new WebDataServiceFake;
- }
-
- void SetDatabase(WebDatabase* web_database) {
- web_database_ = web_database;
- }
-
void StartSyncableService() {
// The |autofill_profile_syncable_service_| must be constructed on the DB
// thread.
@@ -229,8 +219,6 @@ class WebDataServiceFake : public WebDataService {
return autofill_profile_syncable_service_;
}
- virtual void ShutdownOnUIThread() OVERRIDE {}
-
private:
virtual ~WebDataServiceFake() {}
@@ -357,8 +345,6 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
protected:
ProfileSyncServiceAutofillTest() {
}
- virtual ~ProfileSyncServiceAutofillTest() {
- }
AutofillProfileFactory profile_factory_;
AutofillEntryFactory entry_factory_;
@@ -378,10 +364,7 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
AbstractProfileSyncServiceTest::SetUp();
profile_.CreateRequestContext();
web_database_.reset(new WebDatabaseFake(&autofill_table_));
- web_data_service_ = static_cast<WebDataServiceFake*>(
- WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- &profile_, WebDataServiceFake::Build).get());
- web_data_service_->SetDatabase(web_database_.get());
+ web_data_service_ = new WebDataServiceFake(web_database_.get());
personal_data_manager_ = static_cast<PersonalDataManagerMock*>(
PersonalDataManagerFactory::GetInstance()->SetTestingFactoryAndUse(
&profile_, PersonalDataManagerMock::Build));
@@ -394,7 +377,12 @@ class ProfileSyncServiceAutofillTest : public AbstractProfileSyncServiceTest {
WillRepeatedly(Return(static_cast<HistoryService*>(NULL)));
EXPECT_CALL(*personal_data_manager_, LoadProfiles()).Times(1);
EXPECT_CALL(*personal_data_manager_, LoadCreditCards()).Times(1);
-
+ EXPECT_CALL(profile_, GetWebDataService(_)).
+ // TokenService::Initialize
+ // AutofillDataTypeController::StartModels()
+ // In some tests:
+ // AutofillProfileSyncableService::AutofillProfileSyncableService()
+ WillRepeatedly(Return(web_data_service_.get()));
personal_data_manager_->Init(&profile_);
// Note: This must be called *after* the notification service is created.
diff --git a/chrome/browser/sync/profile_sync_service_factory.cc b/chrome/browser/sync/profile_sync_service_factory.cc
index 7ef2275..ddca10e 100644
--- a/chrome/browser/sync/profile_sync_service_factory.cc
+++ b/chrome/browser/sync/profile_sync_service_factory.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/global_error_service_factory.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/pref_names.h"
// static
@@ -55,13 +54,13 @@ ProfileSyncServiceFactory::ProfileSyncServiceFactory()
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(PasswordStoreFactory::GetInstance());
DependsOn(ExtensionSystemFactory::GetInstance());
- DependsOn(WebDataServiceFactory::GetInstance());
// The following have not been converted to ProfileKeyedServices yet, and for
// now they are explicitly destroyed after the ProfileDependencyManager is
// told to DestroyProfileServices, so they will be around when the
// ProfileSyncService is destroyed.
+ // DependsOn(WebDataServiceFactory::GetInstance());
// DependsOn(HistoryServiceFactory::GetInstance());
// DependsOn(BookmarkBarModelFactory::GetInstance());
// DependsOn(FaviconServiceFactory::GetInstance());
diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
index 2282a67..fdf0790 100644
--- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc
@@ -40,7 +40,6 @@ class ProfileSyncServiceStartupTest : public testing::Test {
public:
ProfileSyncServiceStartupTest()
: ui_thread_(BrowserThread::UI, &ui_loop_),
- db_thread_(BrowserThread::DB),
file_thread_(BrowserThread::FILE),
io_thread_(BrowserThread::IO),
profile_(new TestingProfile) {}
@@ -99,7 +98,6 @@ class ProfileSyncServiceStartupTest : public testing::Test {
MessageLoop ui_loop_;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThread io_thread_;
scoped_ptr<TestingProfile> profile_;
diff --git a/chrome/browser/sync/profile_sync_service_unittest.cc b/chrome/browser/sync/profile_sync_service_unittest.cc
index d5ed7a8..54bd7ac 100644
--- a/chrome/browser/sync/profile_sync_service_unittest.cc
+++ b/chrome/browser/sync/profile_sync_service_unittest.cc
@@ -47,7 +47,6 @@ class ProfileSyncServiceTest : public testing::Test {
protected:
ProfileSyncServiceTest()
: ui_thread_(BrowserThread::UI, &ui_loop_),
- db_thread_(BrowserThread::DB),
file_thread_(BrowserThread::FILE),
io_thread_(BrowserThread::IO) {}
@@ -145,7 +144,6 @@ class ProfileSyncServiceTest : public testing::Test {
MessageLoop ui_loop_;
// Needed by |service_|.
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
// Needed by DisableAndEnableSyncTemporarily test case.
content::TestBrowserThread file_thread_;
// Needed by |service| and |profile_|'s request context.
diff --git a/chrome/browser/sync/test/integration/autofill_helper.cc b/chrome/browser/sync/test/integration/autofill_helper.cc
index f9c7e31..7f2dd3b 100644
--- a/chrome/browser/sync/test/integration/autofill_helper.cc
+++ b/chrome/browser/sync/test/integration/autofill_helper.cc
@@ -17,7 +17,6 @@
#include "chrome/browser/sync/test/integration/sync_test.h"
#include "chrome/browser/webdata/autofill_entry.h"
#include "chrome/browser/webdata/autofill_table.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/browser/webdata/web_database.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/test/base/thread_observer_helper.h"
@@ -61,8 +60,7 @@ void RemoveKeyDontBlockForSync(int profile, const AutofillKey& key) {
EXPECT_CALL(*observer_helper->observer(), Observe(_, _, _)).
WillOnce(SignalEvent(&done_event));
- scoped_refptr<WebDataService> wds =
- autofill_helper::GetWebDataService(profile);
+ WebDataService* wds = autofill_helper::GetWebDataService(profile);
wds->RemoveFormValueForElementName(key.name(), key.value());
done_event.Wait();
}
@@ -148,9 +146,8 @@ AutofillProfile CreateAutofillProfile(ProfileType type) {
return profile;
}
-scoped_refptr<WebDataService> GetWebDataService(int index) {
- return WebDataServiceFactory::GetForProfile(
- test()->GetProfile(index), Profile::EXPLICIT_ACCESS);
+WebDataService* GetWebDataService(int index) {
+ return test()->GetProfile(index)->GetWebDataService(Profile::EXPLICIT_ACCESS);
}
PersonalDataManager* GetPersonalDataManager(int index) {
@@ -175,7 +172,7 @@ void AddKeys(int profile, const std::set<AutofillKey>& keys) {
EXPECT_CALL(*observer_helper->observer(), Observe(_, _, _)).
WillOnce(SignalEvent(&done_event));
- scoped_refptr<WebDataService> wds = GetWebDataService(profile);
+ WebDataService* wds = GetWebDataService(profile);
wds->AddFormFields(form_fields);
done_event.Wait();
BlockForPendingDBThreadTasks();
@@ -196,7 +193,7 @@ void RemoveKeys(int profile) {
}
std::set<AutofillEntry> GetAllKeys(int profile) {
- scoped_refptr<WebDataService> wds = GetWebDataService(profile);
+ WebDataService* wds = GetWebDataService(profile);
std::vector<AutofillEntry> all_entries = GetAllAutofillEntries(wds);
std::set<AutofillEntry> all_keys;
for (std::vector<AutofillEntry>::const_iterator it = all_entries.begin();
diff --git a/chrome/browser/sync/test/integration/autofill_helper.h b/chrome/browser/sync/test/integration/autofill_helper.h
index 1df0316..51950ef 100644
--- a/chrome/browser/sync/test/integration/autofill_helper.h
+++ b/chrome/browser/sync/test/integration/autofill_helper.h
@@ -11,7 +11,6 @@
#include <vector>
#include "base/compiler_specific.h"
-#include "base/memory/ref_counted.h"
#include "base/string16.h"
#include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
@@ -32,7 +31,7 @@ enum ProfileType {
};
// Used to access the web data service within a particular sync profile.
-scoped_refptr<WebDataService> GetWebDataService(int index) WARN_UNUSED_RESULT;
+WebDataService* GetWebDataService(int index) WARN_UNUSED_RESULT;
// Used to access the personal data manager within a particular sync profile.
PersonalDataManager* GetPersonalDataManager(int index) WARN_UNUSED_RESULT;
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
index df67227..12cf715 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc
@@ -21,7 +21,6 @@
#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
@@ -231,8 +230,8 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
fake_url_fetcher_factory_.reset(
new FakeURLFetcherFactory(default_url_fetcher_factory_.get()));
- web_data_service_ = WebDataServiceFactory::GetForProfile(
- GetBrowser()->profile(), Profile::EXPLICIT_ACCESS);
+ web_data_service_ =
+ GetBrowser()->profile()->GetWebDataService(Profile::EXPLICIT_ACCESS);
favicon_service_ =
GetBrowser()->profile()->GetFaviconService(Profile::EXPLICIT_ACCESS);
controller_ = GetBrowser()->
@@ -324,7 +323,7 @@ class WebIntentPickerControllerBrowserTest : public InProcessBrowserTest {
}
WebIntentPickerMock picker_;
- scoped_refptr<WebDataService> web_data_service_;
+ WebDataService* web_data_service_;
FaviconService* favicon_service_;
WebIntentPickerController* controller_;
scoped_ptr<DummyURLFetcherFactory> default_url_fetcher_factory_;
diff --git a/chrome/browser/ui/intents/web_intents_model_unittest.cc b/chrome/browser/ui/intents/web_intents_model_unittest.cc
index 05a84b4..7375727 100644
--- a/chrome/browser/ui/intents/web_intents_model_unittest.cc
+++ b/chrome/browser/ui/intents/web_intents_model_unittest.cc
@@ -34,12 +34,9 @@ class WebIntentsModelTest : public testing::Test {
}
virtual void TearDown() {
- wds_->ShutdownOnUIThread();
- wds_ = NULL;
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
+ if (wds_.get())
+ wds_->Shutdown();
+
db_thread_.Stop();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc
index ee99257..6cf2631 100644
--- a/chrome/browser/webdata/web_data_service.cc
+++ b/chrome/browser/webdata/web_data_service.cc
@@ -28,9 +28,6 @@
#include "chrome/browser/webdata/web_intents_table.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
-#ifdef DEBUG
-#include "content/public/browser/browser_thread.h"
-#endif
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
@@ -81,19 +78,14 @@ WDKeywordsResult::WDKeywordsResult()
WDKeywordsResult::~WDKeywordsResult() {}
WebDataService::WebDataService()
- : RefcountedProfileKeyedService(BrowserThread::UI),
- is_running_(false),
- db_(NULL),
- autocomplete_syncable_service_(NULL),
- autofill_profile_syncable_service_(NULL),
- failed_init_(false),
- should_commit_(false),
- next_request_handle_(1),
- main_loop_(MessageLoop::current()) {
- // WebDataService requires DB thread if instantiated.
- // Set WebDataServiceFactory::GetInstance()->SetTestingFactory(&profile, NULL)
- // if you do not want to instantiate WebDataService in your test.
- DCHECK(BrowserThread::IsWellKnownThread(BrowserThread::DB));
+ : is_running_(false),
+ db_(NULL),
+ autocomplete_syncable_service_(NULL),
+ autofill_profile_syncable_service_(NULL),
+ failed_init_(false),
+ should_commit_(false),
+ next_request_handle_(1),
+ main_loop_(MessageLoop::current()) {
}
// static
@@ -110,18 +102,18 @@ void WebDataService::NotifyOfMultipleAutofillChanges(
make_scoped_refptr(web_data_service)));
}
-void WebDataService::ShutdownOnUIThread() {
- ScheduleTask(FROM_HERE,
- Bind(&WebDataService::ShutdownSyncableServices, this));
- UnloadDatabase();
-}
-
bool WebDataService::Init(const FilePath& profile_path) {
FilePath path = profile_path;
path = path.Append(chrome::kWebDataFilename);
return InitWithPath(path);
}
+void WebDataService::Shutdown() {
+ ScheduleTask(FROM_HERE,
+ Bind(&WebDataService::ShutdownSyncableServices, this));
+ UnloadDatabase();
+}
+
bool WebDataService::IsRunning() const {
return is_running_;
}
@@ -562,7 +554,6 @@ void WebDataService::RemoveAutofillProfilesAndCreditCardsModifiedBetween(
WebDataService::~WebDataService() {
if (is_running_ && db_) {
DLOG_ASSERT("WebDataService dtor called without Shutdown");
- NOTREACHED();
}
}
@@ -574,9 +565,7 @@ bool WebDataService::InitWithPath(const FilePath& path) {
// [ http://crbug.com/100745 ], call |AutofillCountry::ApplicationLocale()| to
// cache the application locale before we try to access it on the DB thread.
// This should be safe to remove once [ http://crbug.com/100845 ] is fixed.
- // Do not do it if the thread is not UI (can happen only in some tests).
- if (BrowserThread::CurrentlyOn(BrowserThread::UI))
- AutofillCountry::ApplicationLocale();
+ AutofillCountry::ApplicationLocale();
ScheduleTask(FROM_HERE,
Bind(&WebDataService::InitializeDatabaseIfNecessary, this));
diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h
index 49d327c..aea638a 100644
--- a/chrome/browser/webdata/web_data_service.h
+++ b/chrome/browser/webdata/web_data_service.h
@@ -20,7 +20,6 @@
#include "base/message_loop_helpers.h"
#include "base/memory/ref_counted.h"
#include "base/synchronization/lock.h"
-#include "chrome/browser/profiles/refcounted_profile_keyed_service.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_id.h"
#include "chrome/browser/webdata/keyword_table.h"
@@ -185,7 +184,9 @@ template <class T> class WDObjectResult : public WDTypedResult {
class WebDataServiceConsumer;
-class WebDataService : public RefcountedProfileKeyedService {
+class WebDataService
+ : public base::RefCountedThreadSafe<
+ WebDataService, content::BrowserThread::DeleteOnUIThread> {
public:
// All requests return an opaque handle of the following type.
typedef int Handle;
@@ -299,15 +300,14 @@ class WebDataService : public RefcountedProfileKeyedService {
// |web_data_service| may be NULL for testing purposes.
static void NotifyOfMultipleAutofillChanges(WebDataService* web_data_service);
- // RefcountedProfileKeyedService override:
- // Shutdown the web data service. The service can no longer be used after this
- // call.
- virtual void ShutdownOnUIThread() OVERRIDE;
-
// Initializes the web data service. Returns false on failure
// Takes the path of the profile directory as its argument.
bool Init(const FilePath& profile_path);
+ // Shutdown the web data service. The service can no longer be used after this
+ // call.
+ void Shutdown();
+
// Returns false if Shutdown() has been called.
bool IsRunning() const;
diff --git a/chrome/browser/webdata/web_data_service_factory.cc b/chrome/browser/webdata/web_data_service_factory.cc
deleted file mode 100644
index d86b80d..0000000
--- a/chrome/browser/webdata/web_data_service_factory.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-#include "chrome/browser/webdata/web_data_service_factory.h"
-
-#include "base/file_path.h"
-#include "chrome/browser/profiles/profile_dependency_manager.h"
-#include "chrome/browser/webdata/web_data_service.h"
-#include "chrome/common/chrome_constants.h"
-
-WebDataServiceFactory::WebDataServiceFactory()
- : RefcountedProfileKeyedServiceFactory(
- "WebDataService",
- ProfileDependencyManager::GetInstance()) {
- // WebDataServiceFactory has no dependecies.
-}
-
-WebDataServiceFactory::~WebDataServiceFactory() {}
-
-// static
-scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfile(
- Profile* profile, Profile::ServiceAccessType access_type) {
- DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
- return static_cast<WebDataService*>(
- GetInstance()->GetServiceForProfile(profile, true).get());
-}
-
-// static
-scoped_refptr<WebDataService> WebDataServiceFactory::GetForProfileIfExists(
- Profile* profile, Profile::ServiceAccessType access_type) {
- DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
- return static_cast<WebDataService*>(
- GetInstance()->GetServiceForProfile(profile, false).get());
-}
-
-// static
-WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
- return Singleton<WebDataServiceFactory>::get();
-}
-
-bool WebDataServiceFactory::ServiceRedirectedInIncognito() {
- return false;
-}
-
-scoped_refptr<RefcountedProfileKeyedService>
-WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
- DCHECK(profile);
-
- FilePath path = profile->GetPath();
- path = path.Append(chrome::kWebDataFilename);
-
- scoped_refptr<WebDataService> wds(new WebDataService());
- if (!wds->Init(profile->GetPath()))
- NOTREACHED();
- return wds.get();
-}
-
-bool WebDataServiceFactory::ServiceIsNULLWhileTesting() {
- return true;
-}
diff --git a/chrome/browser/webdata/web_data_service_factory.h b/chrome/browser/webdata/web_data_service_factory.h
deleted file mode 100644
index 78c179b..0000000
--- a/chrome/browser/webdata/web_data_service_factory.h
+++ /dev/null
@@ -1,44 +0,0 @@
-// 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.
-
-#ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__
-#define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__
-#pragma once
-
-#include "base/basictypes.h"
-#include "base/memory/singleton.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/profiles/refcounted_profile_keyed_service_factory.h"
-
-class WebDataService;
-
-class WebDataServiceFactory : public RefcountedProfileKeyedServiceFactory {
- public:
- // Returns the |WebDataService| associated with the |profile|.
- // |access_type| is either EXPLICIT_ACCESS or IMPLICIT_ACCESS
- // (see its definition).
- static scoped_refptr<WebDataService> GetForProfile(
- Profile* profile, Profile::ServiceAccessType access_type);
-
- // Similar to GetForProfile(), but won't create the web data service if it
- // doesn't already exist.
- static scoped_refptr<WebDataService> GetForProfileIfExists(
- Profile* profile, Profile::ServiceAccessType access_type);
-
- static WebDataServiceFactory* GetInstance();
-
- private:
- friend struct DefaultSingletonTraits<WebDataServiceFactory>;
-
- WebDataServiceFactory();
- virtual ~WebDataServiceFactory();
-
- // |ProfileKeyedBaseFactory| methods:
- virtual bool ServiceRedirectedInIncognito() OVERRIDE;
- virtual scoped_refptr<RefcountedProfileKeyedService> BuildServiceInstanceFor(
- Profile* profile) const OVERRIDE;
- virtual bool ServiceIsNULLWhileTesting() OVERRIDE;
-};
-
-#endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_FACTORY_H__
diff --git a/chrome/browser/webdata/web_data_service_unittest.cc b/chrome/browser/webdata/web_data_service_unittest.cc
index 1023bb1..4cb1927 100644
--- a/chrome/browser/webdata/web_data_service_unittest.cc
+++ b/chrome/browser/webdata/web_data_service_unittest.cc
@@ -88,12 +88,8 @@ class WebDataServiceTest : public testing::Test {
}
virtual void TearDown() {
- wds_->ShutdownOnUIThread();
- wds_ = NULL;
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
+ if (wds_.get())
+ wds_->Shutdown();
db_thread_.Stop();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 40ecf54..1593292 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3977,8 +3977,6 @@
'browser/webdata/web_apps_table.h',
'browser/webdata/web_data_service.cc',
'browser/webdata/web_data_service.h',
- 'browser/webdata/web_data_service_factory.cc',
- 'browser/webdata/web_data_service_factory.h',
'browser/webdata/web_data_service_win.cc',
'browser/webdata/web_database.cc',
'browser/webdata/web_database.h',
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 20b226b..0edf9fc 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -4,7 +4,6 @@
#include "chrome/test/base/browser_with_test_window_test.h"
-#include "base/synchronization/waitable_event.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -35,11 +34,9 @@ using content::WebContents;
BrowserWithTestWindowTest::BrowserWithTestWindowTest()
: ui_thread_(BrowserThread::UI, message_loop()),
- db_thread_(BrowserThread::DB),
file_thread_(BrowserThread::FILE, message_loop()),
file_user_blocking_thread_(
BrowserThread::FILE_USER_BLOCKING, message_loop()) {
- db_thread_.Start();
}
void BrowserWithTestWindowTest::SetUp() {
@@ -75,13 +72,6 @@ BrowserWithTestWindowTest::~BrowserWithTestWindowTest() {
DestroyBrowser();
profile_.reset(NULL);
- // Schedule another task on the DB thread to notify us that it's safe to
- // carry on with the test.
- base::WaitableEvent done(false, false);
- BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
- base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done)));
- done.Wait();
- db_thread_.Stop();
MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
MessageLoop::current()->Run();
}
diff --git a/chrome/test/base/browser_with_test_window_test.h b/chrome/test/base/browser_with_test_window_test.h
index 7994cf5..41ee6a0 100644
--- a/chrome/test/base/browser_with_test_window_test.h
+++ b/chrome/test/base/browser_with_test_window_test.h
@@ -113,7 +113,6 @@ class BrowserWithTestWindowTest : public testing::Test {
// We need to create a MessageLoop, otherwise a bunch of things fails.
MessageLoopForUI ui_loop_;
content::TestBrowserThread ui_thread_;
- content::TestBrowserThread db_thread_;
content::TestBrowserThread file_thread_;
content::TestBrowserThread file_user_blocking_thread_;
diff --git a/chrome/test/base/profile_mock.h b/chrome/test/base/profile_mock.h
index fe95a4d..85447d1 100644
--- a/chrome/test/base/profile_mock.h
+++ b/chrome/test/base/profile_mock.h
@@ -18,6 +18,7 @@ class ProfileMock : public TestingProfile {
MOCK_METHOD0(GetBookmarkModel, BookmarkModel*());
MOCK_METHOD1(GetHistoryService, HistoryService*(ServiceAccessType access));
MOCK_METHOD0(GetHistoryServiceWithoutCreating, HistoryService*());
+ MOCK_METHOD1(GetWebDataService, WebDataService*(ServiceAccessType access));
MOCK_METHOD1(GetPasswordStore, PasswordStore* (ServiceAccessType access));
};
diff --git a/chrome/test/base/testing_profile.cc b/chrome/test/base/testing_profile.cc
index 3aa61dc..ea850b2 100644
--- a/chrome/test/base/testing_profile.cc
+++ b/chrome/test/base/testing_profile.cc
@@ -39,7 +39,7 @@
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
-#include "chrome/browser/webdata/web_data_service_factory.h"
+#include "chrome/browser/sync/profile_sync_service_mock.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
@@ -238,6 +238,7 @@ TestingProfile::~TestingProfile() {
DestroyHistoryService();
// FaviconService depends on HistoryServce so destroying it later.
DestroyFaviconService();
+ DestroyWebDataService();
if (pref_proxy_config_tracker_.get())
pref_proxy_config_tracker_->DetachFromPrefService();
@@ -330,17 +331,19 @@ void TestingProfile::CreateProtocolHandlerRegistry() {
new ProtocolHandlerRegistry::Delegate());
}
-static scoped_refptr<RefcountedProfileKeyedService> BuildWebDataService(
- Profile* profile) {
- WebDataService* web_data_service = new WebDataService();
- if (web_data_service)
- web_data_service->Init(profile->GetPath());
- return scoped_refptr<WebDataService>(web_data_service);
-}
+void TestingProfile::CreateWebDataService(bool delete_file) {
+ if (web_data_service_.get())
+ web_data_service_->Shutdown();
-void TestingProfile::CreateWebDataService() {
- WebDataServiceFactory::GetInstance()->SetTestingFactoryAndUse(
- this, BuildWebDataService);
+ if (delete_file) {
+ FilePath path = GetPath();
+ path = path.Append(chrome::kWebDataFilename);
+ file_util::Delete(path, false);
+ }
+
+ web_data_service_ = new WebDataService;
+ if (web_data_service_.get())
+ web_data_service_->Init(GetPath());
}
void TestingProfile::BlockUntilBookmarkModelLoaded() {
@@ -488,6 +491,14 @@ history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() {
return NULL;
}
+WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) {
+ return web_data_service_.get();
+}
+
+WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() {
+ return web_data_service_.get();
+}
+
void TestingProfile::SetPrefService(PrefService* prefs) {
#if defined(ENABLE_PROTECTOR_SERVICE)
// ProtectorService binds itself very closely to the PrefService at the moment
@@ -693,6 +704,13 @@ quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() {
return GetExtensionSpecialStoragePolicy();
}
+void TestingProfile::DestroyWebDataService() {
+ if (!web_data_service_.get())
+ return;
+
+ web_data_service_->Shutdown();
+}
+
bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) {
return true;
}
diff --git a/chrome/test/base/testing_profile.h b/chrome/test/base/testing_profile.h
index f7da11d..4aa4965 100644
--- a/chrome/test/base/testing_profile.h
+++ b/chrome/test/base/testing_profile.h
@@ -106,8 +106,11 @@ class TestingProfile : public Profile {
// registry is NULL.
void CreateProtocolHandlerRegistry();
- // Creates a WebDataService. If not invoked, the web data service is NULL.
- void CreateWebDataService();
+ // Creates the webdata service. If |delete_file| is true, the webdata file is
+ // deleted first, then the WebDataService is created. As TestingProfile
+ // deletes the directory containing the files used by WebDataService, this
+ // only matters if you're recreating the WebDataService.
+ void CreateWebDataService(bool delete_file);
// Blocks until the BookmarkModel finishes loaded. This is NOT invoked from
// CreateBookmarkModel.
@@ -176,6 +179,8 @@ class TestingProfile : public Profile {
net::CookieMonster* GetCookieMonster();
virtual AutocompleteClassifier* GetAutocompleteClassifier() OVERRIDE;
virtual history::ShortcutsBackend* GetShortcutsBackend() OVERRIDE;
+ virtual WebDataService* GetWebDataService(ServiceAccessType access) OVERRIDE;
+ virtual WebDataService* GetWebDataServiceWithoutCreating() OVERRIDE;
// Sets the profile's PrefService. If a pref service hasn't been explicitly
// set GetPrefs creates one, so normally you need not invoke this. If you need
// to set a pref service you must invoke this before GetPrefs.
@@ -260,6 +265,10 @@ class TestingProfile : public Profile {
// Destroys favicon service if it has been created.
void DestroyFaviconService();
+ // If the webdata service has been created, it is destroyed. This is invoked
+ // from the destructor.
+ void DestroyWebDataService();
+
// Creates a TestingPrefService and associates it with the TestingProfile.
void CreateTestingPrefService();
@@ -279,10 +288,16 @@ class TestingProfile : public Profile {
// is invoked.
scoped_refptr<ProtocolHandlerRegistry> protocol_handler_registry_;
+ // The ProfileSyncService. Created by CreateProfileSyncService.
+ scoped_ptr<ProfileSyncService> profile_sync_service_;
+
// The AutocompleteClassifier. Only created if CreateAutocompleteClassifier
// is invoked.
scoped_ptr<AutocompleteClassifier> autocomplete_classifier_;
+ // The WebDataService. Only created if CreateWebDataService is invoked.
+ scoped_refptr<WebDataService> web_data_service_;
+
// Internally, this is a TestURLRequestContextGetter that creates a dummy
// request context. Currently, only the CookieMonster is hooked up.
scoped_refptr<net::URLRequestContextGetter> request_context_;