diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 23:20:39 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 23:20:39 +0000 |
commit | 7d550fa06fba0db3c9a036e4554c6adc0b53953a (patch) | |
tree | d0bc576896754f05f59495df8088f0a7bf4c0bea /base | |
parent | c594137d5eb27a988d98dede8ff9a920f25733de (diff) | |
download | chromium_src-7d550fa06fba0db3c9a036e4554c6adc0b53953a.zip chromium_src-7d550fa06fba0db3c9a036e4554c6adc0b53953a.tar.gz chromium_src-7d550fa06fba0db3c9a036e4554c6adc0b53953a.tar.bz2 |
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
Diffstat (limited to 'base')
-rw-r--r-- | base/tracked.cc | 3 | ||||
-rw-r--r-- | base/tracked_objects_unittest.cc | 10 |
2 files changed, 7 insertions, 6 deletions
diff --git a/base/tracked.cc b/base/tracked.cc index 0a246ae..08c38a7 100644 --- a/base/tracked.cc +++ b/base/tracked.cc @@ -107,9 +107,6 @@ void Tracked::ResetBirthTime() {} Tracked::Tracked() : tracked_births_(NULL), tracked_birth_time_(TimeTicks::Now()) { - if (!ThreadData::IsActive()) - return; - SetBirthPlace(Location("NoFunctionName", "NeedToSetBirthPlace", -1, NULL)); } Tracked::~Tracked() { 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); |