mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1343761 - Use SystemGroup to dispatch runnables in DNSRequestChild, r=mayhemer
--HG-- extra : rebase_source : b2d0aa4e0ed2aca8b79b9c3ff024609b717c0ead
This commit is contained in:
parent
07398398a4
commit
3b3bf39b5a
@ -11,6 +11,7 @@
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIProtocolProxyService.h"
|
||||
#include "nsNetCID.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/net/DNSListenerProxy.h"
|
||||
#include "nsServiceManagerUtils.h"
|
||||
@ -173,9 +174,7 @@ ChildDNSService::AsyncResolveExtendedNative(const nsACString &hostname,
|
||||
nsCOMPtr<nsIEventTarget> target = target_;
|
||||
nsCOMPtr<nsIXPConnectWrappedJS> wrappedListener = do_QueryInterface(listener);
|
||||
if (wrappedListener && !target) {
|
||||
nsCOMPtr<nsIThread> mainThread;
|
||||
NS_GetMainThread(getter_AddRefs(mainThread));
|
||||
target = do_QueryInterface(mainThread);
|
||||
target = SystemGroup::EventTargetFor(TaskCategory::Network);
|
||||
}
|
||||
if (target) {
|
||||
// Guarantee listener freed on main thread. Not sure we need this in child
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "mozilla/net/ChildDNSService.h"
|
||||
#include "mozilla/net/DNSRequestChild.h"
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/SystemGroup.h"
|
||||
#include "mozilla/Unused.h"
|
||||
#include "nsIDNSRecord.h"
|
||||
#include "nsHostResolver.h"
|
||||
@ -210,11 +211,18 @@ DNSRequestChild::StartRequest()
|
||||
{
|
||||
// we can only do IPDL on the main thread
|
||||
if (!NS_IsMainThread()) {
|
||||
NS_DispatchToMainThread(
|
||||
SystemGroup::Dispatch(
|
||||
"StartDNSRequestChild",
|
||||
TaskCategory::Other,
|
||||
NewRunnableMethod(this, &DNSRequestChild::StartRequest));
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEventTarget> systemGroupEventTarget
|
||||
= SystemGroup::EventTargetFor(TaskCategory::Other);
|
||||
|
||||
gNeckoChild->SetEventTargetForActor(this, systemGroupEventTarget);
|
||||
|
||||
// Send request to Parent process.
|
||||
gNeckoChild->SendPDNSRequestConstructor(this, mHost, mOriginAttributes,
|
||||
mFlags, mNetworkInterface);
|
||||
@ -306,8 +314,10 @@ DNSRequestChild::Cancel(nsresult reason)
|
||||
{
|
||||
if(mIPCOpen) {
|
||||
// We can only do IPDL on the main thread
|
||||
NS_DispatchToMainThread(
|
||||
new CancelDNSRequestEvent(this, reason));
|
||||
nsCOMPtr<nsIRunnable> runnable = new CancelDNSRequestEvent(this, reason);
|
||||
SystemGroup::Dispatch("CancelDNSRequest",
|
||||
TaskCategory::Other,
|
||||
runnable.forget());
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user