Bug 1433958 - Change code that uses nsIURI.setHostAndPort() to use nsIURIMutator r=mayhemer

* Removes setHostAndPort from nsIURIMutator as it only has one use
* Instead, the consumer sets the port to -1 before calling setHostPort()

MozReview-Commit-ID: Jx9UMW440hq

--HG--
extra : rebase_source : cb60e76c905db6bb308ddfd8fa548cc13d3afe06
This commit is contained in:
Valentin Gosu 2018-02-26 20:43:45 +01:00
parent b563071323
commit 76fe90c6ed
2 changed files with 8 additions and 27 deletions

View File

@ -29,6 +29,7 @@
#include "nsDOMString.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsIURIMutator.h"
#include "nsIIOService.h"
#include "nsNetUtil.h"
#include "nsIPrivateBrowsingChannel.h"
@ -926,24 +927,17 @@ nsHTMLDocument::CreateInheritingURIForHost(const nsACString& aHostString)
return nullptr;
}
nsCOMPtr<nsIURI> newURI;
nsresult rv = uri->Clone(getter_AddRefs(newURI));
nsresult rv;
rv = NS_MutateURI(uri)
.SetUserPass(EmptyCString())
.SetPort(-1) // we want to reset the port number if needed.
.SetHostPort(aHostString)
.Finalize(uri);
if (NS_FAILED(rv)) {
return nullptr;
}
rv = newURI->SetUserPass(EmptyCString());
if (NS_FAILED(rv)) {
return nullptr;
}
// We use SetHostAndPort because we want to reset the port number if needed.
rv = newURI->SetHostAndPort(aHostString);
if (NS_FAILED(rv)) {
return nullptr;
}
return newURI.forget();
return uri.forget();
}
already_AddRefed<nsIURI>

View File

@ -149,7 +149,6 @@ interface nsIURISetters : nsIURISetSpec
[must_use] nsIURIMutator setUsername(in AUTF8String aUsername);
[must_use] nsIURIMutator setPassword(in AUTF8String aPassword);
[must_use] nsIURIMutator setHostPort(in AUTF8String aHostPort);
[must_use] nsIURIMutator setHostAndPort(in AUTF8String aHostAndPort);
[must_use] nsIURIMutator setHost(in AUTF8String aHost);
[must_use] nsIURIMutator setPort(in long aPort);
[must_use] nsIURIMutator setPathQueryRef(in AUTF8String aPathQueryRef);
@ -195,12 +194,6 @@ interface nsIURISetters : nsIURISetSpec
return !_to ? NS_ERROR_NULL_POINTER : _to->SetHostPort(aHostPort); \
} \
MOZ_MUST_USE NS_IMETHOD \
SetHostAndPort(const nsACString& aHostAndPort, nsIURIMutator** aMutator) override \
{ \
if (aMutator) NS_ADDREF(*aMutator = this); \
return !_to ? NS_ERROR_NULL_POINTER : _to->SetHostAndPort(aHostAndPort); \
} \
MOZ_MUST_USE NS_IMETHOD \
SetHost(const nsACString& aHost, nsIURIMutator** aMutator) override \
{ \
if (aMutator) NS_ADDREF(*aMutator = this); \
@ -360,12 +353,6 @@ public:
mStatus = mMutator->SetHostPort(aHostPort, nullptr);
return *this;
}
NS_MutateURI& SetHostAndPort(const nsACString& aHostAndPort)
{
NS_ENSURE_SUCCESS(mStatus, *this);
mStatus = mMutator->SetHostAndPort(aHostAndPort, nullptr);
return *this;
}
NS_MutateURI& SetHost(const nsACString& aHost)
{
NS_ENSURE_SUCCESS(mStatus, *this);