diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-19 20:34:18 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-19 20:34:18 +0000 |
commit | 359d2bf31d2edc43a9ca8b08ee07707038efce09 (patch) | |
tree | 10bf00aa3964c73a37bae063a349bd496010ed4b /base/tracked_objects.cc | |
parent | 1da05ebbe6301142de46ef7cb100b6cc5aaa38c2 (diff) | |
download | chromium_src-359d2bf31d2edc43a9ca8b08ee07707038efce09.zip chromium_src-359d2bf31d2edc43a9ca8b08ee07707038efce09.tar.gz chromium_src-359d2bf31d2edc43a9ca8b08ee07707038efce09.tar.bz2 |
Reland 66791 (change was innocent)
Revert 66719 - Reland r65996. Disallows Singletons on non-joinable thread.
Test breakages caused by this change have been fixed here or in other changelists.
BUG=61753
TEST=none
Review URL: http://codereview.chromium.org/5024003
TBR=willchan@chromium.org
Review URL: http://codereview.chromium.org/5206005
TBR=willchan@chromium.org
Review URL: http://codereview.chromium.org/5242002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66808 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/tracked_objects.cc')
-rw-r--r-- | base/tracked_objects.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/base/tracked_objects.cc b/base/tracked_objects.cc index 4631f34..9db25ff 100644 --- a/base/tracked_objects.cc +++ b/base/tracked_objects.cc @@ -10,6 +10,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/thread_restrictions.h" using base::TimeDelta; @@ -89,7 +90,13 @@ Lock ThreadData::list_lock_; // static ThreadData::Status ThreadData::status_ = ThreadData::UNINITIALIZED; -ThreadData::ThreadData() : next_(NULL), message_loop_(MessageLoop::current()) {} +ThreadData::ThreadData() : next_(NULL) { + // This shouldn't use the MessageLoop::current() LazyInstance since this might + // be used on a non-joinable thread. + // http://crbug.com/62728 + base::ThreadRestrictions::ScopedAllowSingleton scoped_allow_singleton; + message_loop_ = MessageLoop::current(); +} ThreadData::~ThreadData() {} @@ -260,8 +267,14 @@ void ThreadData::WriteHTMLTotalAndSubtotals( } Births* ThreadData::TallyABirth(const Location& location) { - if (!message_loop_) // In case message loop wasn't yet around... - message_loop_ = MessageLoop::current(); // Find it now. + { + // This shouldn't use the MessageLoop::current() LazyInstance since this + // might be used on a non-joinable thread. + // http://crbug.com/62728 + base::ThreadRestrictions::ScopedAllowSingleton scoped_allow_singleton; + if (!message_loop_) // In case message loop wasn't yet around... + message_loop_ = MessageLoop::current(); // Find it now. + } BirthMap::iterator it = birth_map_.find(location); if (it != birth_map_.end()) { @@ -279,8 +292,12 @@ Births* ThreadData::TallyABirth(const Location& location) { void ThreadData::TallyADeath(const Births& lifetimes, const TimeDelta& duration) { - if (!message_loop_) // In case message loop wasn't yet around... - message_loop_ = MessageLoop::current(); // Find it now. + { + // http://crbug.com/62728 + base::ThreadRestrictions::ScopedAllowSingleton scoped_allow_singleton; + if (!message_loop_) // In case message loop wasn't yet around... + message_loop_ = MessageLoop::current(); // Find it now. + } DeathMap::iterator it = death_map_.find(&lifetimes); if (it != death_map_.end()) { |