netwerk/dns/DNSListenerProxy.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* vim: set sw=4 ts=8 et tw=80 : */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef DNSListenerProxy_h__
michael@0 8 #define DNSListenerProxy_h__
michael@0 9
michael@0 10 #include "nsIDNSListener.h"
michael@0 11 #include "nsIDNSRecord.h"
michael@0 12 #include "nsProxyRelease.h"
michael@0 13 #include "nsThreadUtils.h"
michael@0 14
michael@0 15 class nsIEventTarget;
michael@0 16 class nsICancelable;
michael@0 17
michael@0 18 namespace mozilla {
michael@0 19 namespace net {
michael@0 20
michael@0 21 class DNSListenerProxy MOZ_FINAL : public nsIDNSListener
michael@0 22 {
michael@0 23 public:
michael@0 24 DNSListenerProxy(nsIDNSListener* aListener, nsIEventTarget* aTargetThread)
michael@0 25 // Sometimes aListener is a main-thread only object like XPCWrappedJS, and
michael@0 26 // sometimes it's a threadsafe object like nsSOCKSSocketInfo. Use a main-
michael@0 27 // thread pointer holder, but disable strict enforcement of thread invariants.
michael@0 28 // The AddRef implementation of XPCWrappedJS will assert if we go wrong here.
michael@0 29 : mListener(new nsMainThreadPtrHolder<nsIDNSListener>(aListener, false))
michael@0 30 , mTargetThread(aTargetThread)
michael@0 31 { }
michael@0 32
michael@0 33 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 34 NS_DECL_NSIDNSLISTENER
michael@0 35
michael@0 36 class OnLookupCompleteRunnable : public nsRunnable
michael@0 37 {
michael@0 38 public:
michael@0 39 OnLookupCompleteRunnable(const nsMainThreadPtrHandle<nsIDNSListener>& aListener,
michael@0 40 nsICancelable* aRequest,
michael@0 41 nsIDNSRecord* aRecord,
michael@0 42 nsresult aStatus)
michael@0 43 : mListener(aListener)
michael@0 44 , mRequest(aRequest)
michael@0 45 , mRecord(aRecord)
michael@0 46 , mStatus(aStatus)
michael@0 47 { }
michael@0 48
michael@0 49 NS_DECL_NSIRUNNABLE
michael@0 50
michael@0 51 private:
michael@0 52 nsMainThreadPtrHandle<nsIDNSListener> mListener;
michael@0 53 nsCOMPtr<nsICancelable> mRequest;
michael@0 54 nsCOMPtr<nsIDNSRecord> mRecord;
michael@0 55 nsresult mStatus;
michael@0 56 };
michael@0 57
michael@0 58 private:
michael@0 59 nsMainThreadPtrHandle<nsIDNSListener> mListener;
michael@0 60 nsCOMPtr<nsIEventTarget> mTargetThread;
michael@0 61 };
michael@0 62
michael@0 63
michael@0 64 } // namespace net
michael@0 65 } // namespace mozilla
michael@0 66 #endif // DNSListenerProxy_h__

mercurial