diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 23:07:33 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-02 23:07:33 +0000 |
commit | f1165494135dce16afc85db6d77de295451ee12f (patch) | |
tree | 21b7a93e5dfebb7c65d8400f9a5e10bab823b264 /chrome/browser | |
parent | 9914b760ae181dac034bf16ec196097312199935 (diff) | |
download | chromium_src-f1165494135dce16afc85db6d77de295451ee12f.zip chromium_src-f1165494135dce16afc85db6d77de295451ee12f.tar.gz chromium_src-f1165494135dce16afc85db6d77de295451ee12f.tar.bz2 |
Revert 33611 - Fix leaking ExtensionMessageService in ProfileManagerTest.
BUG=28824
TEST=tools/valgrind/chrome_tests.sh t unit gtest_filter=ProfileManagerTest.CreateProfile
Review URL: http://codereview.chromium.org/455031
TBR=mattm@chromium.org
Review URL: http://codereview.chromium.org/458012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/extensions/extension_message_service.cc | 8 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_message_service.h | 3 | ||||
-rw-r--r-- | chrome/browser/profile_manager_unittest.cc | 4 |
3 files changed, 10 insertions, 5 deletions
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc index 5aaeb73..ae43bd6 100644 --- a/chrome/browser/extensions/extension_message_service.cc +++ b/chrome/browser/extensions/extension_message_service.cc @@ -115,6 +115,11 @@ ExtensionMessageService::ExtensionMessageService(Profile* profile) : profile_(profile), extension_devtools_manager_(NULL), next_port_id_(0) { + if (!ChromeThread::GetCurrentThreadIdentifier(&thread_id_)) { + // If we get created in unit test, GetCurrentThreadIdentifier fails. + // Assign thread_id_ to an ID not used. + thread_id_ = ChromeThread::ID_COUNT; + } registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, NotificationService::AllSources()); registrar_.Add(this, NotificationType::RENDERER_PROCESS_CLOSED, @@ -133,7 +138,8 @@ ExtensionMessageService::~ExtensionMessageService() { void ExtensionMessageService::ProfileDestroyed() { profile_ = NULL; if (!registrar_.IsEmpty()) { - CHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + if (thread_id_ != ChromeThread::ID_COUNT) + CHECK(ChromeThread::CurrentlyOn(thread_id_)); registrar_.RemoveAll(); } } diff --git a/chrome/browser/extensions/extension_message_service.h b/chrome/browser/extensions/extension_message_service.h index b04780c..a4c6037 100644 --- a/chrome/browser/extensions/extension_message_service.h +++ b/chrome/browser/extensions/extension_message_service.h @@ -198,6 +198,9 @@ class ExtensionMessageService // used on the IO thread or the UI thread. Lock next_port_id_lock_; + // The thread creating this object. Should be UI thread. + ChromeThread::ID thread_id_; + DISALLOW_COPY_AND_ASSIGN(ExtensionMessageService); }; diff --git a/chrome/browser/profile_manager_unittest.cc b/chrome/browser/profile_manager_unittest.cc index bd9e4d2..e38e68f 100644 --- a/chrome/browser/profile_manager_unittest.cc +++ b/chrome/browser/profile_manager_unittest.cc @@ -14,9 +14,6 @@ class ProfileManagerTest : public testing::Test { protected: - ProfileManagerTest() : ui_thread_(ChromeThread::UI, &message_loop_) { - } - virtual void SetUp() { // Name a subdirectory of the temp directory. ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); @@ -33,7 +30,6 @@ class ProfileManagerTest : public testing::Test { } MessageLoopForUI message_loop_; - ChromeThread ui_thread_; // the path to temporary directory used to contain the test operations FilePath test_dir_; |