OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_SCOPED_OBSERVER_H_ | 5 #ifndef BASE_SCOPED_OBSERVER_H_ |
6 #define BASE_SCOPED_OBSERVER_H_ | 6 #define BASE_SCOPED_OBSERVER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 29 matching lines...) Expand all Loading... |
40 source->RemoveObserver(observer_); | 40 source->RemoveObserver(observer_); |
41 } | 41 } |
42 | 42 |
43 void RemoveAll() { | 43 void RemoveAll() { |
44 for (size_t i = 0; i < sources_.size(); ++i) | 44 for (size_t i = 0; i < sources_.size(); ++i) |
45 sources_[i]->RemoveObserver(observer_); | 45 sources_[i]->RemoveObserver(observer_); |
46 sources_.clear(); | 46 sources_.clear(); |
47 } | 47 } |
48 | 48 |
49 bool IsObserving(Source* source) const { | 49 bool IsObserving(Source* source) const { |
50 return ContainsValue(sources_, source); | 50 return base::ContainsValue(sources_, source); |
51 } | 51 } |
52 | 52 |
53 bool IsObservingSources() const { return !sources_.empty(); } | 53 bool IsObservingSources() const { return !sources_.empty(); } |
54 | 54 |
55 private: | 55 private: |
56 Observer* observer_; | 56 Observer* observer_; |
57 | 57 |
58 std::vector<Source*> sources_; | 58 std::vector<Source*> sources_; |
59 | 59 |
60 DISALLOW_COPY_AND_ASSIGN(ScopedObserver); | 60 DISALLOW_COPY_AND_ASSIGN(ScopedObserver); |
61 }; | 61 }; |
62 | 62 |
63 #endif // BASE_SCOPED_OBSERVER_H_ | 63 #endif // BASE_SCOPED_OBSERVER_H_ |
OLD | NEW |