From 7c87290fed96e7620b3702bc9435db6bc957d92c Mon Sep 17 00:00:00 2001 From: "jamesr@chromium.org" Date: Wed, 2 Dec 2009 01:44:30 +0000 Subject: Tries to catch callbacks expecting scoped_refptr 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 --- base/task.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'base/task.h') 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::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::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::value), + badrunnablefunctionparams); } ~RunnableFunction() { @@ -642,7 +649,10 @@ typename Callback5::Type* NewCallback( template class UnboundMethod { public: - UnboundMethod(Method m, Params p) : m_(m), p_(p) {} + UnboundMethod(Method m, Params p) : m_(m), p_(p) { + COMPILE_ASSERT((MethodUsesScopedRefptrCorrectly::value), + badunboundmethodparams); + } void Run(T* obj) const { DispatchToMethod(obj, m_, p_); } -- cgit v1.1