Skip to content

Commit

Permalink
Remove usage of FOR_EACH_OBSERVER macro in blimp
Browse files Browse the repository at this point in the history
Observer lists now support range-based for loops.

BUG=655021

Review-Url: https://codereview.chromium.org/2425493002
Cr-Commit-Position: refs/heads/master@{#425768}
  • Loading branch information
ericwilligers authored and Commit bot committed Oct 17, 2016
1 parent 7c5d5c0 commit 08199f1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
15 changes: 8 additions & 7 deletions blimp/client/core/contents/blimp_contents_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ BlimpContentsImpl::BlimpContentsImpl(
}

BlimpContentsImpl::~BlimpContentsImpl() {
FOR_EACH_OBSERVER(BlimpContentsObserver, observers_, BlimpContentsDying());
for (auto& observer : observers_)
observer.BlimpContentsDying();
ime_feature_->set_delegate(nullptr);
}

Expand Down Expand Up @@ -103,18 +104,18 @@ bool BlimpContentsImpl::HasObserver(BlimpContentsObserver* observer) {
}

void BlimpContentsImpl::OnNavigationStateChanged() {
FOR_EACH_OBSERVER(BlimpContentsObserver, observers_,
OnNavigationStateChanged());
for (auto& observer : observers_)
observer.OnNavigationStateChanged();
}

void BlimpContentsImpl::OnLoadingStateChanged(bool loading) {
FOR_EACH_OBSERVER(BlimpContentsObserver, observers_,
OnLoadingStateChanged(loading));
for (auto& observer : observers_)
observer.OnLoadingStateChanged(loading);
}

void BlimpContentsImpl::OnPageLoadingStateChanged(bool loading) {
FOR_EACH_OBSERVER(BlimpContentsObserver, observers_,
OnPageLoadingStateChanged(loading));
for (auto& observer : observers_)
observer.OnPageLoadingStateChanged(loading);
}

void BlimpContentsImpl::SetSizeAndScale(const gfx::Size& size,
Expand Down
7 changes: 4 additions & 3 deletions blimp/client/core/session/connection_status.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ base::WeakPtr<ConnectionStatus> ConnectionStatus::GetWeakPtr() {
void ConnectionStatus::OnConnected() {
is_connected_ = true;
UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", true);
FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_, OnConnected());
for (auto& observer : connection_observers_)
observer.OnConnected();
}

void ConnectionStatus::OnDisconnected(int result) {
is_connected_ = false;
UMA_HISTOGRAM_BOOLEAN("Blimp.Connected", false);
FOR_EACH_OBSERVER(NetworkEventObserver, connection_observers_,
OnDisconnected(result));
for (auto& observer : connection_observers_)
observer.OnDisconnected(result);
}

} // namespace client
Expand Down
3 changes: 2 additions & 1 deletion blimp/engine/app/settings_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ void SettingsManager::UpdateEngineSettings(const EngineSettings& settings) {

if (settings_.record_whole_document != old_settings.record_whole_document) {
// Notify the observers that the web preferences have changed.
FOR_EACH_OBSERVER(Observer, observer_list_, OnWebPreferencesChanged());
for (auto& observer : observer_list_)
observer.OnWebPreferencesChanged();
}
}

Expand Down
4 changes: 2 additions & 2 deletions blimp/engine/app/ui/blimp_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ void BlimpScreen::UpdateDisplayScaleAndSize(float scale,

display_.SetScaleAndBounds(scale, gfx::Rect(size));

FOR_EACH_OBSERVER(display::DisplayObserver, observers_,
OnDisplayMetricsChanged(display_, metrics));
for (auto& observer : observers_)
observer.OnDisplayMetricsChanged(display_, metrics);
}

gfx::Point BlimpScreen::GetCursorScreenPoint() {
Expand Down
4 changes: 2 additions & 2 deletions blimp/net/blimp_connection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ void BlimpConnection::OnConnectionError(int error) {
VLOG(1) << "OnConnectionError, error=" << error;

// Propagate the error to all observers.
FOR_EACH_OBSERVER(ConnectionErrorObserver, error_observers_,
OnConnectionError(error));
for (auto& observer : error_observers_)
observer.OnConnectionError(error);
}

} // namespace blimp

0 comments on commit 08199f1

Please sign in to comment.