From 264834c946c5555c48b1fda985c6513c23773228 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 10 Jan 2004 11:13:06 +0000 Subject: Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places. 2004-01-10 Christian Persch * embed/mozilla/ExternalProtocolHandlers.cpp: Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places. --- ChangeLog | 6 ++++ embed/mozilla/ExternalProtocolHandlers.cpp | 48 ++++++++++++++++++------------ embed/mozilla/ExternalProtocolService.cpp | 2 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 71c1833ef..16b7a827a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-01-10 Christian Persch + + * embed/mozilla/ExternalProtocolHandlers.cpp: + + Use NS_ENSURE_SUCCESS/NS_ENSURE_TRUE at appropriate places. + 2004-01-10 Christian Persch * embed/mozilla/EphyBrowser.cpp: diff --git a/embed/mozilla/ExternalProtocolHandlers.cpp b/embed/mozilla/ExternalProtocolHandlers.cpp index f5dfa3264..8f85f2c01 100644 --- a/embed/mozilla/ExternalProtocolHandlers.cpp +++ b/embed/mozilla/ExternalProtocolHandlers.cpp @@ -16,6 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "ExternalProtocolHandlers.h" #include "nsCOMPtr.h" #include "nsIComponentManager.h" @@ -129,26 +133,30 @@ GBaseProtocolContentHandler::~GBaseProtocolContentHandler() NS_IMETHODIMP GBaseProtocolContentHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval) { + nsresult rv; nsCOMPtr sStream; - nsresult rv = NS_NewStorageStream(1, 16, getter_AddRefs(sStream)); - if (NS_FAILED(rv)) return rv; + rv = NS_NewStorageStream(1, 16, getter_AddRefs(sStream)); + NS_ENSURE_SUCCESS (rv, rv); nsCOMPtr oStream; rv = sStream->GetOutputStream(0, getter_AddRefs(oStream)); + NS_ENSURE_SUCCESS (rv, rv); PRUint32 bytes; - oStream->Write("Dummy stream\0", 13, &bytes); + rv = oStream->Write("Dummy stream\0", 13, &bytes); + NS_ENSURE_SUCCESS (rv, rv); nsCOMPtr iStream; rv = sStream->NewInputStream(0, getter_AddRefs(iStream)); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS (rv, rv); nsCOMPtr channel; rv = NS_NewInputStreamChannel(getter_AddRefs(channel), aURI, iStream, mMimeType, NS_LITERAL_CSTRING("")); - if (NS_FAILED(rv)) return rv; + NS_ENSURE_SUCCESS (rv, rv); NS_IF_ADDREF (*_retval = channel); + return rv; } @@ -158,28 +166,30 @@ NS_IMETHODIMP GBaseProtocolContentHandler::HandleContent ( nsISupports * aWindowContext, nsIRequest *aRequest) { + NS_ENSURE_ARG (aRequest); + nsresult rv = NS_OK; - if (!aRequest) - return NS_ERROR_NULL_POINTER; + // First of all, get the content type and make sure it is a // content type we know how to handle! if (mMimeType.Equals(aContentType)) { nsCOMPtr channel = do_QueryInterface(aRequest); - if(!channel) return NS_ERROR_FAILURE; + NS_ENSURE_TRUE (channel, NS_ERROR_FAILURE); nsCOMPtr uri; - rv = channel->GetURI(getter_AddRefs(uri)); - if (NS_FAILED(rv)) return rv; - - aRequest->Cancel(NS_BINDING_ABORTED); - if (uri) - { - nsCOMPtr ps = - do_GetService (NS_EXTERNALPROTOCOLSERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv) || !ps) return NS_ERROR_FAILURE; - ps->LoadUrl (uri); - } + channel->GetURI(getter_AddRefs(uri)); + NS_ENSURE_TRUE (uri, NS_ERROR_FAILURE); + + rv = aRequest->Cancel(NS_BINDING_ABORTED); + NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE); + + nsCOMPtr ps = + do_GetService (NS_EXTERNALPROTOCOLSERVICE_CONTRACTID); + NS_ENSURE_TRUE (ps, NS_ERROR_FAILURE); + + rv = ps->LoadUrl (uri); } + return rv; } diff --git a/embed/mozilla/ExternalProtocolService.cpp b/embed/mozilla/ExternalProtocolService.cpp index a8a9ce949..9c00e080a 100644 --- a/embed/mozilla/ExternalProtocolService.cpp +++ b/embed/mozilla/ExternalProtocolService.cpp @@ -17,7 +17,7 @@ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #if MOZILLA_SNAPSHOT < 12 -- cgit v1.2.3