Skip to content

Commit

Permalink
Remove unused UnsafeBindtoRefCountedArg in bind_helpers.h
Browse files Browse the repository at this point in the history
BUG=554299

Review-Url: https://codereview.chromium.org/2106123002
Cr-Commit-Position: refs/heads/master@{#403113}
  • Loading branch information
tzik authored and Commit bot committed Jun 30, 2016
1 parent 9f4c1bf commit 11d33ea
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 80 deletions.
58 changes: 0 additions & 58 deletions base/bind_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,64 +240,6 @@ namespace internal {
//
// Works on gcc-4.2, gcc-4.4, and Visual Studio 2008.
//
// TODO(ajwong): Move to ref_counted.h or template_util.h when we've vetted
// this works well.
//
// TODO(ajwong): Make this check for Release() as well.
// See http://crbug.com/82038.
template <typename T>
class SupportsAddRefAndRelease {
using Yes = char[1];
using No = char[2];

struct BaseMixin {
void AddRef();
};

// MSVC warns when you try to use Base if T has a private destructor, the
// common pattern for refcounted types. It does this even though no attempt to
// instantiate Base is made. We disable the warning for this definition.
#if defined(OS_WIN)
#pragma warning(push)
#pragma warning(disable:4624)
#endif
struct Base : public T, public BaseMixin {
};
#if defined(OS_WIN)
#pragma warning(pop)
#endif

template <void(BaseMixin::*)()> struct Helper {};

template <typename C>
static No& Check(Helper<&C::AddRef>*);

template <typename >
static Yes& Check(...);

public:
enum { value = sizeof(Check<Base>(0)) == sizeof(Yes) };
};

// Helpers to assert that arguments of a recounted type are bound with a
// scoped_refptr.
template <bool IsClasstype, typename T>
struct UnsafeBindtoRefCountedArgHelper : std::false_type {
};

template <typename T>
struct UnsafeBindtoRefCountedArgHelper<true, T>
: std::integral_constant<bool, SupportsAddRefAndRelease<T>::value> {
};

template <typename T>
struct UnsafeBindtoRefCountedArg : std::false_type {
};

template <typename T>
struct UnsafeBindtoRefCountedArg<T*>
: UnsafeBindtoRefCountedArgHelper<std::is_class<T>::value, T> {
};

template <typename T>
class HasIsMethodTag {
Expand Down
22 changes: 0 additions & 22 deletions base/bind_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,28 +650,6 @@ TEST_F(BindTest, ArrayArgumentBinding) {
EXPECT_EQ(3, const_array_cb.Run());
}

// Verify SupportsAddRefAndRelease correctly introspects the class type for
// AddRef() and Release().
// - Class with AddRef() and Release()
// - Class without AddRef() and Release()
// - Derived Class with AddRef() and Release()
// - Derived Class without AddRef() and Release()
// - Derived Class with AddRef() and Release() and a private destructor.
TEST_F(BindTest, SupportsAddRefAndRelease) {
EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRef>::value);
EXPECT_FALSE(internal::SupportsAddRefAndRelease<NoRef>::value);

// StrictMock<T> is a derived class of T. So, we use StrictMock<HasRef> and
// StrictMock<NoRef> to test that SupportsAddRefAndRelease works over
// inheritance.
EXPECT_TRUE(internal::SupportsAddRefAndRelease<StrictMock<HasRef> >::value);
EXPECT_FALSE(internal::SupportsAddRefAndRelease<StrictMock<NoRef> >::value);

// This matters because the implementation creates a dummy class that
// inherits from the template type.
EXPECT_TRUE(internal::SupportsAddRefAndRelease<HasRefPrivateDtor>::value);
}

// Unretained() wrapper support.
// - Method bound to Unretained() non-const object.
// - Const method bound to Unretained() non-const object.
Expand Down

0 comments on commit 11d33ea

Please sign in to comment.