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 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 class ObserverListThreadSafe; | 60 class ObserverListThreadSafe; |
61 | 61 |
62 namespace internal { | 62 namespace internal { |
63 | 63 |
64 // An UnboundMethod is a wrapper for a method where the actual object is | 64 // An UnboundMethod is a wrapper for a method where the actual object is |
65 // provided at Run dispatch time. | 65 // provided at Run dispatch time. |
66 template <class T, class Method, class Params> | 66 template <class T, class Method, class Params> |
67 class UnboundMethod { | 67 class UnboundMethod { |
68 public: | 68 public: |
69 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { | 69 UnboundMethod(Method m, const Params& p) : m_(m), p_(p) { |
70 COMPILE_ASSERT( | 70 static_assert((internal::ParamsUseScopedRefptrCorrectly<Params>::value), |
71 (internal::ParamsUseScopedRefptrCorrectly<Params>::value), | 71 "bad unbound method params"); |
72 badunboundmethodparams); | |
73 } | 72 } |
74 void Run(T* obj) const { | 73 void Run(T* obj) const { |
75 DispatchToMethod(obj, m_, p_); | 74 DispatchToMethod(obj, m_, p_); |
76 } | 75 } |
77 private: | 76 private: |
78 Method m_; | 77 Method m_; |
79 Params p_; | 78 Params p_; |
80 }; | 79 }; |
81 | 80 |
82 } // namespace internal | 81 } // namespace internal |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 mutable Lock list_lock_; // Protects the observer_lists_. | 263 mutable Lock list_lock_; // Protects the observer_lists_. |
265 ObserversListMap observer_lists_; | 264 ObserversListMap observer_lists_; |
266 const NotificationType type_; | 265 const NotificationType type_; |
267 | 266 |
268 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); | 267 DISALLOW_COPY_AND_ASSIGN(ObserverListThreadSafe); |
269 }; | 268 }; |
270 | 269 |
271 } // namespace base | 270 } // namespace base |
272 | 271 |
273 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ | 272 #endif // BASE_OBSERVER_LIST_THREADSAFE_H_ |
OLD | NEW |