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

Side by Side Diff: ui/chromeos/network/network_icon_animation.cc

Issue 2422073002: Reduce FOR_EACH_OBSERVER usage in ui/ (Closed)
Patch Set: remove space 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "ui/chromeos/network/network_icon_animation.h" 5 #include "ui/chromeos/network/network_icon_animation.h"
6 6
7 #include "ui/chromeos/network/network_icon_animation_observer.h" 7 #include "ui/chromeos/network/network_icon_animation_observer.h"
8 8
9 namespace { 9 namespace {
10 const int kThrobDurationMs = 750; // Animation cycle length. 10 const int kThrobDurationMs = 750; // Animation cycle length.
11 } 11 }
12 12
13 namespace ui { 13 namespace ui {
14 namespace network_icon { 14 namespace network_icon {
15 15
16 NetworkIconAnimation::NetworkIconAnimation() 16 NetworkIconAnimation::NetworkIconAnimation()
17 : animation_(this) { 17 : animation_(this) {
18 // Set up the animation throbber. 18 // Set up the animation throbber.
19 animation_.SetThrobDuration(kThrobDurationMs); 19 animation_.SetThrobDuration(kThrobDurationMs);
20 animation_.SetTweenType(gfx::Tween::LINEAR); 20 animation_.SetTweenType(gfx::Tween::LINEAR);
21 } 21 }
22 22
23 NetworkIconAnimation::~NetworkIconAnimation() { 23 NetworkIconAnimation::~NetworkIconAnimation() {
24 } 24 }
25 25
26 void NetworkIconAnimation::AnimationProgressed( 26 void NetworkIconAnimation::AnimationProgressed(
27 const gfx::Animation* animation) { 27 const gfx::Animation* animation) {
28 if (animation != &animation_) 28 if (animation != &animation_)
29 return; 29 return;
30 FOR_EACH_OBSERVER(AnimationObserver, observers_, NetworkIconChanged()); 30 for (AnimationObserver& observer : observers_)
31 observer.NetworkIconChanged();
31 } 32 }
32 33
33 double NetworkIconAnimation::GetAnimation() { 34 double NetworkIconAnimation::GetAnimation() {
34 if (!animation_.is_animating()) { 35 if (!animation_.is_animating()) {
35 animation_.Reset(); 36 animation_.Reset();
36 animation_.StartThrobbing(-1 /*throb indefinitely*/); 37 animation_.StartThrobbing(-1 /*throb indefinitely*/);
37 return 0; 38 return 0;
38 } 39 }
39 return animation_.GetCurrentValue(); 40 return animation_.GetCurrentValue();
40 } 41 }
(...skipping 11 matching lines...) Expand all
52 53
53 // static 54 // static
54 NetworkIconAnimation* NetworkIconAnimation::GetInstance() { 55 NetworkIconAnimation* NetworkIconAnimation::GetInstance() {
55 static NetworkIconAnimation* s_icon_animation = 56 static NetworkIconAnimation* s_icon_animation =
56 new NetworkIconAnimation(); 57 new NetworkIconAnimation();
57 return s_icon_animation; 58 return s_icon_animation;
58 } 59 }
59 60
60 } // namespace network_icon 61 } // namespace network_icon
61 } // namespace ui 62 } // namespace ui
OLDNEW
« no previous file with comments | « ui/chromeos/ime/input_method_menu_manager.cc ('k') | ui/display/chromeos/display_configurator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698