Chromium Code Reviews| Index: chrome/browser/extensions/extension_message_service.cc |
| =================================================================== |
| --- chrome/browser/extensions/extension_message_service.cc (revision 32822) |
| +++ chrome/browser/extensions/extension_message_service.cc (working copy) |
| @@ -115,6 +115,11 @@ |
| : 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 @@ |
| 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_)); |
|
Erik does not do reviews
2009/11/25 15:52:11
If GetCurrentThreadIdentifier fails, I don't see h
huanr
2009/11/25 17:16:38
If GetCurrentThreadIdentifier fails, the thread_id
Erik does not do reviews
2009/11/25 17:32:49
I think you're missing my point. CurrentlyOn uses
|
| + registrar_.RemoveAll(); |
| + } |
| } |
| void ExtensionMessageService::AddEventListener(const std::string& event_name, |