OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_OBSERVER_LIST_THREADSAFE_H_ | 5 #ifndef BASE_OBSERVER_LIST_THREADSAFE_H_ |
6 #define BASE_OBSERVER_LIST_THREADSAFE_H_ | 6 #define BASE_OBSERVER_LIST_THREADSAFE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 } | 178 } |
179 | 179 |
180 // TODO(mbelshe): Add more wrappers for Notify() with more arguments. | 180 // TODO(mbelshe): Add more wrappers for Notify() with more arguments. |
181 | 181 |
182 private: | 182 private: |
183 // See comment above ObserverListThreadSafeTraits' definition. | 183 // See comment above ObserverListThreadSafeTraits' definition. |
184 friend struct ObserverListThreadSafeTraits<ObserverType>; | 184 friend struct ObserverListThreadSafeTraits<ObserverType>; |
185 | 185 |
186 struct ObserverListContext { | 186 struct ObserverListContext { |
187 explicit ObserverListContext(NotificationType type) | 187 explicit ObserverListContext(NotificationType type) |
188 : loop(base::MessageLoopProxy::CreateForCurrentThread()), | 188 : loop(base::MessageLoopProxy::current()), |
189 list(type) { | 189 list(type) { |
190 } | 190 } |
191 | 191 |
192 scoped_refptr<base::MessageLoopProxy> loop; | 192 scoped_refptr<base::MessageLoopProxy> loop; |
193 ObserverList<ObserverType> list; | 193 ObserverList<ObserverType> list; |
194 | 194 |
195 DISALLOW_COPY_AND_ASSIGN(ObserverListContext); | 195 DISALLOW_COPY_AND_ASSIGN(ObserverListContext); |
196 }; | 196 }; |
197 | 197 |
198 ~ObserverListThreadSafe() { | 198 ~ObserverListThreadSafe() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 typedef std::map<MessageLoop*, ObserverListContext*> ObserversListMap; | 263 typedef std::map<MessageLoop*, ObserverListContext*> ObserversListMap; |
264 | 264 |
265 base::Lock list_lock_; // Protects the observer_lists_. | 265 base::Lock list_lock_; // Protects the observer_lists_. |
266 ObserversListMap observer_lists_; | 266 ObserversListMap observer_lists_; |
267 const NotificationType type_; | 267 const NotificationType type_; |
268 | 268 |
269 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); | 269 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); |
270 }; | 270 }; |
271 | 271 |
272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ | 272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ |
OLD | NEW |