OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #ifndef ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ | 5 #ifndef ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ |
6 #define ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ | 6 #define ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" |
12 | 12 |
13 // ScopedObserverWithDuplicatedSources is used to keep track of the set of | 13 // ScopedObserverWithDuplicatedSources is used to keep track of the set of |
14 // sources an object has attached itself to as an observer. When | 14 // sources an object has attached itself to as an observer. When |
15 // ScopedObserverWithDuplicatedSources is destroyed it removes the object as an | 15 // ScopedObserverWithDuplicatedSources is destroyed it removes the object as an |
16 // observer from all sources it has been added to. | 16 // observer from all sources it has been added to. |
17 // ScopedObserverWithDuplicatedSources adds |observer| once for a particular | 17 // ScopedObserverWithDuplicatedSources adds |observer| once for a particular |
18 // source, no matter how many times Add() is invoked. Additionaly |observer| is | 18 // source, no matter how many times Add() is invoked. Additionaly |observer| is |
19 // only removed once Remove() is invoked the same number of times as Add(). | 19 // only removed once Remove() is invoked the same number of times as Add(). |
20 | 20 |
21 template <class Source, class Observer> | 21 template <class Source, class Observer> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 Observer* observer_; | 62 Observer* observer_; |
63 | 63 |
64 // Map Source and its adding count. | 64 // Map Source and its adding count. |
65 std::map<Source*, int> counted_sources_; | 65 std::map<Source*, int> counted_sources_; |
66 | 66 |
67 DISALLOW_COPY_AND_ASSIGN(ScopedObserverWithDuplicatedSources); | 67 DISALLOW_COPY_AND_ASSIGN(ScopedObserverWithDuplicatedSources); |
68 }; | 68 }; |
69 | 69 |
70 #endif // ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ | 70 #endif // ASH_SHELF_SCOPED_OBSERVER_WITH_DUPLICATED_SOURCES_H_ |
OLD | NEW |