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

Unified Diff: third_party/WebKit/Source/wtf/RefPtrTest.cpp

Issue 2696703008: Adds RefPtr::leakRef method to allow raw pointers that prevent destruct. (Closed)
Patch Set: Added deref in RefPtrTest.LeakRef to avoid memory leak. Created 3 years, 10 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 | « third_party/WebKit/Source/wtf/RefPtr.h ('k') | third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/RefPtrTest.cpp
diff --git a/third_party/WebKit/Source/wtf/RefPtrTest.cpp b/third_party/WebKit/Source/wtf/RefPtrTest.cpp
index e823520ef3d932f78a224807c6e501ac6f25c0f6..9e0975a3ecb94720d8068926820d4760c9361378 100644
--- a/third_party/WebKit/Source/wtf/RefPtrTest.cpp
+++ b/third_party/WebKit/Source/wtf/RefPtrTest.cpp
@@ -19,6 +19,19 @@ TEST(RefPtrTest, Basic) {
EXPECT_TRUE(!string);
}
+TEST(RefPtrTest, LeakRef) {
+ RefPtr<StringImpl> string = StringImpl::create("test");
+ EXPECT_TRUE(string);
+ EXPECT_TRUE(string->hasOneRef());
+ StringImpl* raw = string.get();
+ StringImpl* leaked = string.leakRef();
+ EXPECT_TRUE(!string);
+ EXPECT_TRUE(leaked);
+ EXPECT_TRUE(leaked->hasOneRef());
+ EXPECT_EQ(raw, leaked);
+ leaked->deref();
Bugs Nash 2017/02/20 01:53:38 Needed to add this line to prevent memory leak whi
+}
+
TEST(RefPtrTest, MoveAssignmentOperator) {
RefPtr<StringImpl> a = StringImpl::create("a");
RefPtr<StringImpl> b = StringImpl::create("b");
« no previous file with comments | « third_party/WebKit/Source/wtf/RefPtr.h ('k') | third_party/WebKit/Source/wtf/text/AtomicStringTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698