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

Unified Diff: base/memory/weak_ptr_unittest.cc

Issue 15797010: Fix leak in WeakPtrTest::NonOwnerThreadCanCopyAndAssignWeakPtr{,Base} (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 years, 6 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/memory/weak_ptr_unittest.cc
diff --git a/base/memory/weak_ptr_unittest.cc b/base/memory/weak_ptr_unittest.cc
index 0a2724cb09ee9430b89b231a69372bd6e01e3a20..515df69e7b2f9caee89292abb5ce77a7a990fd18 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -436,32 +436,28 @@ TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtr) {
// Main thread creates a Target object.
Target target;
// Main thread creates an arrow referencing the Target.
- Arrow *arrow;
- {
- ANNOTATE_SCOPED_MEMORY_LEAK;
- arrow = new Arrow();
- arrow->target = target.AsWeakPtr();
- }
+ Arrow *arrow = new Arrow();
+ arrow->target = target.AsWeakPtr();
+
// Background can copy and assign arrow (as well as the WeakPtr inside).
BackgroundThread background;
background.Start();
background.CopyAndAssignArrow(arrow);
+ background.DeleteArrow(arrow);
}
TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtrBase) {
// Main thread creates a Target object.
Target target;
// Main thread creates an arrow referencing the Target.
- Arrow *arrow;
- {
- ANNOTATE_SCOPED_MEMORY_LEAK;
- arrow = new Arrow();
- arrow->target = target.AsWeakPtr();
- }
+ Arrow *arrow = new Arrow();
+ arrow->target = target.AsWeakPtr();
+
// Background can copy and assign arrow's WeakPtr to a base class WeakPtr.
BackgroundThread background;
background.Start();
background.CopyAndAssignArrowBase(arrow);
+ background.DeleteArrow(arrow);
}
TEST(WeakPtrTest, NonOwnerThreadCanDeleteWeakPtr) {
« 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