Commit cbd511b8 authored by ericwilligers's avatar ericwilligers Committed by Commit bot

Reduce usage of FOR_EACH_OBSERVER macro in chrome/browser/signin

Observer lists now support range-based for loops.

BUG=655021

Review-Url: https://chromiumcodereview.appspot.com/2435533004
Cr-Commit-Position: refs/heads/master@{#426951}
parent e30a06a8
...@@ -224,7 +224,8 @@ DownloadHistory::DownloadHistory(content::DownloadManager* manager, ...@@ -224,7 +224,8 @@ DownloadHistory::DownloadHistory(content::DownloadManager* manager,
DownloadHistory::~DownloadHistory() { DownloadHistory::~DownloadHistory() {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadHistoryDestroyed()); for (Observer& observer : observers_)
observer.OnDownloadHistoryDestroyed();
observers_.Clear(); observers_.Clear();
} }
...@@ -288,7 +289,8 @@ void DownloadHistory::QueryCallback(std::unique_ptr<InfoVector> infos) { ...@@ -288,7 +289,8 @@ void DownloadHistory::QueryCallback(std::unique_ptr<InfoVector> infos) {
notifier_.GetManager()->CheckForHistoryFilesRemoval(); notifier_.GetManager()->CheckForHistoryFilesRemoval();
initial_history_query_complete_ = true; initial_history_query_complete_ = true;
FOR_EACH_OBSERVER(Observer, observers_, OnHistoryQueryComplete()); for (Observer& observer : observers_)
observer.OnHistoryQueryComplete();
} }
void DownloadHistory::MaybeAddToHistory(content::DownloadItem* item) { void DownloadHistory::MaybeAddToHistory(content::DownloadItem* item) {
...@@ -316,8 +318,8 @@ void DownloadHistory::MaybeAddToHistory(content::DownloadItem* item) { ...@@ -316,8 +318,8 @@ void DownloadHistory::MaybeAddToHistory(content::DownloadItem* item) {
history_->CreateDownload(*data->info(), base::Bind( history_->CreateDownload(*data->info(), base::Bind(
&DownloadHistory::ItemAdded, weak_ptr_factory_.GetWeakPtr(), &DownloadHistory::ItemAdded, weak_ptr_factory_.GetWeakPtr(),
download_id)); download_id));
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadStored( for (Observer& observer : observers_)
item, *data->info())); observer.OnDownloadStored(item, *data->info());
} }
void DownloadHistory::ItemAdded(uint32_t download_id, bool success) { void DownloadHistory::ItemAdded(uint32_t download_id, bool success) {
...@@ -364,8 +366,8 @@ void DownloadHistory::ItemAdded(uint32_t download_id, bool success) { ...@@ -364,8 +366,8 @@ void DownloadHistory::ItemAdded(uint32_t download_id, bool success) {
// Notify the observer about the change in the persistence state. // Notify the observer about the change in the persistence state.
if (was_persisted != IsPersisted(item)) { if (was_persisted != IsPersisted(item)) {
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadStored( for (Observer& observer : observers_)
item, *data->info())); observer.OnDownloadStored(item, *data->info());
} }
// In case the item changed or became temporary while it was being added. // In case the item changed or became temporary while it was being added.
...@@ -410,8 +412,8 @@ void DownloadHistory::OnDownloadUpdated( ...@@ -410,8 +412,8 @@ void DownloadHistory::OnDownloadUpdated(
should_update, 2); should_update, 2);
if (should_update) { if (should_update) {
history_->UpdateDownload(current_info); history_->UpdateDownload(current_info);
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadStored( for (Observer& observer : observers_)
item, current_info)); observer.OnDownloadStored(item, current_info);
} }
if (item->GetState() == content::DownloadItem::IN_PROGRESS) { if (item->GetState() == content::DownloadItem::IN_PROGRESS) {
data->set_info(current_info); data->set_info(current_info);
...@@ -465,5 +467,6 @@ void DownloadHistory::RemoveDownloadsBatch() { ...@@ -465,5 +467,6 @@ void DownloadHistory::RemoveDownloadsBatch() {
IdSet remove_ids; IdSet remove_ids;
removing_ids_.swap(remove_ids); removing_ids_.swap(remove_ids);
history_->RemoveDownloads(remove_ids); history_->RemoveDownloads(remove_ids);
FOR_EACH_OBSERVER(Observer, observers_, OnDownloadsRemoved(remove_ids)); for (Observer& observer : observers_)
observer.OnDownloadsRemoved(remove_ids);
} }
...@@ -283,8 +283,8 @@ void CrossDevicePromo::MarkPromoShouldBeShown() { ...@@ -283,8 +283,8 @@ void CrossDevicePromo::MarkPromoShouldBeShown() {
if (!prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { if (!prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) {
prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, true); prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, true);
FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, for (CrossDevicePromo::Observer& observer : observer_list_)
OnPromoEligibilityChanged(true)); observer.OnPromoEligibilityChanged(true);
} }
} }
...@@ -292,8 +292,8 @@ void CrossDevicePromo::MarkPromoShouldNotBeShown() { ...@@ -292,8 +292,8 @@ void CrossDevicePromo::MarkPromoShouldNotBeShown() {
VLOG(1) << "CrossDevicePromo::MarkPromoShouldNotBeShown."; VLOG(1) << "CrossDevicePromo::MarkPromoShouldNotBeShown.";
if (prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) { if (prefs_->GetBoolean(prefs::kCrossDevicePromoShouldBeShown)) {
prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, false); prefs_->SetBoolean(prefs::kCrossDevicePromoShouldBeShown, false);
FOR_EACH_OBSERVER(CrossDevicePromo::Observer, observer_list_, for (CrossDevicePromo::Observer& observer : observer_list_)
OnPromoEligibilityChanged(false)); observer.OnPromoEligibilityChanged(false);
} }
} }
......
...@@ -494,8 +494,8 @@ bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) { ...@@ -494,8 +494,8 @@ bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) {
HandleAuthFailure(GetAccountId()); HandleAuthFailure(GetAccountId());
} }
FOR_EACH_OBSERVER( for (EasyUnlockServiceObserver& observer : observers_)
EasyUnlockServiceObserver, observers_, OnScreenlockStateChanged(state)); observer.OnScreenlockStateChanged(state);
return true; return true;
} }
...@@ -723,8 +723,8 @@ void EasyUnlockService::NotifyUserUpdated() { ...@@ -723,8 +723,8 @@ void EasyUnlockService::NotifyUserUpdated() {
} }
void EasyUnlockService::NotifyTurnOffOperationStatusChanged() { void EasyUnlockService::NotifyTurnOffOperationStatusChanged() {
FOR_EACH_OBSERVER( for (EasyUnlockServiceObserver& observer : observers_)
EasyUnlockServiceObserver, observers_, OnTurnOffOperationStatusChanged()); observer.OnTurnOffOperationStatusChanged();
} }
void EasyUnlockService::ResetScreenlockState() { void EasyUnlockService::ResetScreenlockState() {
......
...@@ -100,7 +100,8 @@ void SigninManagerFactory::RemoveObserver(Observer* observer) { ...@@ -100,7 +100,8 @@ void SigninManagerFactory::RemoveObserver(Observer* observer) {
void SigninManagerFactory::NotifyObserversOfSigninManagerCreationForTesting( void SigninManagerFactory::NotifyObserversOfSigninManagerCreationForTesting(
SigninManagerBase* manager) { SigninManagerBase* manager) {
FOR_EACH_OBSERVER(Observer, observer_list_, SigninManagerCreated(manager)); for (Observer& observer : observer_list_)
observer.SigninManagerCreated(manager);
} }
KeyedService* SigninManagerFactory::BuildServiceInstanceFor( KeyedService* SigninManagerFactory::BuildServiceInstanceFor(
...@@ -122,7 +123,8 @@ KeyedService* SigninManagerFactory::BuildServiceInstanceFor( ...@@ -122,7 +123,8 @@ KeyedService* SigninManagerFactory::BuildServiceInstanceFor(
AccountFetcherServiceFactory::GetForProfile(profile); AccountFetcherServiceFactory::GetForProfile(profile);
#endif #endif
service->Initialize(g_browser_process->local_state()); service->Initialize(g_browser_process->local_state());
FOR_EACH_OBSERVER(Observer, observer_list_, SigninManagerCreated(service)); for (Observer& observer : observer_list_)
observer.SigninManagerCreated(service);
return service; return service;
} }
...@@ -130,7 +132,9 @@ void SigninManagerFactory::BrowserContextShutdown( ...@@ -130,7 +132,9 @@ void SigninManagerFactory::BrowserContextShutdown(
content::BrowserContext* context) { content::BrowserContext* context) {
SigninManagerBase* manager = static_cast<SigninManagerBase*>( SigninManagerBase* manager = static_cast<SigninManagerBase*>(
GetServiceForBrowserContext(context, false)); GetServiceForBrowserContext(context, false));
if (manager) if (manager) {
FOR_EACH_OBSERVER(Observer, observer_list_, SigninManagerShutdown(manager)); for (Observer& observer : observer_list_)
observer.SigninManagerShutdown(manager);
}
BrowserContextKeyedServiceFactory::BrowserContextShutdown(context); BrowserContextKeyedServiceFactory::BrowserContextShutdown(context);
} }
...@@ -28,12 +28,14 @@ bool StatusIcon::HasObservers() const { ...@@ -28,12 +28,14 @@ bool StatusIcon::HasObservers() const {
} }
void StatusIcon::DispatchClickEvent() { void StatusIcon::DispatchClickEvent() {
FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnStatusIconClicked()); for (StatusIconObserver& observer : observers_)
observer.OnStatusIconClicked();
} }
#if defined(OS_WIN) #if defined(OS_WIN)
void StatusIcon::DispatchBalloonClickEvent() { void StatusIcon::DispatchBalloonClickEvent() {
FOR_EACH_OBSERVER(StatusIconObserver, observers_, OnBalloonClicked()); for (StatusIconObserver& observer : observers_)
observer.OnBalloonClicked();
} }
#endif #endif
......
...@@ -163,7 +163,8 @@ void StatusIconMenuModel::MenuItemsChanged() { ...@@ -163,7 +163,8 @@ void StatusIconMenuModel::MenuItemsChanged() {
} }
void StatusIconMenuModel::NotifyMenuStateChanged() { void StatusIconMenuModel::NotifyMenuStateChanged() {
FOR_EACH_OBSERVER(Observer, observer_list_, OnMenuStateChanged()); for (Observer& observer : observer_list_)
observer.OnMenuStateChanged();
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
......
...@@ -187,8 +187,8 @@ class TestSyncProcessorStub : public syncer::SyncChangeProcessor { ...@@ -187,8 +187,8 @@ class TestSyncProcessorStub : public syncer::SyncChangeProcessor {
void NotifyLocalChangeObservers() { void NotifyLocalChangeObservers() {
const syncer::SyncChange empty_change; const syncer::SyncChange empty_change;
FOR_EACH_OBSERVER(syncer::LocalChangeObserver, local_change_observers_, for (syncer::LocalChangeObserver& observer : local_change_observers_)
OnLocalChange(NULL, empty_change)); observer.OnLocalChange(NULL, empty_change);
} }
void FailProcessSyncChangesWith(const syncer::SyncError& error) { void FailProcessSyncChangesWith(const syncer::SyncError& error) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment