mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 850245 - Remove Off-Main-Thread XPCWrappedJS refcounting from DNSListenerProxy. r=mcmanus
This commit is contained in:
parent
67dff5d95a
commit
6b99053512
@ -27,6 +27,7 @@
|
||||
#include "nsIOService.h"
|
||||
#include "nsCharSeparatedTokenizer.h"
|
||||
#include "nsNetAddr.h"
|
||||
#include "nsProxyRelease.h"
|
||||
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
@ -516,23 +517,21 @@ class DNSListenerProxy MOZ_FINAL : public nsIDNSListener
|
||||
{
|
||||
public:
|
||||
DNSListenerProxy(nsIDNSListener* aListener, nsIEventTarget* aTargetThread)
|
||||
: mListener(aListener)
|
||||
// Sometimes aListener is a main-thread only object like XPCWrappedJS, and
|
||||
// sometimes it's a threadsafe object like nsSOCKSSocketInfo. Use a main-
|
||||
// thread pointer holder, but disable strict enforcement of thread invariants.
|
||||
// The AddRef implementation of XPCWrappedJS will assert if we go wrong here.
|
||||
: mListener(new nsMainThreadPtrHolder<nsIDNSListener>(aListener, false))
|
||||
, mTargetThread(aTargetThread)
|
||||
{ }
|
||||
|
||||
~DNSListenerProxy()
|
||||
{
|
||||
nsCOMPtr<nsIThread> mainThread(do_GetMainThread());
|
||||
NS_ProxyRelease(mainThread, mListener);
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDNSLISTENER
|
||||
|
||||
class OnLookupCompleteRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
OnLookupCompleteRunnable(nsIDNSListener* aListener,
|
||||
OnLookupCompleteRunnable(nsMainThreadPtrHolder<nsIDNSListener>* aListener,
|
||||
nsICancelable* aRequest,
|
||||
nsIDNSRecord* aRecord,
|
||||
nsresult aStatus)
|
||||
@ -542,23 +541,17 @@ public:
|
||||
, mStatus(aStatus)
|
||||
{ }
|
||||
|
||||
~OnLookupCompleteRunnable()
|
||||
{
|
||||
nsCOMPtr<nsIThread> mainThread(do_GetMainThread());
|
||||
NS_ProxyRelease(mainThread, mListener);
|
||||
}
|
||||
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDNSListener> mListener;
|
||||
nsMainThreadPtrHandle<nsIDNSListener> mListener;
|
||||
nsCOMPtr<nsICancelable> mRequest;
|
||||
nsCOMPtr<nsIDNSRecord> mRecord;
|
||||
nsresult mStatus;
|
||||
};
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIDNSListener> mListener;
|
||||
nsMainThreadPtrHandle<nsIDNSListener> mListener;
|
||||
nsCOMPtr<nsIEventTarget> mTargetThread;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user