| 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 #pragma once | |
| 8 | 7 |
| 9 #include <algorithm> | 8 #include <algorithm> |
| 10 #include <vector> | 9 #include <vector> |
| 11 | 10 |
| 12 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 13 | 12 |
| 14 // ScopedObserver is used to keep track of the set of sources an object has | 13 // ScopedObserver is used to keep track of the set of sources an object has |
| 15 // attached itself to as an observer. When ScopedObserver is destroyed it | 14 // attached itself to as an observer. When ScopedObserver is destroyed it |
| 16 // removes the object as an observer from all sources it has been added to. | 15 // removes the object as an observer from all sources it has been added to. |
| 17 template <class Source, class Observer> | 16 template <class Source, class Observer> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 38 | 37 |
| 39 private: | 38 private: |
| 40 Observer* observer_; | 39 Observer* observer_; |
| 41 | 40 |
| 42 std::vector<Source*> sources_; | 41 std::vector<Source*> sources_; |
| 43 | 42 |
| 44 DISALLOW_COPY_AND_ASSIGN(ScopedObserver); | 43 DISALLOW_COPY_AND_ASSIGN(ScopedObserver); |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 #endif // BASE_SCOPED_OBSERVER_H_ | 46 #endif // BASE_SCOPED_OBSERVER_H_ |
| OLD | NEW |