Bug 842818 - Allow calling WebCryptoTask::DispatchWithPromise() from workers r=keeler
authorTim Taubert <tim@timtaubert.de>
Wed, 20 Jan 2016 23:19:42 +0100
changeset 292426 fdded53dc92f12deeb7e2b72f07571f577418d05
parent 292425 f83f79281511d9ea9d8c5bde4ad0c1ef15d27a89
child 292427 9262f09b33225eaf831004be688c9b6103d3503a
push id30160
push userryanvm@gmail.com
push dateSun, 10 Apr 2016 20:21:04 +0000
treeherdermozilla-central@29d5a4175c8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskeeler
bugs842818
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 842818 - Allow calling WebCryptoTask::DispatchWithPromise() from workers r=keeler
dom/crypto/WebCryptoTask.cpp
dom/crypto/WebCryptoThreadPool.cpp
--- a/dom/crypto/WebCryptoTask.cpp
+++ b/dom/crypto/WebCryptoTask.cpp
@@ -335,40 +335,32 @@ CloneData(JSContext* aCx, CryptoBuffer& 
   return false;
 }
 
 // Implementation of WebCryptoTask methods
 
 void
 WebCryptoTask::DispatchWithPromise(Promise* aResultPromise)
 {
-  MOZ_ASSERT(NS_IsMainThread());
   mResultPromise = aResultPromise;
 
   // Fail if an error was set during the constructor
   MAYBE_EARLY_FAIL(mEarlyRv)
 
   // Perform pre-NSS operations, and fail if they fail
   mEarlyRv = BeforeCrypto();
   MAYBE_EARLY_FAIL(mEarlyRv)
 
   // Skip NSS if we're already done, or launch a CryptoTask
   if (mEarlyComplete) {
     CallCallback(mEarlyRv);
     Skip();
     return;
   }
 
-  // Ensure that NSS is initialized, since presumably CalculateResult
-  // will use NSS functions
-  if (!EnsureNSSInitializedChromeOrContent()) {
-    mEarlyRv = NS_ERROR_DOM_UNKNOWN_ERR;
-    MAYBE_EARLY_FAIL(mEarlyRv)
-  }
-
   // Store calling thread and dispatch to thread pool.
   mOriginalThread = NS_GetCurrentThread();
   mEarlyRv = WebCryptoThreadPool::Dispatch(this);
   MAYBE_EARLY_FAIL(mEarlyRv)
 }
 
 NS_IMETHODIMP
 WebCryptoTask::Run()
--- a/dom/crypto/WebCryptoThreadPool.cpp
+++ b/dom/crypto/WebCryptoThreadPool.cpp
@@ -60,16 +60,18 @@ WebCryptoThreadPool::Init()
 }
 
 nsresult
 WebCryptoThreadPool::DispatchInternal(nsIRunnable* aRunnable)
 {
   MutexAutoLock lock(mMutex);
 
   if (!mPool) {
+    NS_ENSURE_TRUE(EnsureNSSInitializedChromeOrContent(), NS_ERROR_FAILURE);
+
     nsCOMPtr<nsIThreadPool> pool(do_CreateInstance(NS_THREADPOOL_CONTRACTID));
     NS_ENSURE_TRUE(pool, NS_ERROR_FAILURE);
 
     nsresult rv = pool->SetName(NS_LITERAL_CSTRING("SubtleCrypto"));
     NS_ENSURE_SUCCESS(rv, rv);
 
     pool.swap(mPool);
   }