diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /netwerk/dns/DNSListenerProxy.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'netwerk/dns/DNSListenerProxy.h')
-rw-r--r-- | netwerk/dns/DNSListenerProxy.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/netwerk/dns/DNSListenerProxy.h b/netwerk/dns/DNSListenerProxy.h new file mode 100644 index 000000000..307dde0f7 --- /dev/null +++ b/netwerk/dns/DNSListenerProxy.h @@ -0,0 +1,72 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* vim: set sw=4 ts=8 et tw=80 : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef DNSListenerProxy_h__ +#define DNSListenerProxy_h__ + +#include "nsIDNSListener.h" +#include "nsIDNSRecord.h" +#include "nsProxyRelease.h" +#include "nsThreadUtils.h" + +class nsIEventTarget; +class nsICancelable; + +namespace mozilla { +namespace net { + +class DNSListenerProxy final + : public nsIDNSListener + , public nsIDNSListenerProxy +{ +public: + DNSListenerProxy(nsIDNSListener* aListener, nsIEventTarget* aTargetThread) + // 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) + { } + + NS_DECL_THREADSAFE_ISUPPORTS + NS_DECL_NSIDNSLISTENER + NS_DECL_NSIDNSLISTENERPROXY + + class OnLookupCompleteRunnable : public Runnable + { + public: + OnLookupCompleteRunnable(const nsMainThreadPtrHandle<nsIDNSListener>& aListener, + nsICancelable* aRequest, + nsIDNSRecord* aRecord, + nsresult aStatus) + : mListener(aListener) + , mRequest(aRequest) + , mRecord(aRecord) + , mStatus(aStatus) + { } + + NS_DECL_NSIRUNNABLE + + private: + nsMainThreadPtrHandle<nsIDNSListener> mListener; + nsCOMPtr<nsICancelable> mRequest; + nsCOMPtr<nsIDNSRecord> mRecord; + nsresult mStatus; + }; + +private: + ~DNSListenerProxy() {} + + nsMainThreadPtrHandle<nsIDNSListener> mListener; + nsCOMPtr<nsIEventTarget> mTargetThread; +}; + + +} // namespace net +} // namespace mozilla + +#endif // DNSListenerProxy_h__ |