1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* vim: set sw=4 ts=8 et tw=80 : */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef DNSListenerProxy_h__
8 #define DNSListenerProxy_h__
10 #include "nsIDNSListener.h"
11 #include "nsIDNSRecord.h"
12 #include "nsProxyRelease.h"
13 #include "nsThreadUtils.h"
21 class DNSListenerProxy MOZ_FINAL
22 : public nsIDNSListener
23 , public nsIDNSListenerProxy
26 DNSListenerProxy(nsIDNSListener
* aListener
, nsIEventTarget
* aTargetThread
)
27 // Sometimes aListener is a main-thread only object like XPCWrappedJS, and
28 // sometimes it's a threadsafe object like nsSOCKSSocketInfo. Use a main-
29 // thread pointer holder, but disable strict enforcement of thread invariants.
30 // The AddRef implementation of XPCWrappedJS will assert if we go wrong here.
31 : mListener(new nsMainThreadPtrHolder
<nsIDNSListener
>(aListener
, false))
32 , mTargetThread(aTargetThread
)
35 NS_DECL_THREADSAFE_ISUPPORTS
36 NS_DECL_NSIDNSLISTENER
37 NS_DECL_NSIDNSLISTENERPROXY
39 class OnLookupCompleteRunnable
: public nsRunnable
42 OnLookupCompleteRunnable(const nsMainThreadPtrHandle
<nsIDNSListener
>& aListener
,
43 nsICancelable
* aRequest
,
44 nsIDNSRecord
* aRecord
,
46 : mListener(aListener
)
55 nsMainThreadPtrHandle
<nsIDNSListener
> mListener
;
56 nsCOMPtr
<nsICancelable
> mRequest
;
57 nsCOMPtr
<nsIDNSRecord
> mRecord
;
62 ~DNSListenerProxy() {}
64 nsMainThreadPtrHandle
<nsIDNSListener
> mListener
;
65 nsCOMPtr
<nsIEventTarget
> mTargetThread
;
70 } // namespace mozilla
71 #endif // DNSListenerProxy_h__