michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim: set sw=4 ts=8 et tw=80 : */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef DNSListenerProxy_h__ michael@0: #define DNSListenerProxy_h__ michael@0: michael@0: #include "nsIDNSListener.h" michael@0: #include "nsIDNSRecord.h" michael@0: #include "nsProxyRelease.h" michael@0: #include "nsThreadUtils.h" michael@0: michael@0: class nsIEventTarget; michael@0: class nsICancelable; michael@0: michael@0: namespace mozilla { michael@0: namespace net { michael@0: michael@0: class DNSListenerProxy MOZ_FINAL : public nsIDNSListener michael@0: { michael@0: public: michael@0: DNSListenerProxy(nsIDNSListener* aListener, nsIEventTarget* aTargetThread) michael@0: // Sometimes aListener is a main-thread only object like XPCWrappedJS, and michael@0: // sometimes it's a threadsafe object like nsSOCKSSocketInfo. Use a main- michael@0: // thread pointer holder, but disable strict enforcement of thread invariants. michael@0: // The AddRef implementation of XPCWrappedJS will assert if we go wrong here. michael@0: : mListener(new nsMainThreadPtrHolder(aListener, false)) michael@0: , mTargetThread(aTargetThread) michael@0: { } michael@0: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIDNSLISTENER michael@0: michael@0: class OnLookupCompleteRunnable : public nsRunnable michael@0: { michael@0: public: michael@0: OnLookupCompleteRunnable(const nsMainThreadPtrHandle& aListener, michael@0: nsICancelable* aRequest, michael@0: nsIDNSRecord* aRecord, michael@0: nsresult aStatus) michael@0: : mListener(aListener) michael@0: , mRequest(aRequest) michael@0: , mRecord(aRecord) michael@0: , mStatus(aStatus) michael@0: { } michael@0: michael@0: NS_DECL_NSIRUNNABLE michael@0: michael@0: private: michael@0: nsMainThreadPtrHandle mListener; michael@0: nsCOMPtr mRequest; michael@0: nsCOMPtr mRecord; michael@0: nsresult mStatus; michael@0: }; michael@0: michael@0: private: michael@0: nsMainThreadPtrHandle mListener; michael@0: nsCOMPtr mTargetThread; michael@0: }; michael@0: michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: #endif // DNSListenerProxy_h__