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

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: 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..4a0ab9a451c932cfee0d102a7db5120c35630673 100644
--- a/base/memory/weak_ptr_unittest.cc
+++ b/base/memory/weak_ptr_unittest.cc
@@ -432,48 +432,44 @@ TEST(WeakPtrTest, OwnerThreadDeletesObject) {
background.DeleteArrow(arrow_copy);
}
-TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtr) {
+TEST(WeakPtrTest, NonOwnerThreadCanDeleteWeakPtr) {
// 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();
- }
- // Background can copy and assign arrow (as well as the WeakPtr inside).
+ Arrow* arrow = new Arrow();
+ arrow->target = target.AsWeakPtr();
+
+ // Background can delete arrow (as well as the WeakPtr inside).
BackgroundThread background;
background.Start();
- background.CopyAndAssignArrow(arrow);
+ background.DeleteArrow(arrow);
}
-TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtrBase) {
+TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtr) {
jar (doing other things) 2013/06/10 03:32:41 Why did you move the two test methods down (below
akalin 2013/06/10 17:58:21 I think that's the logical order of the tests, sin
// 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();
- }
- // Background can copy and assign arrow's WeakPtr to a base class WeakPtr.
+ 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.CopyAndAssignArrowBase(arrow);
+ background.CopyAndAssignArrow(arrow);
+ background.DeleteArrow(arrow);
}
-TEST(WeakPtrTest, NonOwnerThreadCanDeleteWeakPtr) {
+TEST(WeakPtrTest, NonOwnerThreadCanCopyAndAssignWeakPtrBase) {
// Main thread creates a Target object.
Target target;
// Main thread creates an arrow referencing the Target.
- Arrow* arrow = new Arrow();
+ Arrow *arrow = new Arrow();
arrow->target = target.AsWeakPtr();
- // Background can delete arrow (as well as the WeakPtr inside).
+ // Background can copy and assign arrow's WeakPtr to a base class WeakPtr.
BackgroundThread background;
background.Start();
+ background.CopyAndAssignArrowBase(arrow);
background.DeleteArrow(arrow);
}
« 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