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_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 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <map> | 9 #include <map> |
10 #include <memory> | 10 #include <memory> |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 Method m, Params&&... params) { | 144 Method m, Params&&... params) { |
145 Callback<void(ObserverType*)> method = | 145 Callback<void(ObserverType*)> method = |
146 Bind(&internal::Dispatcher<ObserverType, Method>::Run, | 146 Bind(&internal::Dispatcher<ObserverType, Method>::Run, |
147 m, std::forward<Params>(params)...); | 147 m, std::forward<Params>(params)...); |
148 | 148 |
149 AutoLock lock(list_lock_); | 149 AutoLock lock(list_lock_); |
150 for (const auto& entry : observer_lists_) { | 150 for (const auto& entry : observer_lists_) { |
151 ObserverListContext* context = entry.second.get(); | 151 ObserverListContext* context = entry.second.get(); |
152 context->task_runner->PostTask( | 152 context->task_runner->PostTask( |
153 from_here, | 153 from_here, |
154 Bind(&ObserverListThreadSafe<ObserverType>::NotifyWrapper, | 154 BindOnce(&ObserverListThreadSafe<ObserverType>::NotifyWrapper, this, |
155 this, context, method)); | 155 context, method)); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
159 private: | 159 private: |
160 friend class RefCountedThreadSafe<ObserverListThreadSafe<ObserverType>>; | 160 friend class RefCountedThreadSafe<ObserverListThreadSafe<ObserverType>>; |
161 | 161 |
162 struct ObserverListContext { | 162 struct ObserverListContext { |
163 explicit ObserverListContext(NotificationType type) | 163 explicit ObserverListContext(NotificationType type) |
164 : task_runner(ThreadTaskRunnerHandle::Get()), list(type) {} | 164 : task_runner(ThreadTaskRunnerHandle::Get()), list(type) {} |
165 | 165 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 observer_lists_; | 219 observer_lists_; |
220 | 220 |
221 const NotificationType type_; | 221 const NotificationType type_; |
222 | 222 |
223 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); | 223 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); |
224 }; | 224 }; |
225 | 225 |
226 } // namespace base | 226 } // namespace base |
227 | 227 |
228 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ | 228 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ |
OLD | NEW |