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

Side by Side Diff: ash/system/chromeos/network/network_icon_animation.cc

Issue 12094072: Use ash NetworkIconAnimation in NetworkMenuIcon code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/system/chromeos/network/network_icon_animation.h"
6
7 #include "ash/system/chromeos/network/network_icon_animation_observer.h"
8
9 namespace {
10 const int kThrobDurationMs = 750; // Animation cycle length.
11 }
12
13 namespace ash {
14 namespace network_icon {
15
16 NetworkIconAnimation::NetworkIconAnimation()
17 : ALLOW_THIS_IN_INITIALIZER_LIST(animation_(this)) {
18 // Set up the animation throbber.
19 animation_.SetThrobDuration(kThrobDurationMs);
20 animation_.SetTweenType(ui::Tween::LINEAR);
21 }
22
23 NetworkIconAnimation::~NetworkIconAnimation() {
24 }
25
26 void NetworkIconAnimation::AnimationProgressed(const ui::Animation* animation) {
tfarina 2013/02/20 02:48:48 the order of this definition does not match the or
27 if (animation != &animation_)
28 return;
29 FOR_EACH_OBSERVER(AnimationObserver, observers_, NetworkIconChanged());
30 }
31
32 double NetworkIconAnimation::GetAnimation() {
33 if (!animation_.is_animating()) {
34 animation_.Reset();
35 animation_.StartThrobbing(-1 /*throb indefinitely*/);
36 return 0;
37 }
38 return animation_.GetCurrentValue();
39 }
40
41 void NetworkIconAnimation::AddObserver(AnimationObserver* observer) {
42 observers_.AddObserver(observer);
43 }
44
45 void NetworkIconAnimation::RemoveObserver(AnimationObserver* observer) {
46 observers_.RemoveObserver(observer);
47 if (observers_.size() == 0)
48 animation_.Stop();
49 }
50
51 // static
52 NetworkIconAnimation* NetworkIconAnimation::GetInstance() {
53 static NetworkIconAnimation* s_icon_animation =
54 new NetworkIconAnimation();
55 return s_icon_animation;
56 }
57
58 } // namespace network_icon
59 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698