summaryrefslogtreecommitdiffstats
path: root/base/task.h
diff options
context:
space:
mode:
authorjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 01:44:30 +0000
committerjamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-02 01:44:30 +0000
commit7c87290fed96e7620b3702bc9435db6bc957d92c (patch)
tree43b6be5e45147a6ebc641012da2444446e6f74f3 /base/task.h
parent4559a7d9c3eca928fc19b64b64f19c8032d0ee0f (diff)
downloadchromium_src-7c87290fed96e7620b3702bc9435db6bc957d92c.zip
chromium_src-7c87290fed96e7620b3702bc9435db6bc957d92c.tar.gz
chromium_src-7c87290fed96e7620b3702bc9435db6bc957d92c.tar.bz2
Tries to catch callbacks expecting scoped_refptr<T> and getting T* using template magic
Review URL: http://codereview.chromium.org/414024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33531 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/task.h')
-rw-r--r--base/task.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/base/task.h b/base/task.h
index 0fb144b..7c2f393 100644
--- a/base/task.h
+++ b/base/task.h
@@ -6,6 +6,7 @@
#define BASE_TASK_H_
#include "base/non_thread_safe.h"
+#include "base/raw_scoped_refptr_mismatch_checker.h"
#include "base/tracked.h"
#include "base/tuple.h"
#include "base/weak_ptr.h"
@@ -140,6 +141,8 @@ class ScopedRunnableMethodFactory {
: obj_(obj),
meth_(meth),
params_(params) {
+ COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value),
+ badscopedrunnablemethodparams);
}
virtual void Run() {
@@ -273,6 +276,8 @@ class RunnableMethod : public CancelableTask {
RunnableMethod(T* obj, Method meth, const Params& params)
: obj_(obj), meth_(meth), params_(params) {
traits_.RetainCallee(obj_);
+ COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value),
+ badrunnablemethodparams);
}
~RunnableMethod() {
@@ -383,6 +388,8 @@ class RunnableFunction : public CancelableTask {
public:
RunnableFunction(Function function, const Params& params)
: function_(function), params_(params) {
+ COMPILE_ASSERT((FunctionUsesScopedRefptrCorrectly<Function, Params>::value),
+ badrunnablefunctionparams);
}
~RunnableFunction() {
@@ -642,7 +649,10 @@ typename Callback5<Arg1, Arg2, Arg3, Arg4, Arg5>::Type* NewCallback(
template <class T, class Method, class Params>
class UnboundMethod {
public:
- UnboundMethod(Method m, Params p) : m_(m), p_(p) {}
+ UnboundMethod(Method m, Params p) : m_(m), p_(p) {
+ COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly<Method, Params>::value),
+ badunboundmethodparams);
+ }
void Run(T* obj) const {
DispatchToMethod(obj, m_, p_);
}