| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ |
| 6 #define CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ | 6 #define CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 typedef typename EventTraits::EventType EventType; | 98 typedef typename EventTraits::EventType EventType; |
| 99 typedef EventListener<EventType> Listener; | 99 typedef EventListener<EventType> Listener; |
| 100 | 100 |
| 101 protected: | 101 protected: |
| 102 typedef std::map<Listener*, bool> Listeners; | 102 typedef std::map<Listener*, bool> Listeners; |
| 103 typedef PThreadScopedLock<PThreadMutex> ScopedListenersLock; | 103 typedef PThreadScopedLock<PThreadMutex> ScopedListenersLock; |
| 104 | 104 |
| 105 public: | 105 public: |
| 106 // The shutdown event gets send in the EventChannel's destructor. | 106 // The shutdown event gets send in the EventChannel's destructor. |
| 107 explicit EventChannel(const EventType& shutdown_event) | 107 explicit EventChannel(const EventType& shutdown_event) |
| 108 : callback_waiters_(NULL), shutdown_event_(shutdown_event), | 108 : current_listener_callback_(NULL), |
| 109 current_listener_callback_(NULL) { | 109 callback_waiters_(NULL), |
| 110 shutdown_event_(shutdown_event) { |
| 110 } | 111 } |
| 111 | 112 |
| 112 ~EventChannel() { | 113 ~EventChannel() { |
| 113 // Tell all the listeners that the channel is being deleted. | 114 // Tell all the listeners that the channel is being deleted. |
| 114 NotifyListeners(shutdown_event_); | 115 NotifyListeners(shutdown_event_); |
| 115 | 116 |
| 116 // Make sure all the listeners have been disconnected. Otherwise, they | 117 // Make sure all the listeners have been disconnected. Otherwise, they |
| 117 // will try to call RemoveListener() at a later date. | 118 // will try to call RemoveListener() at a later date. |
| 118 #ifdef DEBUG | 119 #ifdef DEBUG |
| 119 ScopedListenersLock lock(&listeners_mutex_); | 120 ScopedListenersLock lock(&listeners_mutex_); |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 CallbackObject* cbobject, | 332 CallbackObject* cbobject, |
| 332 CallbackMethod cbmethod, | 333 CallbackMethod cbmethod, |
| 333 CallbackArg0 arg0) { | 334 CallbackArg0 arg0) { |
| 334 return new ArgHookup<EventChannel, | 335 return new ArgHookup<EventChannel, |
| 335 typename EventChannel::EventTraits, | 336 typename EventChannel::EventTraits, |
| 336 CallbackObject, CallbackMethod, CallbackArg0>(channel, cbobject, | 337 CallbackObject, CallbackMethod, CallbackArg0>(channel, cbobject, |
| 337 cbmethod, arg0); | 338 cbmethod, arg0); |
| 338 } | 339 } |
| 339 | 340 |
| 340 #endif // CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ | 341 #endif // CHROME_BROWSER_SYNC_UTIL_EVENT_SYS_INL_H_ |
| OLD | NEW |