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

Unified Diff: base/bind_unittest.cc

Issue 698493003: Test Bind protection for raw pointers of ref-counted types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | 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 a30b7756704658a599a84e3df88e80166e731ce7..669e7546bcf775f76dc68238ee479782f8236b4f 100644
--- a/base/bind_unittest.cc
+++ b/base/bind_unittest.cc
@@ -786,6 +786,28 @@ TEST_F(BindTest, ArgumentCopies) {
EXPECT_EQ(0, assigns);
}
+// Test using lambdas with Bind
+struct Dummy {};
+struct RefcountedClass;
+void Func1(RefcountedClass*, Dummy*) {}
+void Func2(Dummy*, RefcountedClass*) {}
+struct RefcountedClass : public base::RefCounted<RefcountedClass> {
+ void TryStuffWithThis() {
+ scoped_refptr<RefcountedClass> refcounted_object;
+ Dummy d;
+ base::Closure c;
+ c = base::Bind(&Func1,
+ this,
+ base::Unretained(&d));
+ c = base::Bind(&Func2,
+ base::Unretained(&d),
+ this);
+ }
+ private:
+ friend class base::RefCounted<RefcountedClass>;
+ ~RefcountedClass() {}
+};
+
// Callback construction and assignment tests.
// - Construction from an InvokerStorageHolder should not cause ref/deref.
// - Assignment from other callback should only cause one ref
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698