OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_API_NOTIFIER_H_ | 11 #ifndef WEBRTC_API_NOTIFIER_H_ |
12 #define WEBRTC_API_NOTIFIER_H_ | 12 #define WEBRTC_API_NOTIFIER_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 | 15 |
16 #include "webrtc/api/mediastreaminterface.h" | 16 #include "webrtc/api/mediastreaminterface.h" |
17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 | 20 |
21 // Implements a template version of a notifier. | 21 // Implements a template version of a notifier. |
22 // TODO(deadbeef): This is an implementation detail; move out of api/. | 22 // TODO(deadbeef): This is an implementation detail; move out of api/. |
23 template <class T> | 23 template <class T> |
24 class Notifier : public T { | 24 class Notifier : public T { |
25 public: | 25 public: |
26 Notifier() { | 26 Notifier() { |
27 } | 27 } |
28 | 28 |
29 virtual void RegisterObserver(ObserverInterface* observer) { | 29 virtual void RegisterObserver(ObserverInterface* observer) { |
30 RTC_DCHECK(observer != NULL); | 30 RTC_DCHECK(observer != nullptr); |
31 observers_.push_back(observer); | 31 observers_.push_back(observer); |
32 } | 32 } |
33 | 33 |
34 virtual void UnregisterObserver(ObserverInterface* observer) { | 34 virtual void UnregisterObserver(ObserverInterface* observer) { |
35 for (std::list<ObserverInterface*>::iterator it = observers_.begin(); | 35 for (std::list<ObserverInterface*>::iterator it = observers_.begin(); |
36 it != observers_.end(); it++) { | 36 it != observers_.end(); it++) { |
37 if (*it == observer) { | 37 if (*it == observer) { |
38 observers_.erase(it); | 38 observers_.erase(it); |
39 break; | 39 break; |
40 } | 40 } |
(...skipping 11 matching lines...) Expand all Loading... |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 protected: | 55 protected: |
56 std::list<ObserverInterface*> observers_; | 56 std::list<ObserverInterface*> observers_; |
57 }; | 57 }; |
58 | 58 |
59 } // namespace webrtc | 59 } // namespace webrtc |
60 | 60 |
61 #endif // WEBRTC_API_NOTIFIER_H_ | 61 #endif // WEBRTC_API_NOTIFIER_H_ |
OLD | NEW |