Bug 1259018 - Part a: Use early returns in nsExternalProtocolHandler::NewChannel2; r=jst

This commit is contained in:
Ms2ger 2016-03-25 09:17:32 +01:00
Родитель 0d901b89d3
Коммит 0f69c09bbe
1 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -426,33 +426,30 @@ NS_IMETHODIMP nsExternalProtocolHandler::NewURI(const nsACString &aSpec,
NS_IMETHODIMP
nsExternalProtocolHandler::NewChannel2(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsIChannel** _retval)
nsIChannel** aRetval)
{
NS_ENSURE_TRUE(aRetval, NS_ERROR_UNKNOWN_PROTOCOL);
// Only try to return a channel if we have a protocol handler for the url.
// nsOSHelperAppService::LoadUriInternal relies on this to check trustedness
// for some platforms at least. (win uses ::ShellExecute and unix uses
// gnome_url_show.)
bool haveExternalHandler = HaveExternalProtocolHandler(aURI);
if (haveExternalHandler)
{
nsCOMPtr<nsIChannel> channel = new nsExtProtocolChannel();
if (!channel) return NS_ERROR_OUT_OF_MEMORY;
((nsExtProtocolChannel*) channel.get())->SetURI(aURI);
channel->SetOriginalURI(aURI);
// set the loadInfo on the new channel
((nsExtProtocolChannel*) channel.get())->SetLoadInfo(aLoadInfo);
if (_retval)
{
*_retval = channel;
NS_IF_ADDREF(*_retval);
return NS_OK;
}
if (!HaveExternalProtocolHandler(aURI)) {
return NS_ERROR_UNKNOWN_PROTOCOL;
}
return NS_ERROR_UNKNOWN_PROTOCOL;
nsCOMPtr<nsIChannel> channel = new nsExtProtocolChannel();
if (!channel) return NS_ERROR_OUT_OF_MEMORY;
((nsExtProtocolChannel*) channel.get())->SetURI(aURI);
channel->SetOriginalURI(aURI);
// set the loadInfo on the new channel
((nsExtProtocolChannel*) channel.get())->SetLoadInfo(aLoadInfo);
*aRetval = channel;
NS_IF_ADDREF(*aRetval);
return NS_OK;
}
NS_IMETHODIMP nsExternalProtocolHandler::NewChannel(nsIURI *aURI, nsIChannel **_retval)