Bug 850253 - Remove Off-Main-Thread XPCWrappedJS refcounting from KeyGenRunnable. r=jedp, a=bajaj
authorBobby Holley <bobbyholley@gmail.com>
Thu, 11 Apr 2013 14:05:35 -0700
changeset 120054 bb1ba0f59b3143d8b8b5b9279d08a1867d8c8849
parent 120053 05db0f8744fa08f9f25372aa44ac6bf7be71e349
child 120055 e58ba4276d7ba111c70973302e7cb29719a0ed4f
push id99
push userryanvm@gmail.com
push dateFri, 18 Oct 2013 00:45:52 +0000
reviewersjedp, bajaj
bugs850253
milestone18.1
Bug 850253 - Remove Off-Main-Thread XPCWrappedJS refcounting from KeyGenRunnable. r=jedp, a=bajaj
toolkit/identity/IdentityCryptoService.cpp
--- a/toolkit/identity/IdentityCryptoService.cpp
+++ b/toolkit/identity/IdentityCryptoService.cpp
@@ -6,16 +6,17 @@
 
 #include "nsIIdentityCryptoService.h"
 #include "mozilla/ModuleUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsNSSShutDown.h"
 #include "nsIThread.h"
 #include "nsThreadUtils.h"
 #include "nsCOMPtr.h"
+#include "nsProxyRelease.h"
 #include "nsStringGlue.h"
 #include "mozilla/Base64.h"
 #include "ScopedNSSTypes.h"
 
 #include "nss.h"
 #include "pk11pub.h"
 #include "secmod.h"
 #include "secerr.h"
@@ -129,17 +130,17 @@ private:
     nsNSSShutDownPreventionLock locker;
     if (isAlreadyShutDown())
       return;
 
      mKeyPair = NULL;
   }
 
   const KeyType mKeyType; // in
-  nsCOMPtr<nsIIdentityKeyGenCallback> mCallback; // in
+  nsMainThreadPtrHandle<nsIIdentityKeyGenCallback> mCallback; // in
   nsresult mRv; // out
   nsCOMPtr<KeyPair> mKeyPair; // out
 
   KeyGenRunnable(const KeyGenRunnable &) MOZ_DELETE;
   void operator=(const KeyGenRunnable &) MOZ_DELETE;
 };
 
 class SignRunnable : public nsRunnable, public nsNSSShutDownObject
@@ -326,17 +327,17 @@ KeyPair::Sign(const nsACString & textToS
   nsCOMPtr<nsIThread> thread;
   nsresult rv = NS_NewThread(getter_AddRefs(thread), r);
   return rv;
 }
 
 KeyGenRunnable::KeyGenRunnable(KeyType keyType,
                                nsIIdentityKeyGenCallback * callback)
   : mKeyType(keyType)
-  , mCallback(callback)
+  , mCallback(new nsMainThreadPtrHolder<nsIIdentityKeyGenCallback>(callback))
   , mRv(NS_ERROR_NOT_INITIALIZED)
 {
 }
 
 MOZ_WARN_UNUSED_RESULT nsresult
 GenerateKeyPair(PK11SlotInfo * slot,
                 SECKEYPrivateKey ** privateKey,
                 SECKEYPublicKey ** publicKey,