Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(328)

Side by Side Diff: services/ui/ws/animation_runner.cc

Issue 2424613002: Remove usage of FOR_EACH_OBSERVER macro in services/ (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/public/cpp/window_tree_client.cc ('k') | services/ui/ws/focus_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "services/ui/ws/animation_runner.h" 5 #include "services/ui/ws/animation_runner.h"
6 6
7 #include "base/memory/scoped_vector.h" 7 #include "base/memory/scoped_vector.h"
8 #include "services/ui/ws/animation_runner_observer.h" 8 #include "services/ui/ws/animation_runner_observer.h"
9 #include "services/ui/ws/scheduled_animation_group.h" 9 #include "services/ui/ws/scheduled_animation_group.h"
10 #include "services/ui/ws/server_window.h" 10 #include "services/ui/ws/server_window.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 // Update internal maps 73 // Update internal maps
74 for (auto& group : groups) { 74 for (auto& group : groups) {
75 group->ObtainStartValues(); 75 group->ObtainStartValues();
76 ServerWindow* window = group->window(); 76 ServerWindow* window = group->window();
77 window_to_animation_map_[window] = std::move(group); 77 window_to_animation_map_[window] = std::move(group);
78 DCHECK(!id_to_windows_map_[animation_id].count(window)); 78 DCHECK(!id_to_windows_map_[animation_id].count(window));
79 id_to_windows_map_[animation_id].insert(window); 79 id_to_windows_map_[animation_id].insert(window);
80 } 80 }
81 81
82 FOR_EACH_OBSERVER(AnimationRunnerObserver, observers_, 82 for (auto& observer : observers_)
83 OnAnimationScheduled(animation_id)); 83 observer.OnAnimationScheduled(animation_id);
84 return animation_id; 84 return animation_id;
85 } 85 }
86 86
87 void AnimationRunner::CancelAnimation(AnimationId id) { 87 void AnimationRunner::CancelAnimation(AnimationId id) {
88 if (id_to_windows_map_.count(id) == 0) 88 if (id_to_windows_map_.count(id) == 0)
89 return; 89 return;
90 90
91 std::set<ServerWindow*> windows(id_to_windows_map_[id]); 91 std::set<ServerWindow*> windows(id_to_windows_map_[id]);
92 for (ServerWindow* window : windows) 92 for (ServerWindow* window : windows)
93 CancelAnimationForWindow(window); 93 CancelAnimationForWindow(window);
(...skipping 21 matching lines...) Expand all
115 ServerWindow* window = i->first; 115 ServerWindow* window = i->first;
116 ++i; 116 ++i;
117 bool animation_completed = RemoveWindowFromMaps(window); 117 bool animation_completed = RemoveWindowFromMaps(window);
118 if (animation_completed) 118 if (animation_completed)
119 animations_completed.insert(animation_id); 119 animations_completed.insert(animation_id);
120 } else { 120 } else {
121 ++i; 121 ++i;
122 } 122 }
123 } 123 }
124 for (const AnimationId& id : animations_completed) { 124 for (const AnimationId& id : animations_completed) {
125 FOR_EACH_OBSERVER(AnimationRunnerObserver, observers_, OnAnimationDone(id)); 125 for (auto& observer : observers_)
126 observer.OnAnimationDone(id);
126 } 127 }
127 } 128 }
128 129
129 void AnimationRunner::CancelAnimationForWindowImpl(ServerWindow* window, 130 void AnimationRunner::CancelAnimationForWindowImpl(ServerWindow* window,
130 CancelSource source) { 131 CancelSource source) {
131 if (!window_to_animation_map_[window]) 132 if (!window_to_animation_map_[window])
132 return; 133 return;
133 134
134 const AnimationId animation_id = window_to_animation_map_[window]->id(); 135 const AnimationId animation_id = window_to_animation_map_[window]->id();
135 if (RemoveWindowFromMaps(window)) { 136 if (RemoveWindowFromMaps(window)) {
136 // This was the last window in the group. 137 // This was the last window in the group.
137 if (source == CANCEL_SOURCE_CANCEL) { 138 if (source == CANCEL_SOURCE_CANCEL) {
138 FOR_EACH_OBSERVER(AnimationRunnerObserver, observers_, 139 for (auto& observer : observers_)
139 OnAnimationCanceled(animation_id)); 140 observer.OnAnimationCanceled(animation_id);
140 } else { 141 } else {
141 FOR_EACH_OBSERVER(AnimationRunnerObserver, observers_, 142 for (auto& observer : observers_)
142 OnAnimationInterrupted(animation_id)); 143 observer.OnAnimationInterrupted(animation_id);
143 } 144 }
144 } 145 }
145 } 146 }
146 147
147 bool AnimationRunner::RemoveWindowFromMaps(ServerWindow* window) { 148 bool AnimationRunner::RemoveWindowFromMaps(ServerWindow* window) {
148 DCHECK(window_to_animation_map_[window]); 149 DCHECK(window_to_animation_map_[window]);
149 150
150 const AnimationId animation_id = window_to_animation_map_[window]->id(); 151 const AnimationId animation_id = window_to_animation_map_[window]->id();
151 window_to_animation_map_.erase(window); 152 window_to_animation_map_.erase(window);
152 153
153 DCHECK(id_to_windows_map_.count(animation_id)); 154 DCHECK(id_to_windows_map_.count(animation_id));
154 id_to_windows_map_[animation_id].erase(window); 155 id_to_windows_map_[animation_id].erase(window);
155 if (!id_to_windows_map_[animation_id].empty()) 156 if (!id_to_windows_map_[animation_id].empty())
156 return false; 157 return false;
157 158
158 id_to_windows_map_.erase(animation_id); 159 id_to_windows_map_.erase(animation_id);
159 return true; 160 return true;
160 } 161 }
161 162
162 } // namespace ws 163 } // namespace ws
163 } // namespace ui 164 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/public/cpp/window_tree_client.cc ('k') | services/ui/ws/focus_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698