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

Unified Diff: base/task.h

Issue 248021: Reverting 27379. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 3 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 | « base/ref_counted.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task.h
===================================================================
--- base/task.h (revision 27386)
+++ base/task.h (working copy)
@@ -205,33 +205,12 @@
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 @@
// 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 @@
private:
void ReleaseCallee() {
if (obj_) {
- traits_.ReleaseCallee(obj_);
+ RunnableMethodTraits<T>::ReleaseCallee(obj_);
obj_ = NULL;
}
}
@@ -292,7 +271,6 @@
T* obj_;
Method meth_;
Params params_;
- RunnableMethodTraits<T> traits_;
};
template <class T, class Method>
« no previous file with comments | « base/ref_counted.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698