| Index: chrome/common/notification_registrar.cc
|
| ===================================================================
|
| --- chrome/common/notification_registrar.cc (revision 33330)
|
| +++ chrome/common/notification_registrar.cc (working copy)
|
| @@ -24,6 +24,11 @@
|
| }
|
|
|
| NotificationRegistrar::NotificationRegistrar() {
|
| + if (!ChromeThread::GetCurrentThreadIdentifier(&thread_id_)) {
|
| + // If we are not created in well known thread, GetCurrentThreadIdentifier
|
| + // fails. Assign thread_id_ to an ID not used.
|
| + thread_id_ = ChromeThread::ID_COUNT;
|
| + }
|
| }
|
|
|
| NotificationRegistrar::~NotificationRegistrar() {
|
| @@ -38,6 +43,16 @@
|
| registered_.end()) << "Duplicate registration.";
|
| registered_.push_back(record);
|
|
|
| + if (ChromeThread::IsWellKnownThread(thread_id_)) {
|
| + if (!ChromeThread::CurrentlyOn(thread_id_)) {
|
| + // We are created on a well known thread, but this function is called
|
| + // on a different thread. This could be a bug, or maybe the object is
|
| + // passed around.
|
| + // To be safe, reset thread_id_ so we don't call CHECK during remove.
|
| + thread_id_ = ChromeThread::ID_COUNT;
|
| + }
|
| + }
|
| +
|
| NotificationService::current()->AddObserver(observer, type, source);
|
| }
|
|
|
| @@ -54,6 +69,8 @@
|
| }
|
| registered_.erase(found);
|
|
|
| + CheckCalledOnValidWellKnownThread();
|
| +
|
| // This can be NULL if our owner outlives the NotificationService, e.g. if our
|
| // owner is a Singleton.
|
| NotificationService* service = NotificationService::current();
|
| @@ -71,6 +88,8 @@
|
| if (registered_.empty())
|
| return;
|
|
|
| + CheckCalledOnValidWellKnownThread();
|
| +
|
| // This can be NULL if our owner outlives the NotificationService, e.g. if our
|
| // owner is a Singleton.
|
| NotificationService* service = NotificationService::current();
|
| @@ -87,3 +106,9 @@
|
| bool NotificationRegistrar::IsEmpty() const {
|
| return registered_.empty();
|
| }
|
| +
|
| +void NotificationRegistrar::CheckCalledOnValidWellKnownThread() {
|
| + if (ChromeThread::IsWellKnownThread(thread_id_)) {
|
| + CHECK(ChromeThread::CurrentlyOn(thread_id_));
|
| + }
|
| +}
|
|
|