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

Unified Diff: base/observer_list_threadsafe.h

Issue 6198003: Add workaround for VS2005 compile error introduced by r70933 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed windows compile failure Created 9 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698