summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/ref_counted.h2
-rw-r--r--base/ref_counted_unittest.cc16
2 files changed, 17 insertions, 1 deletions
diff --git a/base/ref_counted.h b/base/ref_counted.h
index a1e7bb4..2268808 100644
--- a/base/ref_counted.h
+++ b/base/ref_counted.h
@@ -222,7 +222,7 @@ class scoped_refptr {
swap(&r.ptr_);
}
- private:
+ protected:
T* ptr_;
};
diff --git a/base/ref_counted_unittest.cc b/base/ref_counted_unittest.cc
index 724c64f..ba392d6 100644
--- a/base/ref_counted_unittest.cc
+++ b/base/ref_counted_unittest.cc
@@ -5,9 +5,22 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "base/ref_counted.h"
+namespace {
+
class SelfAssign : public base::RefCounted<SelfAssign> {
};
+class CheckDerivedMemberAccess : public scoped_refptr<SelfAssign> {
+ public:
+ CheckDerivedMemberAccess() {
+ // This shouldn't compile if we don't have access to the member variable.
+ SelfAssign** pptr = &ptr_;
+ EXPECT_EQ(*pptr, ptr_);
+ }
+};
+
+} // end namespace
+
TEST(RefCountedUnitTest, TestSelfAssignment) {
SelfAssign* p = new SelfAssign;
scoped_refptr<SelfAssign> var = p;
@@ -15,3 +28,6 @@ TEST(RefCountedUnitTest, TestSelfAssignment) {
EXPECT_EQ(var.get(), p);
}
+TEST(RefCountedUnitTest, ScopedRefPtrMemberAccess) {
+ CheckDerivedMemberAccess check;
+}