DNSListenerProxy.cpp (1517B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set sw=2 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/. */ 6 7 #include "mozilla/net/DNSListenerProxy.h" 8 #include "nsICancelable.h" 9 10 namespace mozilla { 11 namespace net { 12 13 NS_IMPL_ADDREF(DNSListenerProxy) 14 NS_IMPL_RELEASE(DNSListenerProxy) 15 NS_INTERFACE_MAP_BEGIN(DNSListenerProxy) 16 NS_INTERFACE_MAP_ENTRY(nsIDNSListener) 17 NS_INTERFACE_MAP_ENTRY_CONCRETE(DNSListenerProxy) 18 NS_INTERFACE_MAP_END 19 20 NS_IMETHODIMP 21 DNSListenerProxy::OnLookupComplete(nsICancelable* aRequest, 22 nsIDNSRecord* aRecord, nsresult aStatus) { 23 RefPtr<DNSListenerProxy> self = this; 24 nsCOMPtr<nsICancelable> request = aRequest; 25 nsCOMPtr<nsIDNSRecord> record = aRecord; 26 nsresult rv = mTargetThread->Dispatch( 27 NS_NewRunnableFunction("DNSListenerProxy::OnLookupComplete", 28 [self, request, record, aStatus]() { 29 (void)self->mListener->OnLookupComplete( 30 request, record, aStatus); 31 self->mListener = nullptr; 32 }), 33 NS_DISPATCH_NORMAL); 34 if (NS_FAILED(rv)) { 35 NS_WARNING("DNSListenerProxy::OnLookupComplete dispatch failed."); 36 } 37 return rv; 38 } 39 40 } // namespace net 41 } // namespace mozilla