diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-11 21:19:54 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-11 21:19:54 +0000 |
commit | bf68712f715acb13506f3d017f5b29084bff948d (patch) | |
tree | 17f65ff75b064d6e7de1343c19220c5f6658f46a /base | |
parent | 1f790efdad37740608b44e6a96f9271fb8bfec6e (diff) | |
download | chromium_src-bf68712f715acb13506f3d017f5b29084bff948d.zip chromium_src-bf68712f715acb13506f3d017f5b29084bff948d.tar.gz chromium_src-bf68712f715acb13506f3d017f5b29084bff948d.tar.bz2 |
Add workaround for VS2005 compile error introduced by r70933
BUG=None
TEST=compiles on VS2005
Review URL: http://codereview.chromium.org/6198003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71081 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/observer_list_threadsafe.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/base/observer_list_threadsafe.h b/base/observer_list_threadsafe.h index 6085fde..ecdad90 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) |