From 359e88bc6b5c70a789b0f5bea155954f0660a232 Mon Sep 17 00:00:00 2001 From: "senorblanco@chromium.org" Date: Mon, 28 Sep 2009 19:21:41 +0000 Subject: 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 --- base/message_pump_glib_unittest.cc | 4 ++-- base/ref_counted.h | 4 ---- base/task.h | 34 ++++++---------------------------- 3 files changed, 8 insertions(+), 34 deletions(-) (limited to 'base') 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 { - 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 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 RunnableMethod : public CancelableTask { +class RunnableMethod : public CancelableTask, + public RunnableMethodTraits { 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::ReleaseCallee(obj_); obj_ = NULL; } } @@ -292,7 +271,6 @@ class RunnableMethod : public CancelableTask { T* obj_; Method meth_; Params params_; - RunnableMethodTraits traits_; }; template -- cgit v1.1