summaryrefslogtreecommitdiffstats
path: root/base/bind_unittest.cc
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 06:31:41 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 06:31:41 +0000
commit8217d454b2f96847028e9b0dbe7d82d66959ecb4 (patch)
treefc6ff9f433b1f09b56c54421d625c410bdac4882 /base/bind_unittest.cc
parent63a2ecf084a9f13418e100cca6689925bc9dfe96 (diff)
downloadchromium_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_unittest.cc')
-rw-r--r--base/bind_unittest.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index 0c24710..648096d 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -15,6 +15,8 @@ using ::testing::StrictMock;
namespace base {
namespace {
+class IncompleteType;
+
class NoRef {
public:
NoRef() {}
@@ -362,6 +364,7 @@ TEST_F(BindTest, IgnoreReturn) {
// - Argument binding to a literal string.
// - Argument binding with template function.
// - Argument binding to an object.
+// - Argument binding to pointer to incomplete type.
// - Argument gets type converted.
// - Pointer argument gets converted.
// - Const Reference forces conversion.
@@ -391,6 +394,11 @@ TEST_F(BindTest, ArgumentBinding) {
Callback<int(void)> bind_object_cb = Bind(&UnwrapNoRefParent, p);
EXPECT_EQ(5, bind_object_cb.Run());
+ IncompleteType* incomplete_ptr = reinterpret_cast<IncompleteType*>(123);
+ Callback<IncompleteType*(void)> bind_incomplete_ptr_cb =
+ Bind(&PolymorphicIdentity<IncompleteType*>, incomplete_ptr);
+ EXPECT_EQ(incomplete_ptr, bind_incomplete_ptr_cb.Run());
+
NoRefChild c;
c.value = 6;
Callback<int(void)> bind_promotes_cb = Bind(&UnwrapNoRefParent, c);