diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 19:21:41 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-28 19:21:41 +0000 |
commit | 359e88bc6b5c70a789b0f5bea155954f0660a232 (patch) | |
tree | 8c2114ff268739901f213e2a052bb50e04da8272 /base | |
parent | 27b51d38027a9927cdc8bc0c8d7eef1d1bcb7108 (diff) | |
download | chromium_src-359e88bc6b5c70a789b0f5bea155954f0660a232.zip chromium_src-359e88bc6b5c70a789b0f5bea155954f0660a232.tar.gz chromium_src-359e88bc6b5c70a789b0f5bea155954f0660a232.tar.bz2 |
Reverting 27379, in hopes of fixing browser_tests.
TBR=darin
Review URL: http://codereview.chromium.org/248021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27389 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/message_pump_glib_unittest.cc | 4 | ||||
-rw-r--r-- | base/ref_counted.h | 4 | ||||
-rw-r--r-- | base/task.h | 34 |
3 files changed, 8 insertions, 34 deletions
diff --git a/base/message_pump_glib_unittest.cc b/base/message_pump_glib_unittest.cc index e3a04e8..e0ad260 100644 --- a/base/message_pump_glib_unittest.cc +++ b/base/message_pump_glib_unittest.cc @@ -185,8 +185,8 @@ class MessagePumpGLibTest : public testing::Test { // This lets us call NewRunnableMethod on EventInjector instances. template<> struct RunnableMethodTraits<EventInjector> { - void RetainCallee(EventInjector* obj) { } - void ReleaseCallee(EventInjector* obj) { } + static void RetainCallee(EventInjector* obj) { } + static void ReleaseCallee(EventInjector* obj) { } }; TEST_F(MessagePumpGLibTest, TestQuit) { diff --git a/base/ref_counted.h b/base/ref_counted.h index 70536b9..097d16e 100644 --- a/base/ref_counted.h +++ b/base/ref_counted.h @@ -14,8 +14,6 @@ namespace subtle { class RefCountedBase { public: - static bool ImplementsThreadSafeReferenceCounting() { return false; } - bool HasOneRef() const { return ref_count_ == 1; } protected: @@ -40,8 +38,6 @@ class RefCountedBase { class RefCountedThreadSafeBase { public: - static bool ImplementsThreadSafeReferenceCounting() { return true; } - bool HasOneRef() const; protected: diff --git a/base/task.h b/base/task.h index e9da8b3..c827681 100644 --- a/base/task.h +++ b/base/task.h @@ -205,33 +205,12 @@ class ReleaseTask : public CancelableTask { template <class T> struct RunnableMethodTraits { - RunnableMethodTraits() { -#ifndef NDEBUG - origin_thread_id_ = PlatformThread::CurrentId(); -#endif - } - - ~RunnableMethodTraits() { -#ifndef NDEBUG - // If destroyed on a separate thread, then we had better have been using - // thread-safe reference counting! - if (origin_thread_id_ != PlatformThread::CurrentId()) - DCHECK(T::ImplementsThreadSafeReferenceCounting()); -#endif - } - - void RetainCallee(T* obj) { + static void RetainCallee(T* obj) { obj->AddRef(); } - - void ReleaseCallee(T* obj) { + static void ReleaseCallee(T* obj) { obj->Release(); } - - private: -#ifndef NDEBUG - PlatformThreadId origin_thread_id_; -#endif }; // RunnableMethod and RunnableFunction ----------------------------------------- @@ -261,13 +240,13 @@ struct RunnableMethodTraits { // RunnableMethod and NewRunnableMethod implementation ------------------------- template <class T, class Method, class Params> -class RunnableMethod : public CancelableTask { +class RunnableMethod : public CancelableTask, + public RunnableMethodTraits<T> { public: RunnableMethod(T* obj, Method meth, const Params& params) : obj_(obj), meth_(meth), params_(params) { - traits_.RetainCallee(obj_); + RetainCallee(obj_); } - ~RunnableMethod() { ReleaseCallee(); } @@ -284,7 +263,7 @@ class RunnableMethod : public CancelableTask { private: void ReleaseCallee() { if (obj_) { - traits_.ReleaseCallee(obj_); + RunnableMethodTraits<T>::ReleaseCallee(obj_); obj_ = NULL; } } @@ -292,7 +271,6 @@ class RunnableMethod : public CancelableTask { T* obj_; Method meth_; Params params_; - RunnableMethodTraits<T> traits_; }; template <class T, class Method> |