Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: base/observer_list_threadsafe.h

Issue 2023243002: Remove base::Tuple (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint fix Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/bind_internal.h ('k') | base/tuple.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <tuple>
10 11
11 #include "base/bind.h" 12 #include "base/bind.h"
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/single_thread_task_runner.h" 19 #include "base/single_thread_task_runner.h"
19 #include "base/stl_util.h" 20 #include "base/stl_util.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 171
171 // Notify methods. 172 // Notify methods.
172 // Make a thread-safe callback to each Observer in the list. 173 // Make a thread-safe callback to each Observer in the list.
173 // Note, these calls are effectively asynchronous. You cannot assume 174 // Note, these calls are effectively asynchronous. You cannot assume
174 // that at the completion of the Notify call that all Observers have 175 // that at the completion of the Notify call that all Observers have
175 // been Notified. The notification may still be pending delivery. 176 // been Notified. The notification may still be pending delivery.
176 template <class Method, class... Params> 177 template <class Method, class... Params>
177 void Notify(const tracked_objects::Location& from_here, 178 void Notify(const tracked_objects::Location& from_here,
178 Method m, 179 Method m,
179 const Params&... params) { 180 const Params&... params) {
180 internal::UnboundMethod<ObserverType, Method, Tuple<Params...>> method( 181 internal::UnboundMethod<ObserverType, Method, std::tuple<Params...>> method(
181 m, MakeTuple(params...)); 182 m, std::make_tuple(params...));
182 183
183 AutoLock lock(list_lock_); 184 AutoLock lock(list_lock_);
184 for (const auto& entry : observer_lists_) { 185 for (const auto& entry : observer_lists_) {
185 ObserverListContext* context = entry.second; 186 ObserverListContext* context = entry.second;
186 context->task_runner->PostTask( 187 context->task_runner->PostTask(
187 from_here, 188 from_here,
188 Bind(&ObserverListThreadSafe<ObserverType>::template NotifyWrapper< 189 Bind(&ObserverListThreadSafe<ObserverType>::template NotifyWrapper<
189 Method, Tuple<Params...>>, 190 Method, std::tuple<Params...>>,
190 this, context, method)); 191 this, context, method));
191 } 192 }
192 } 193 }
193 194
194 private: 195 private:
195 // See comment above ObserverListThreadSafeTraits' definition. 196 // See comment above ObserverListThreadSafeTraits' definition.
196 friend struct ObserverListThreadSafeTraits<ObserverType>; 197 friend struct ObserverListThreadSafeTraits<ObserverType>;
197 198
198 struct ObserverListContext { 199 struct ObserverListContext {
199 explicit ObserverListContext(NotificationType type) 200 explicit ObserverListContext(NotificationType type)
200 : task_runner(ThreadTaskRunnerHandle::Get()), list(type) {} 201 : task_runner(ThreadTaskRunnerHandle::Get()), list(type) {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 mutable Lock list_lock_; // Protects the observer_lists_. 264 mutable Lock list_lock_; // Protects the observer_lists_.
264 ObserversListMap observer_lists_; 265 ObserversListMap observer_lists_;
265 const NotificationType type_; 266 const NotificationType type_;
266 267
267 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); 268 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe);
268 }; 269 };
269 270
270 } // namespace base 271 } // namespace base
271 272
272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ 273 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_
OLDNEW
« no previous file with comments | « base/bind_internal.h ('k') | base/tuple.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698