diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-01 06:31:41 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-01 06:31:41 +0000 |
commit | 8217d454b2f96847028e9b0dbe7d82d66959ecb4 (patch) | |
tree | fc6ff9f433b1f09b56c54421d625c410bdac4882 /base/bind_internal.h.pump | |
parent | 63a2ecf084a9f13418e100cca6689925bc9dfe96 (diff) | |
download | chromium_src-8217d454b2f96847028e9b0dbe7d82d66959ecb4.zip chromium_src-8217d454b2f96847028e9b0dbe7d82d66959ecb4.tar.gz chromium_src-8217d454b2f96847028e9b0dbe7d82d66959ecb4.tar.bz2 |
Use NeedsScopedRefptrButGetsRawPtr instead of UnsafeBindtoRefCountedArg.
Will's implementation of NeedsScopedRefptrButGetsRawPtr checks for refcounting by testing for converability of the pointer values to base::RefCounted and base::RefCountedThreadsafe. This happens to tolerate incomplete types in a sane way on linux where the check is enabled.
UnsafeBindtoRefCountedArg's impelmentation relies on introspecting the type for the existence of a member function. Though this will catch refcounted objects with a refcount API that are not derived from base::RefCounted and base::RefCountedThreadsafe it requires complete types which places too strong of a constraint on what kinds of arguments can be bound.
Since the majority (all?) refcounted types in Chromium are derived from base::RefCounted and base::RefCountedThreadsafe, this should be just as good of a guarantee.
Bug filed to see if there's a way to adapt UnsafeBindtoRefCountedArg.
BUG=94995,98732
TEST=new unittest.
Review URL: http://codereview.chromium.org/8101008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103627 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/bind_internal.h.pump')
-rw-r--r-- | base/bind_internal.h.pump | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/base/bind_internal.h.pump b/base/bind_internal.h.pump index 532fe3d..429e13f 100644 --- a/base/bind_internal.h.pump +++ b/base/bind_internal.h.pump @@ -17,6 +17,7 @@ $var MAX_ARITY = 6 #include "base/bind_helpers.h" #include "base/callback_internal.h" +#include "base/memory/raw_scoped_refptr_mismatch_checker.h" #include "base/memory/weak_ptr.h" #include "base/template_util.h" #include "build/build_config.h" @@ -334,14 +335,16 @@ $if BOUND_ARG == 1 [[ // scoped_refptr check because the binder itself takes care of this. We also // disallow binding of an array as the method's target object. COMPILE_ASSERT(IsMethod::value || - !internal::UnsafeBindtoRefCountedArg<P$(BOUND_ARG)>::value, + internal::NeedsScopedRefptrButGetsRawPtr< + typename ParamTraits<P$(BOUND_ARG)>::StorageType>::value == 0, p$(BOUND_ARG)_is_refcounted_type_and_needs_scoped_refptr); COMPILE_ASSERT(!IsMethod::value || !is_array<P$(BOUND_ARG)>::value, first_bound_argument_to_method_cannot_be_array); ]] $else [[ - COMPILE_ASSERT(!internal::UnsafeBindtoRefCountedArg<P$(BOUND_ARG)>::value, - p$(BOUND_ARG)_is_refcounted_type_and_needs_scoped_refptr); + COMPILE_ASSERT(internal::NeedsScopedRefptrButGetsRawPtr< + typename ParamTraits<P$(BOUND_ARG)>::StorageType>::value == 0, + p$(BOUND_ARG)_is_refcounted_type_and_needs_scoped_refptr); ]] $$ $if BOUND_ARG ]] $$ $for BOUND_ARG |