Index: base/observer_list_threadsafe.h |
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h |
index 6085fde74ba9093ec59edf38e53c4f57eb65f7db..ecdad90ccebc20e4ab685b7f46aa3375587a72fc 100644 |
--- a/base/observer_list_threadsafe.h |
+++ b/base/observer_list_threadsafe.h |
@@ -49,9 +49,32 @@ |
// will notify its regular ObserverList. |
// |
/////////////////////////////////////////////////////////////////////////////// |
+ |
+// Forward declaration for ObserverListThreadSafeTraits. |
+template <class ObserverType> |
+class ObserverListThreadSafe; |
+ |
+// This class is used to work around VS2005 not accepting: |
+// |
+// friend class |
+// base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> >; |
+// |
+// Instead of friending the class, we could friend the actual function |
+// which calls delete. However, this ends up being |
+// RefCountedThreadSafe::DeleteInternal(), which is private. So we |
+// define our own templated traits class so we can friend it. |
+template <class T> |
+struct ObserverListThreadSafeTraits { |
+ static void Destruct(const ObserverListThreadSafe<T>* x) { |
+ delete x; |
+ } |
+}; |
+ |
template <class ObserverType> |
class ObserverListThreadSafe |
- : public base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> > { |
+ : public base::RefCountedThreadSafe< |
+ ObserverListThreadSafe<ObserverType>, |
+ ObserverListThreadSafeTraits<ObserverType> > { |
public: |
typedef typename ObserverList<ObserverType>::NotificationType |
NotificationType; |
@@ -130,8 +153,9 @@ class ObserverListThreadSafe |
// TODO(mbelshe): Add more wrappers for Notify() with more arguments. |
private: |
- friend class |
- base::RefCountedThreadSafe<ObserverListThreadSafe<ObserverType> >; |
+ // See comment above ObserverListThreadSafeTraits' definition. |
+ friend struct ObserverListThreadSafeTraits<ObserverType>; |
+ |
~ObserverListThreadSafe() { |
typename ObserversListMap::const_iterator it; |
for (it = observer_lists_.begin(); it != observer_lists_.end(); ++it) |