Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2200)

Unified Diff: base/bind_unittest.cc

Issue 8171013: Support scoped_refptr<> as the object for a method call in base::Bind(). Reduce useless copies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/bind_helpers.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/bind_unittest.cc
diff --git a/base/bind_unittest.cc b/base/bind_unittest.cc
index 648096df781c00e196a7ddeaf75c63f528699c27..acaf5626f182dcc4e49c9088895ff5bb36c68f89 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -284,6 +284,7 @@ TEST_F(BindTest, CallbackBindMore) {
// - Normal function.
// - Normal function bound with non-refcounted first argument.
// - Method bound to non-const object.
+// - Method bound to scoped_refptr.
// - Const method bound to non-const object.
// - Const method bound to const object.
// - Derived classes can be used with pointers to non-virtual base functions.
@@ -291,9 +292,9 @@ TEST_F(BindTest, CallbackBindMore) {
// preserve virtual dispatch).
TEST_F(BindTest, FunctionTypeSupport) {
EXPECT_CALL(static_func_mock_, VoidMethod0());
- EXPECT_CALL(has_ref_, AddRef()).Times(3);
- EXPECT_CALL(has_ref_, Release()).Times(3);
- EXPECT_CALL(has_ref_, VoidMethod0());
+ EXPECT_CALL(has_ref_, AddRef()).Times(5);
+ EXPECT_CALL(has_ref_, Release()).Times(5);
+ EXPECT_CALL(has_ref_, VoidMethod0()).Times(2);
EXPECT_CALL(has_ref_, VoidConstMethod0()).Times(2);
Closure normal_cb = Bind(&VoidFunc0);
@@ -303,11 +304,14 @@ TEST_F(BindTest, FunctionTypeSupport) {
EXPECT_EQ(&no_ref_, normal_non_refcounted_cb.Run());
Closure method_cb = Bind(&HasRef::VoidMethod0, &has_ref_);
+ Closure method_refptr_cb = Bind(&HasRef::VoidMethod0,
+ make_scoped_refptr(&has_ref_));
Closure const_method_nonconst_obj_cb = Bind(&HasRef::VoidConstMethod0,
&has_ref_);
Closure const_method_const_obj_cb = Bind(&HasRef::VoidConstMethod0,
const_has_ref_ptr_);
method_cb.Run();
+ method_refptr_cb.Run();
const_method_nonconst_obj_cb.Run();
const_method_const_obj_cb.Run();
« no previous file with comments | « base/bind_helpers.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698