From 7d550fa06fba0db3c9a036e4554c6adc0b53953a Mon Sep 17 00:00:00 2001 From: "ajwong@chromium.org" Date: Thu, 23 Jun 2011 23:20:39 +0000 Subject: Remove default initializtion of BirthPlace in Tracked. Previously, MessageLoop::PostTask set the BirthPlace of the Task object (subclass of Tracked), which would decrement the counter for the Location("NoFunctionName", "NeedToSetBirthPlace", -1) Birth, and replace it with a more appropriate Location provided by the FROM_HERE argument. With the MessageLoop restructuring in r82300, tracking of Births is moved up from the Task object into the MessageLoop::PendingTask structure. The side-effect is that the default birth is never decremented, and we double count each task's creation. This default Birth is effectively a count of "tasks that were created, but not posted" without a stored reference to location, so removing it is the simplest fix to the double counting. BUG=none TEST=about:tasks looks sane. Review URL: http://codereview.chromium.org/7029038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90290 0039d316-1c4b-4281-b951-d872f2087c98 --- base/tracked_objects_unittest.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'base/tracked_objects_unittest.cc') diff --git a/base/tracked_objects_unittest.cc b/base/tracked_objects_unittest.cc index ab615da..e7d07a7 100644 --- a/base/tracked_objects_unittest.cc +++ b/base/tracked_objects_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -60,10 +60,12 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) { return; // Instigate tracking on a single tracked object, or our thread. + const Location& location = FROM_HERE; NoopTracked tracked; + tracked.SetBirthPlace(location); const ThreadData* data = ThreadData::first(); - EXPECT_TRUE(data); + ASSERT_TRUE(data); EXPECT_TRUE(!data->next()); EXPECT_EQ(data, ThreadData::current()); ThreadData::BirthMap birth_map; @@ -76,7 +78,9 @@ TEST_F(TrackedObjectsTest, TinyStartupShutdown) { // Now instigate a birth, and a death. - delete new NoopTracked; + NoopTracked* new_tracked = new NoopTracked; + new_tracked->SetBirthPlace(location); + delete new_tracked; birth_map.clear(); data->SnapshotBirthMap(&birth_map); -- cgit v1.1