summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/extension_message_service.cc
diff options
context:
space:
mode:
authorhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 06:59:33 +0000
committerhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-25 06:59:33 +0000
commit303e8f00bec846e87a34e9a3e00f0947ae33a584 (patch)
tree58638382ffed902f6f4fe1d7728516ee830b6793 /chrome/browser/extensions/extension_message_service.cc
parent61e9572d1eeadfd4eb8326515fa73e3826de3111 (diff)
downloadchromium_src-303e8f00bec846e87a34e9a3e00f0947ae33a584.zip
chromium_src-303e8f00bec846e87a34e9a3e00f0947ae33a584.tar.gz
chromium_src-303e8f00bec846e87a34e9a3e00f0947ae33a584.tar.bz2
Fixing 27834 by always deleting ExtensionMessageService on
UI thread. BUG=27834 TEST=none Review URL: http://codereview.chromium.org/440012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33057 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_message_service.cc')
-rw-r--r--chrome/browser/extensions/extension_message_service.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_message_service.cc b/chrome/browser/extensions/extension_message_service.cc
index 9058aee..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,
@@ -132,10 +137,11 @@ ExtensionMessageService::~ExtensionMessageService() {
void ExtensionMessageService::ProfileDestroyed() {
profile_ = NULL;
-
- // We remove notifications here because our destructor might be called on
- // a non-UI thread.
- registrar_.RemoveAll();
+ if (!registrar_.IsEmpty()) {
+ if (thread_id_ != ChromeThread::ID_COUNT)
+ CHECK(ChromeThread::CurrentlyOn(thread_id_));
+ registrar_.RemoveAll();
+ }
}
void ExtensionMessageService::AddEventListener(const std::string& event_name,