summaryrefslogtreecommitdiffstats
path: root/base/task.h
diff options
context:
space:
mode:
authorsenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 19:21:41 +0000
committersenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-28 19:21:41 +0000
commit359e88bc6b5c70a789b0f5bea155954f0660a232 (patch)
tree8c2114ff268739901f213e2a052bb50e04da8272 /base/task.h
parent27b51d38027a9927cdc8bc0c8d7eef1d1bcb7108 (diff)
downloadchromium_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/task.h')
-rw-r--r--base/task.h34
1 files changed, 6 insertions, 28 deletions
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>