diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index 93fd560c36c..64035677768 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -114,11 +114,6 @@ #include "nsISHistoryListener.h" #include "nsIWindowWatcher.h" -// Pull in various NS_ERROR_* definitions -#include "nsIDNSService.h" -#include "nsISocketTransportService.h" -#include "nsISocketProvider.h" - // Editor-related #include "nsIEditingSession.h" diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 5b3ecf85898..f954689369b 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -52,8 +52,6 @@ #include "nsIStreamListener.h" #include "nsIPrompt.h" #include "nsNetUtil.h" -#include "nsIDNSService.h" -#include "nsISocketProvider.h" #include "nsIRefreshURI.h" #include "nsIScriptGlobalObject.h" #include "nsIScriptGlobalObjectOwner.h" diff --git a/mozilla/embedding/browser/photon/src/EmbedProgress.cpp b/mozilla/embedding/browser/photon/src/EmbedProgress.cpp index ead8ab95fd3..d35512cecd6 100644 --- a/mozilla/embedding/browser/photon/src/EmbedProgress.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedProgress.cpp @@ -47,7 +47,6 @@ #include "nsIWidget.h" #include #include -#include #include "nsReadableUtils.h" #include #include diff --git a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp index 96908fa6757..5f975863584 100644 --- a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp @@ -56,7 +56,6 @@ #include "nsIStringBundle.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" -#include "nsIDNSService.h" #include "nsNetError.h" NS_IMPL_ISUPPORTS2(nsAbLDAPAutoCompFormatter, diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.cpp b/mozilla/mailnews/base/util/nsMsgProtocol.cpp index 3cbf24dafc3..e2b5c84972e 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.cpp +++ b/mozilla/mailnews/base/util/nsMsgProtocol.cpp @@ -49,7 +49,6 @@ #include "nsNetUtil.h" #include "nsIFileURL.h" #include "nsFileStream.h" -#include "nsIDNSService.h" #include "nsIMsgWindow.h" #include "nsIMsgStatusFeedback.h" #include "nsIWebProgressListener.h" diff --git a/mozilla/mailnews/compose/src/nsMsgSend.cpp b/mozilla/mailnews/compose/src/nsMsgSend.cpp index 18c694f30cf..adfa879b9a5 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSend.cpp @@ -81,7 +81,6 @@ #include "nsIAbAddressCollecter.h" #include "nsAbBaseCID.h" #include "nsCOMPtr.h" -#include "nsIDNSService.h" #include "mozITXTToHTMLConv.h" #include "nsIMsgStatusFeedback.h" #include "nsIMsgMailSession.h" diff --git a/mozilla/mailnews/imap/src/nsImapProtocol.cpp b/mozilla/mailnews/imap/src/nsImapProtocol.cpp index 530f4145b0f..db0507e69d6 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.cpp +++ b/mozilla/mailnews/imap/src/nsImapProtocol.cpp @@ -79,7 +79,6 @@ #include "nsICopyMsgStreamListener.h" #include "nsTextFormatter.h" #include "nsAutoLock.h" -#include "nsIDNSService.h" #include "nsIMsgHdr.h" #include "nsMsgI18N.h" #include "nsEscape.h" diff --git a/mozilla/netwerk/base/src/nsIOService.h b/mozilla/netwerk/base/src/nsIOService.h index 5c33475b662..44586a19e68 100644 --- a/mozilla/netwerk/base/src/nsIOService.h +++ b/mozilla/netwerk/base/src/nsIOService.h @@ -44,7 +44,7 @@ #include "nsIIOService.h" #include "nsVoidArray.h" #include "nsISocketTransportService.h" -#include "nsIDNSService.h" +#include "nsPIDNSService.h" #include "nsIProtocolProxyService.h" #include "nsCOMPtr.h" #include "nsURLHelper.h" @@ -103,7 +103,7 @@ protected: PRPackedBool mOffline; PRPackedBool mOfflineForProfileChange; nsCOMPtr mSocketTransportService; - nsCOMPtr mDNSService; + nsCOMPtr mDNSService; nsCOMPtr mProxyService; nsCOMPtr mEventQueueService; diff --git a/mozilla/netwerk/base/src/nsPACMan.cpp b/mozilla/netwerk/base/src/nsPACMan.cpp index 9e971bc056e..b338226af41 100644 --- a/mozilla/netwerk/base/src/nsPACMan.cpp +++ b/mozilla/netwerk/base/src/nsPACMan.cpp @@ -39,6 +39,7 @@ #include "nsPACMan.h" #include "nsIDNSService.h" #include "nsIDNSListener.h" +#include "nsICancelable.h" #include "nsEventQueueUtils.h" #include "nsNetUtil.h" #include "nsAutoLock.h" @@ -72,7 +73,7 @@ private: nsPACMan *mPACMan; // weak reference nsCOMPtr mURI; nsRefPtr mCallback; - nsCOMPtr mDNSRequest; + nsCOMPtr mDNSRequest; }; // This is threadsafe because we implement nsIDNSListener @@ -119,13 +120,13 @@ PendingPACQuery::Complete(nsresult status, const nsCString &pacString) mCallback = nsnull; if (mDNSRequest) { - mDNSRequest->Cancel(); + mDNSRequest->Cancel(NS_ERROR_ABORT); mDNSRequest = nsnull; } } NS_IMETHODIMP -PendingPACQuery::OnLookupComplete(nsIDNSRequest *request, +PendingPACQuery::OnLookupComplete(nsICancelable *request, nsIDNSRecord *record, nsresult status) { diff --git a/mozilla/netwerk/base/src/nsSocketTransport2.cpp b/mozilla/netwerk/base/src/nsSocketTransport2.cpp index a5711b44da7..2959a7fe464 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport2.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport2.cpp @@ -1518,7 +1518,7 @@ nsSocketTransport::OnSocketDetached(PRFileDesc *fd) // make sure there isn't any pending DNS request if (mDNSRequest) { - mDNSRequest->Cancel(); + mDNSRequest->Cancel(NS_ERROR_ABORT); mDNSRequest = 0; } @@ -1803,7 +1803,7 @@ nsSocketTransport::SetTimeout(PRUint32 type, PRUint32 value) } NS_IMETHODIMP -nsSocketTransport::OnLookupComplete(nsIDNSRequest *request, +nsSocketTransport::OnLookupComplete(nsICancelable *request, nsIDNSRecord *rec, nsresult status) { diff --git a/mozilla/netwerk/base/src/nsSocketTransport2.h b/mozilla/netwerk/base/src/nsSocketTransport2.h index 1ee76b15ffe..0531a13e9ca 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport2.h +++ b/mozilla/netwerk/base/src/nsSocketTransport2.h @@ -51,7 +51,9 @@ #include "nsIInterfaceRequestor.h" #include "nsIAsyncInputStream.h" #include "nsIAsyncOutputStream.h" -#include "nsIDNSService.h" +#include "nsIDNSListener.h" +#include "nsIDNSRecord.h" +#include "nsICancelable.h" class nsSocketTransport; @@ -216,7 +218,7 @@ private: // recursively or not. this flag is not protected by any lock. PRPackedBool mResolving; - nsCOMPtr mDNSRequest; + nsCOMPtr mDNSRequest; nsCOMPtr mDNSRecord; PRNetAddr mNetAddr; diff --git a/mozilla/netwerk/dns/public/Makefile.in b/mozilla/netwerk/dns/public/Makefile.in index 1fcde9eafa6..182039650d5 100644 --- a/mozilla/netwerk/dns/public/Makefile.in +++ b/mozilla/netwerk/dns/public/Makefile.in @@ -48,9 +48,9 @@ XPIDL_MODULE = necko_dns GRE_MODULE = 1 XPIDLSRCS = \ + nsPIDNSService.idl \ nsIDNSService.idl \ nsIDNSListener.idl \ - nsIDNSRequest.idl \ nsIDNSRecord.idl \ nsIIDNService.idl \ $(NULL) diff --git a/mozilla/netwerk/dns/public/nsIDNSListener.idl b/mozilla/netwerk/dns/public/nsIDNSListener.idl index a150e425c35..9534682b523 100644 --- a/mozilla/netwerk/dns/public/nsIDNSListener.idl +++ b/mozilla/netwerk/dns/public/nsIDNSListener.idl @@ -36,13 +36,13 @@ #include "nsISupports.idl" -interface nsIDNSRequest; +interface nsICancelable; interface nsIDNSRecord; /** * nsIDNSListener */ -[scriptable, uuid(36413eba-3a2a-444d-b88e-df9b6d306b73)] +[scriptable, uuid(41466a9f-f027-487d-a96c-af39e629b8d2)] interface nsIDNSListener : nsISupports { /** @@ -56,7 +56,7 @@ interface nsIDNSListener : nsISupports * @param aStatus * if the lookup failed, this parameter gives the reason. */ - void onLookupComplete(in nsIDNSRequest aRequest, + void onLookupComplete(in nsICancelable aRequest, in nsIDNSRecord aRecord, in nsresult aStatus); }; diff --git a/mozilla/netwerk/dns/public/nsIDNSService.idl b/mozilla/netwerk/dns/public/nsIDNSService.idl index 78d473d9ad4..151f6b9a044 100644 --- a/mozilla/netwerk/dns/public/nsIDNSService.idl +++ b/mozilla/netwerk/dns/public/nsIDNSService.idl @@ -36,32 +36,19 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsIDNSRecord.idl" -#include "nsIDNSRequest.idl" -#include "nsIDNSListener.idl" +#include "nsISupports.idl" -interface nsIEventQueue; +interface nsICancelable; +interface nsIEventTarget; +interface nsIDNSRecord; +interface nsIDNSListener; /** * nsIDNSService */ -[scriptable, uuid(2d6bbf2f-cf97-48f0-af29-642b86d0e59e)] +[scriptable, uuid(5c8ec09d-bfbf-4eaf-8a36-0d84b5c8f35b)] interface nsIDNSService : nsISupports { - /** - * called to initialize the DNS service. - */ - void init(); - - /** - * called to shutdown the DNS service. any pending asynchronous - * requests will be canceled, and the local cache of DNS records - * will be cleared. NOTE: the operating system may still have - * its own cache of DNS records, which would be unaffected by - * this method. - */ - void shutdown(); - /** * kicks off an asynchronous host lookup. * @@ -71,19 +58,19 @@ interface nsIDNSService : nsISupports * a bitwise OR of the RESOLVE_ prefixed constants defined below. * @param aListener * the listener to be notified when the result is available. - * @param aListenerEventQ + * @param aListenerEventTarget * optional parameter (may be null). if non-null, this parameter - * specifies the nsIEventQueue of the thread on which the listener's + * specifies the nsIEventTarget of the thread on which the listener's * onLookupComplete should be called. however, if this parameter is * null, then onLookupComplete will be called on an unspecified * thread (possibly recursively). * - * @return DNS request instance that can be used to cancel the host lookup. + * @return An object that can be used to cancel the host lookup. */ - nsIDNSRequest asyncResolve(in AUTF8String aHostName, + nsICancelable asyncResolve(in AUTF8String aHostName, in unsigned long aFlags, in nsIDNSListener aListener, - in nsIEventQueue aListenerEventQ); + in nsIEventTarget aListenerEventTarget); /** * called to synchronously resolve a hostname. warning this method may diff --git a/mozilla/netwerk/dns/public/nsPIDNSService.idl b/mozilla/netwerk/dns/public/nsPIDNSService.idl new file mode 100644 index 00000000000..e0eea6d7674 --- /dev/null +++ b/mozilla/netwerk/dns/public/nsPIDNSService.idl @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Google Inc. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Darin Fisher + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsIDNSService.idl" + +/** + * This is a private interface used by the internals of the networking library. + * It will never be frozen. Do not use it in external code. + */ +[scriptable, uuid(a26c5b45-7707-4412-bbc1-2462b890848d)] +interface nsPIDNSService : nsIDNSService +{ + /** + * called to initialize the DNS service. + */ + void init(); + + /** + * called to shutdown the DNS service. any pending asynchronous + * requests will be canceled, and the local cache of DNS records + * will be cleared. NOTE: the operating system may still have + * its own cache of DNS records, which would be unaffected by + * this method. + */ + void shutdown(); +}; diff --git a/mozilla/netwerk/dns/src/nsDNSService2.cpp b/mozilla/netwerk/dns/src/nsDNSService2.cpp index 4d976f1c116..2d51f03710a 100644 --- a/mozilla/netwerk/dns/src/nsDNSService2.cpp +++ b/mozilla/netwerk/dns/src/nsDNSService2.cpp @@ -36,6 +36,9 @@ * ***** END LICENSE BLOCK ***** */ #include "nsDNSService2.h" +#include "nsIDNSRecord.h" +#include "nsIDNSListener.h" +#include "nsICancelable.h" #include "nsIProxyObjectManager.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" @@ -174,11 +177,11 @@ nsDNSRecord::Rewind() //----------------------------------------------------------------------------- class nsDNSAsyncRequest : public nsResolveHostCallback - , public nsIDNSRequest + , public nsICancelable { public: NS_DECL_ISUPPORTS - NS_DECL_NSIDNSREQUEST + NS_DECL_NSICANCELABLE nsDNSAsyncRequest(nsHostResolver *res, const nsACString &host, @@ -225,12 +228,13 @@ nsDNSAsyncRequest::OnLookupComplete(nsHostResolver *resolver, NS_RELEASE_THIS(); } -NS_IMPL_THREADSAFE_ISUPPORTS1(nsDNSAsyncRequest, nsIDNSRequest) +NS_IMPL_THREADSAFE_ISUPPORTS1(nsDNSAsyncRequest, nsICancelable) NS_IMETHODIMP -nsDNSAsyncRequest::Cancel() +nsDNSAsyncRequest::Cancel(nsresult reason) { - mResolver->DetachCallback(mHost.get(), mFlags, mAF, this); + NS_ENSURE_ARG(NS_FAILED(reason)); + mResolver->DetachCallback(mHost.get(), mFlags, mAF, this, reason); return NS_OK; } @@ -282,7 +286,8 @@ nsDNSService::~nsDNSService() PR_DestroyLock(mLock); } -NS_IMPL_THREADSAFE_ISUPPORTS2(nsDNSService, nsIDNSService, nsIObserver) +NS_IMPL_THREADSAFE_ISUPPORTS3(nsDNSService, nsIDNSService, nsPIDNSService, + nsIObserver) NS_IMETHODIMP nsDNSService::Init() @@ -366,8 +371,8 @@ NS_IMETHODIMP nsDNSService::AsyncResolve(const nsACString &hostname, PRUint32 flags, nsIDNSListener *listener, - nsIEventQueue *eventQ, - nsIDNSRequest **result) + nsIEventTarget *eventTarget, + nsICancelable **result) { // grab reference to global host resolver and IDN service. beware // simultaneous shutdown!! @@ -390,6 +395,8 @@ nsDNSService::AsyncResolve(const nsACString &hostname, } nsCOMPtr listenerProxy; + nsCOMPtr eventQ = do_QueryInterface(eventTarget); + // TODO(darin): make XPCOM proxies support any nsIEventTarget impl if (eventQ) { rv = NS_GetProxyForObject(eventQ, NS_GET_IID(nsIDNSListener), diff --git a/mozilla/netwerk/dns/src/nsDNSService2.h b/mozilla/netwerk/dns/src/nsDNSService2.h index fa628876a79..e0e0b34285a 100644 --- a/mozilla/netwerk/dns/src/nsDNSService2.h +++ b/mozilla/netwerk/dns/src/nsDNSService2.h @@ -34,7 +34,7 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsIDNSService.h" +#include "nsPIDNSService.h" #include "nsIIDNService.h" #include "nsIObserver.h" #include "nsHostResolver.h" @@ -42,16 +42,17 @@ #include "nsString.h" #include "prlock.h" -class nsDNSService : public nsIDNSService +class nsDNSService : public nsPIDNSService , public nsIObserver { public: NS_DECL_ISUPPORTS + NS_DECL_NSPIDNSSERVICE NS_DECL_NSIDNSSERVICE NS_DECL_NSIOBSERVER nsDNSService(); - virtual ~nsDNSService(); + ~nsDNSService(); private: PRUint16 GetAFForLookup(const nsACString &host); diff --git a/mozilla/netwerk/dns/src/nsHostResolver.cpp b/mozilla/netwerk/dns/src/nsHostResolver.cpp index cfcc68f57bc..4a6fc25ceb0 100644 --- a/mozilla/netwerk/dns/src/nsHostResolver.cpp +++ b/mozilla/netwerk/dns/src/nsHostResolver.cpp @@ -457,7 +457,8 @@ void nsHostResolver::DetachCallback(const char *host, PRUint16 flags, PRUint16 af, - nsResolveHostCallback *callback) + nsResolveHostCallback *callback, + nsresult status) { nsRefPtr rec; { @@ -481,10 +482,10 @@ nsHostResolver::DetachCallback(const char *host, } } - // complete callback with an error code; this would only be done - // if the record was in the process of being resolved. + // complete callback with the given status code; this would only be done if + // the record was in the process of being resolved. if (rec) - callback->OnLookupComplete(this, rec, NS_ERROR_ABORT); + callback->OnLookupComplete(this, rec, status); } nsresult diff --git a/mozilla/netwerk/dns/src/nsHostResolver.h b/mozilla/netwerk/dns/src/nsHostResolver.h index b11b0b95ec8..5470d9676a5 100644 --- a/mozilla/netwerk/dns/src/nsHostResolver.h +++ b/mozilla/netwerk/dns/src/nsHostResolver.h @@ -179,13 +179,13 @@ public: * removes the specified callback from the nsHostRecord for the given * hostname, flags, and address family. these parameters should correspond * to the parameters passed to ResolveHost. this function executes the - * callback if the callback is still pending with the status failure code - * NS_ERROR_ABORT. + * callback if the callback is still pending with the given status. */ void DetachCallback(const char *hostname, PRUint16 flags, PRUint16 af, - nsResolveHostCallback *callback); + nsResolveHostCallback *callback, + nsresult status); /** * values for the flags parameter passed to ResolveHost and DetachCallback diff --git a/mozilla/netwerk/socket/base/nsSOCKSIOLayer.cpp b/mozilla/netwerk/socket/base/nsSOCKSIOLayer.cpp index 8e74089ce04..7e0f75c26e4 100644 --- a/mozilla/netwerk/socket/base/nsSOCKSIOLayer.cpp +++ b/mozilla/netwerk/socket/base/nsSOCKSIOLayer.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsIDNSService.h" +#include "nsIDNSRecord.h" #include "nsISOCKSSocketInfo.h" #include "nsISocketProvider.h" #include "nsSOCKSIOLayer.h" diff --git a/mozilla/netwerk/test/TestDNS.cpp b/mozilla/netwerk/test/TestDNS.cpp index 7a0ac0ccfa4..ee6e0c9d390 100644 --- a/mozilla/netwerk/test/TestDNS.cpp +++ b/mozilla/netwerk/test/TestDNS.cpp @@ -38,7 +38,10 @@ #include #include #include "nsIServiceManager.h" -#include "nsIDNSService.h" +#include "nsPIDNSService.h" +#include "nsIDNSListener.h" +#include "nsIDNSRecord.h" +#include "nsICancelable.h" #include "nsCOMPtr.h" #include "nsString.h" #include "nsNetCID.h" @@ -57,7 +60,7 @@ public: , mIndex(index) {} virtual ~myDNSListener() {} - NS_IMETHOD OnLookupComplete(nsIDNSRequest *request, + NS_IMETHOD OnLookupComplete(nsICancelable *request, nsIDNSRecord *rec, nsresult status) { @@ -99,7 +102,7 @@ int main(int argc, char **argv) return -1; } - nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID); + nsCOMPtr dns = do_GetService(NS_DNSSERVICE_CONTRACTID); if (!dns) return -1; @@ -120,7 +123,7 @@ int main(int argc, char **argv) nsCOMPtr listener = new myDNSListener(argv[i], i); - nsCOMPtr req; + nsCOMPtr req; nsresult rv = dns->AsyncResolve(hostBuf, nsIDNSService::RESOLVE_CANONICAL_NAME, listener, nsnull, getter_AddRefs(req));