Bug 889885 - Avoid releasing scripted observers from PSM off the main thread. r=bsmith a=bajaj
authorJosh Matthews <josh@joshmatthews.net>
Tue, 09 Jul 2013 12:48:24 -0400
changeset 147877 5f5646dc9d94b77c3dff3333d80c9371dbb6ef77
parent 147876 ba6c735171209d7823e256c4f9e9729ab8ee558c
child 147878 f257dd1c65cab594eb62d5091e12d958038e5dc2
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmith, bajaj
bugs889885
milestone24.0a2
Bug 889885 - Avoid releasing scripted observers from PSM off the main thread. r=bsmith a=bajaj
security/manager/ssl/src/PSMRunnable.h
--- a/security/manager/ssl/src/PSMRunnable.h
+++ b/security/manager/ssl/src/PSMRunnable.h
@@ -3,16 +3,17 @@
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef PSMRunnable_h
 #define PSMRunnable_h
 
 #include "mozilla/Monitor.h"
 #include "nsThreadUtils.h"
 #include "nsIObserver.h"
+#include "nsProxyRelease.h"
 
 namespace mozilla { namespace psm {
 
 // Wait for the event to run on the target thread without spinning the event
 // loop on the calling thread. (Dispatching events to a thread using
 // NS_DISPATCH_SYNC would cause the event loop on the calling thread to spin.)
 class SyncRunnableBase : public nsRunnable
 {
@@ -26,18 +27,20 @@ private:
   mozilla::Monitor monitor;
 };
 
 class NotifyObserverRunnable : public nsRunnable
 {
 public:
   NotifyObserverRunnable(nsIObserver * observer,
                          const char * topicStringLiteral)
-    : mObserver(), mTopic(topicStringLiteral) { mObserver = observer; }
+    : mObserver(), mTopic(topicStringLiteral) {
+    mObserver = new nsMainThreadPtrHolder<nsIObserver>(observer);
+  }
   NS_DECL_NSIRUNNABLE
 private:
-  nsCOMPtr<nsIObserver> mObserver;
+  nsMainThreadPtrHandle<nsIObserver> mObserver;
   const char * const mTopic;
 };
 
 } } // namespace mozilla::psm
 
 #endif