diff options
author | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 18:13:03 +0000 |
---|---|---|
committer | tim@chromium.org <tim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 18:13:03 +0000 |
commit | ac45ac54f31e5dd64a089b432525ecd8fab5e086 (patch) | |
tree | 9f06f6f3cb40dad1f618a32b52949fbbcbf89821 /chrome/browser/sync | |
parent | 5d0f1d9523731593681d014d9534b244be0df5a0 (diff) | |
download | chromium_src-ac45ac54f31e5dd64a089b432525ecd8fab5e086.zip chromium_src-ac45ac54f31e5dd64a089b432525ecd8fab5e086.tar.gz chromium_src-ac45ac54f31e5dd64a089b432525ecd8fab5e086.tar.bz2 |
Add Sources to several notifications.
BUG=none
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/3400011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/sync')
5 files changed, 36 insertions, 25 deletions
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc index d170ec3..2266a3f 100644 --- a/chrome/browser/sync/glue/data_type_manager_impl.cc +++ b/chrome/browser/sync/glue/data_type_manager_impl.cc @@ -412,14 +412,14 @@ void DataTypeManagerImpl::RemoveObserver(NotificationType type) { void DataTypeManagerImpl::NotifyStart() { NotificationService::current()->Notify( NotificationType::SYNC_CONFIGURE_START, - NotificationService::AllSources(), + Source<DataTypeManager>(this), NotificationService::NoDetails()); } void DataTypeManagerImpl::NotifyDone(ConfigureResult result) { NotificationService::current()->Notify( NotificationType::SYNC_CONFIGURE_DONE, - NotificationService::AllSources(), + Source<DataTypeManager>(this), Details<ConfigureResult>(&result)); } diff --git a/chrome/browser/sync/glue/data_type_manager_mock.h b/chrome/browser/sync/glue/data_type_manager_mock.h index ce61e27..2a1705a 100644 --- a/chrome/browser/sync/glue/data_type_manager_mock.h +++ b/chrome/browser/sync/glue/data_type_manager_mock.h @@ -13,13 +13,19 @@ #include "chrome/common/notification_type.h" #include "testing/gmock/include/gmock/gmock.h" -ACTION_P2(NotifyWithResult, type, result) { +ACTION_P3(NotifyFromDataTypeManagerWithResult, dtm, type, result) { NotificationService::current()->Notify( type, - NotificationService::AllSources(), + Source<browser_sync::DataTypeManager>(dtm), Details<browser_sync::DataTypeManager::ConfigureResult>(result)); } +ACTION_P2(NotifyFromDataTypeManager, dtm, type) { + NotificationService::current()->Notify(type, + Source<browser_sync::DataTypeManager>(dtm), + NotificationService::NoDetails()); +} + namespace browser_sync { class DataTypeManagerMock : public DataTypeManager { @@ -30,9 +36,10 @@ class DataTypeManagerMock : public DataTypeManager { // detail. ON_CALL(*this, Configure(testing::_)). WillByDefault(testing::DoAll( - Notify(NotificationType::SYNC_CONFIGURE_START), - NotifyWithResult(NotificationType::SYNC_CONFIGURE_DONE, - &result_))); + NotifyFromDataTypeManager(this, + NotificationType::SYNC_CONFIGURE_START), + NotifyFromDataTypeManagerWithResult + (this, NotificationType::SYNC_CONFIGURE_DONE, &result_))); } MOCK_METHOD1(Configure, void(const TypeSet&)); diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc index 56c8b86..1df0905 100644 --- a/chrome/browser/sync/glue/sync_backend_host.cc +++ b/chrome/browser/sync/glue/sync_backend_host.cc @@ -337,7 +337,7 @@ void SyncBackendHost::Core::NotifyResumed() { void SyncBackendHost::Core::NotifyPassphraseRequired() { NotificationService::current()->Notify( NotificationType::SYNC_PASSPHRASE_REQUIRED, - NotificationService::AllSources(), + Source<SyncBackendHost>(host_), NotificationService::NoDetails()); } @@ -346,7 +346,7 @@ void SyncBackendHost::Core::NotifyPassphraseAccepted( host_->PersistEncryptionBootstrapToken(bootstrap_token); NotificationService::current()->Notify( NotificationType::SYNC_PASSPHRASE_ACCEPTED, - NotificationService::AllSources(), + Source<SyncBackendHost>(host_), NotificationService::NoDetails()); } diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index 1196647..b049dd8 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -75,20 +75,8 @@ ProfileSyncService::ProfileSyncService(ProfileSyncFactory* factory, DCHECK(factory); DCHECK(profile); registrar_.Add(this, - NotificationType::SYNC_CONFIGURE_START, - NotificationService::AllSources()); - registrar_.Add(this, - NotificationType::SYNC_CONFIGURE_DONE, - NotificationService::AllSources()); - registrar_.Add(this, NotificationType::SYNC_DATA_TYPES_UPDATED, - NotificationService::AllSources()); - registrar_.Add(this, - NotificationType::SYNC_PASSPHRASE_REQUIRED, - NotificationService::AllSources()); - registrar_.Add(this, - NotificationType::SYNC_PASSPHRASE_ACCEPTED, - NotificationService::AllSources()); + Source<Profile>(profile)); // By default, dev & chromium users will go to the development servers. // Dev servers have more features than standard sync servers. @@ -401,6 +389,14 @@ void ProfileSyncService::StartUp() { profile_->GetPrefs()->GetInt64(prefs::kSyncLastSyncedTime)); CreateBackend(); + + registrar_.Add(this, + NotificationType::SYNC_PASSPHRASE_REQUIRED, + Source<SyncBackendHost>(backend_.get())); + registrar_.Add(this, + NotificationType::SYNC_PASSPHRASE_ACCEPTED, + Source<SyncBackendHost>(backend_.get())); + // Initialize the backend. Every time we start up a new SyncBackendHost, // we'll want to start from a fresh SyncDB, so delete any old one that might // be there. @@ -824,6 +820,12 @@ void ProfileSyncService::ConfigureDataTypeManager() { data_type_manager_.reset( factory_->CreateDataTypeManager(backend_.get(), data_type_controllers_)); + registrar_.Add(this, + NotificationType::SYNC_CONFIGURE_START, + Source<DataTypeManager>(data_type_manager_.get())); + registrar_.Add(this, + NotificationType::SYNC_CONFIGURE_DONE, + Source<DataTypeManager>(data_type_manager_.get())); } syncable::ModelTypeSet types; diff --git a/chrome/browser/sync/profile_sync_service_startup_unittest.cc b/chrome/browser/sync/profile_sync_service_startup_unittest.cc index e831e36..e7e1a34 100644 --- a/chrome/browser/sync/profile_sync_service_startup_unittest.cc +++ b/chrome/browser/sync/profile_sync_service_startup_unittest.cc @@ -175,9 +175,11 @@ TEST_F(ProfileSyncServiceStartupTest, SKIP_MACOSX(StartFailure)) { DataTypeManager::ConfigureResult result = DataTypeManager::ASSOCIATION_FAILED; EXPECT_CALL(*data_type_manager, Configure(_)). - WillOnce(DoAll(Notify(NotificationType::SYNC_CONFIGURE_START), - NotifyWithResult(NotificationType::SYNC_CONFIGURE_DONE, - &result))); + WillOnce(DoAll(NotifyFromDataTypeManager(data_type_manager, + NotificationType::SYNC_CONFIGURE_START), + NotifyFromDataTypeManagerWithResult(data_type_manager, + NotificationType::SYNC_CONFIGURE_DONE, + &result))); EXPECT_CALL(*data_type_manager, state()). WillOnce(Return(DataTypeManager::STOPPED)); |