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

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

Issue 23190045: Switch ObserverList::size() to ObserverList::might_have_observers() Pt.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 3 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
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 "ash/system/chromeos/network/network_icon_animation.h" 5 #include "ash/system/chromeos/network/network_icon_animation.h"
6 6
7 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 7 #include "ash/system/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.
(...skipping 27 matching lines...) Expand all
38 return animation_.GetCurrentValue(); 38 return animation_.GetCurrentValue();
39 } 39 }
40 40
41 void NetworkIconAnimation::AddObserver(AnimationObserver* observer) { 41 void NetworkIconAnimation::AddObserver(AnimationObserver* observer) {
42 if (!observers_.HasObserver(observer)) 42 if (!observers_.HasObserver(observer))
43 observers_.AddObserver(observer); 43 observers_.AddObserver(observer);
44 } 44 }
45 45
46 void NetworkIconAnimation::RemoveObserver(AnimationObserver* observer) { 46 void NetworkIconAnimation::RemoveObserver(AnimationObserver* observer) {
47 observers_.RemoveObserver(observer); 47 observers_.RemoveObserver(observer);
48 if (observers_.size() == 0) 48 if (!observers_.might_have_observers())
49 animation_.Reset(); // Stops the animation and resets the current value. 49 animation_.Reset(); // Stops the animation and resets the current value.
50 } 50 }
51 51
52 // static 52 // static
53 NetworkIconAnimation* NetworkIconAnimation::GetInstance() { 53 NetworkIconAnimation* NetworkIconAnimation::GetInstance() {
54 static NetworkIconAnimation* s_icon_animation = 54 static NetworkIconAnimation* s_icon_animation =
55 new NetworkIconAnimation(); 55 new NetworkIconAnimation();
56 return s_icon_animation; 56 return s_icon_animation;
57 } 57 }
58 58
59 } // namespace network_icon 59 } // namespace network_icon
60 } // namespace ash 60 } // namespace ash
OLDNEW
« no previous file with comments | « ash/launcher/launcher_button.cc ('k') | chrome/browser/chromeos/cros/network_library_impl_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698