Bumping manifests a=b2g-bump
[gecko.git] / netwerk / dns / DNSListenerProxy.h
blobf9f021f836f2de8926035f086ab215b788f0699c
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"
15 class nsIEventTarget;
16 class nsICancelable;
18 namespace mozilla {
19 namespace net {
21 class DNSListenerProxy MOZ_FINAL
22 : public nsIDNSListener
23 , public nsIDNSListenerProxy
25 public:
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)
33 { }
35 NS_DECL_THREADSAFE_ISUPPORTS
36 NS_DECL_NSIDNSLISTENER
37 NS_DECL_NSIDNSLISTENERPROXY
39 class OnLookupCompleteRunnable : public nsRunnable
41 public:
42 OnLookupCompleteRunnable(const nsMainThreadPtrHandle<nsIDNSListener>& aListener,
43 nsICancelable* aRequest,
44 nsIDNSRecord* aRecord,
45 nsresult aStatus)
46 : mListener(aListener)
47 , mRequest(aRequest)
48 , mRecord(aRecord)
49 , mStatus(aStatus)
50 { }
52 NS_DECL_NSIRUNNABLE
54 private:
55 nsMainThreadPtrHandle<nsIDNSListener> mListener;
56 nsCOMPtr<nsICancelable> mRequest;
57 nsCOMPtr<nsIDNSRecord> mRecord;
58 nsresult mStatus;
61 private:
62 ~DNSListenerProxy() {}
64 nsMainThreadPtrHandle<nsIDNSListener> mListener;
65 nsCOMPtr<nsIEventTarget> mTargetThread;
69 } // namespace net
70 } // namespace mozilla
71 #endif // DNSListenerProxy_h__