Bug 1365513 - Remove the call to AbstractThread::GetCurrent() in nsPermissionManager.cpp. r?mystor
See
bug 1365483 for the rationale.
MozReview-Commit-ID: 4sWodnP5MYZ
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -6,16 +6,17 @@
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/BasePrincipal.h"
#include "mozilla/Services.h"
+#include "mozilla/SystemGroup.h"
#include "mozilla/Unused.h"
#include "nsPermissionManager.h"
#include "nsPermission.h"
#include "nsCRT.h"
#include "nsNetUtil.h"
#include "nsCOMArray.h"
#include "nsArrayEnumerator.h"
#include "nsTArray.h"
@@ -3351,19 +3352,21 @@ nsPermissionManager::WhenPermissionsAvai
// If all of our permissions are avaliable, immediately run the runnable. This
// avoids any extra overhead during fetch interception which is performance
// sensitive.
if (promises.IsEmpty()) {
aRunnable->Run();
return NS_OK;
}
+ auto* thread = SystemGroup::AbstractMainThreadFor(TaskCategory::Other);
+
RefPtr<nsIRunnable> runnable = aRunnable;
- GenericPromise::All(AbstractThread::GetCurrent(), promises)->Then(
- AbstractThread::GetCurrent(), __func__,
+ GenericPromise::All(thread, promises)->Then(
+ thread, __func__,
[runnable] () { runnable->Run(); },
[] () {
NS_WARNING("nsPermissionManager permission promise rejected. We're probably shutting down.");
});
return NS_OK;
}
NS_IMETHODIMP
--- a/netwerk/base/nsIPermissionManager.idl
+++ b/netwerk/base/nsIPermissionManager.idl
@@ -326,17 +326,19 @@ interface nsIPermissionManager : nsISupp
*
* @param aPrincipal The principal to broadcast permissions for.
*/
void broadcastPermissionsForPrincipalToAllContentProcesses(in nsIPrincipal aPrincipal);
/**
* Add a callback which should be run when all permissions are available for
* the given nsIPrincipal. This method invokes the callback runnable
- * synchronously when the permissions are already available.
+ * synchronously when the permissions are already available. Otherwise the
+ * callback will be run asynchronously in SystemGroup when all permissions
+ * are available in the future.
*
* NOTE: This method will not request the permissions be sent by the parent
* process. This should only be used to wait for permissions which may not
* have arrived yet in order to ensure they are present.
*
* @param aPrincipal The principal to wait for permissions to be available for.
* @param aRunnable The runnable to run when permissions are available for the
* given principal.