Backed out changeset c9dcce0a1068 (bug 1435671) for build bustages on nsIURIMutator.h. CLOSED TREE

This commit is contained in:
nbeleuzu@mozilla.com 2018-02-21 00:06:46 +02:00
Родитель f1850e9354
Коммит 01eef6aff1
18 изменённых файлов: 101 добавлений и 124 удалений

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

@ -79,10 +79,9 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec,
nsresult rv;
nsCOMPtr<nsIURL> surl;
rv = NS_MutateURI(new mozilla::net::nsStandardURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD,
-1, nsCString(aSpec), aCharset,
aBaseURI, nullptr))
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, -1,
nsCString(aSpec), aCharset, aBaseURI, nullptr)
.Finalize(surl);
if (NS_FAILED(rv)) {
return rv;

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

@ -606,8 +606,9 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
mimeInfo->GetPrimaryExtension(primaryExtension);
rv = NS_MutateURI(imgUrl)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileExtension,
primaryExtension, nullptr))
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileExtension,
primaryExtension,
nullptr)
.Finalize(imgUrl);
NS_ENSURE_SUCCESS(rv, rv);
}

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

@ -656,8 +656,9 @@ static nsresult AppendImagePromise(nsITransferable* aTransferable,
mimeInfo->GetPrimaryExtension(primaryExtension);
rv = NS_MutateURI(imgUri)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileExtension,
primaryExtension, nullptr))
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileExtension,
primaryExtension,
nullptr)
.Finalize(imgUrl);
NS_ENSURE_SUCCESS(rv, rv);
}

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

@ -900,8 +900,8 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec,
nsCOMPtr<nsIURI> uri;
rv = NS_MutateURI(new nsHostObjectURI::Mutator())
.SetSpec(aSpec)
.Apply(NS_MutatorMethod(&nsIBlobURIMutator::SetBlobImpl, blob))
.Apply(NS_MutatorMethod(&nsIPrincipalURIMutator::SetPrincipal, principal))
.Apply<nsIBlobURIMutator>(&nsIBlobURIMutator::SetBlobImpl, blob)
.Apply<nsIPrincipalURIMutator>(&nsIPrincipalURIMutator::SetPrincipal, principal)
.Finalize(uri);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -647,11 +647,11 @@ URLWorker::Init(const nsAString& aURL, const Optional<nsAString>& aBase,
}
nsCOMPtr<nsIURI> uri;
rv = NS_MutateURI(new nsStandardURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD,
-1, NS_ConvertUTF16toUTF8(aURL),
nullptr, baseURL, nullptr))
.Finalize(uri);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, -1,
NS_ConvertUTF16toUTF8(aURL),
nullptr, baseURL, nullptr)
.Finalize(uri);
aRv = rv;
if (NS_SUCCEEDED(rv)) {
mStdURL = static_cast<nsStandardURL*>(uri.get());

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

@ -2120,10 +2120,11 @@ nsWebBrowserPersist::CalculateUniqueFilename(nsIURI *aURI, nsCOMPtr<nsIURI>& aOu
}
else
{
return NS_MutateURI(url)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileName,
filename, nullptr))
.Finalize(aOutURI);
return NS_MutateURI(url)
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
filename,
nullptr)
.Finalize(aOutURI);
}
}
@ -2297,10 +2298,11 @@ nsWebBrowserPersist::CalculateAndAppendFileExt(nsIURI *aURI,
}
else
{
return NS_MutateURI(url)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileName,
newFileName, nullptr))
.Finalize(aOutURI);
return NS_MutateURI(url)
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
newFileName,
nullptr)
.Finalize(aOutURI);
}
}

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

@ -97,10 +97,11 @@ nsJARURI::CreateEntryURL(const nsACString& entryFilename,
// Flatten the concatenation, just in case. See bug 128288
nsAutoCString spec(NS_BOGUS_ENTRY_SCHEME + entryFilename);
return NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
spec, charset, nullptr, nullptr))
.Finalize(url);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
spec, charset, nullptr,
nullptr)
.Finalize(url);
}
////////////////////////////////////////////////////////////////////////////////
@ -333,10 +334,11 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL)
nsCOMPtr<nsIURI> entry;
rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY,
-1, nsCString(aSpec), mCharsetHint.get(),
otherJAR->mJAREntry, nullptr))
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
nsCString(aSpec), mCharsetHint.get(),
otherJAR->mJAREntry,
nullptr)
.Finalize(entry);
if (NS_FAILED(rv)) {
return rv;
@ -714,9 +716,10 @@ nsresult
nsJARURI::SetFileNameInternal(const nsACString& fileName)
{
return NS_MutateURI(mJAREntry)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileName,
nsCString(fileName), nullptr))
.Finalize(mJAREntry);
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileName,
nsCString(fileName),
nullptr)
.Finalize(mJAREntry);
}
NS_IMETHODIMP
@ -729,9 +732,10 @@ nsresult
nsJARURI::SetFileBaseNameInternal(const nsACString& fileBaseName)
{
return NS_MutateURI(mJAREntry)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileBaseName,
nsCString(fileBaseName), nullptr))
.Finalize(mJAREntry);
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileBaseName,
nsCString(fileBaseName),
nullptr)
.Finalize(mJAREntry);
}
NS_IMETHODIMP
@ -744,9 +748,10 @@ nsresult
nsJARURI::SetFileExtensionInternal(const nsACString& fileExtension)
{
return NS_MutateURI(mJAREntry)
.Apply(NS_MutatorMethod(&nsIURLMutator::SetFileExtension,
nsCString(fileExtension), nullptr))
.Finalize(mJAREntry);
.Apply<nsIURLMutator>(&nsIURLMutator::SetFileExtension,
nsCString(fileExtension),
nullptr)
.Finalize(mJAREntry);
}
NS_IMETHODIMP

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

@ -11,7 +11,6 @@ interface nsIURIMutator;
%{C++
#include "nsString.h"
#include "nsCOMPtr.h"
#include <functional>
#undef SetPort // XXX Windows!
@ -272,45 +271,6 @@ interface nsIURIMutator : nsIURISetters
%{C++
// This templated struct is used to extract the class type of the method
// passed to NS_MutatorMethod.
template <typename Method>
struct nsMethodTypeTraits;
template <class C, typename R, typename... As>
struct nsMethodTypeTraits<R(C::*)(As...)>
{
typedef C class_type;
};
#ifdef NS_HAVE_STDCALL
template <class C, typename R, typename... As>
struct nsMethodTypeTraits<R(__stdcall C::*)(As...)>
{
typedef C class_type;
};
#endif
// This helper returns a std::function that will be applied on the
// nsIURIMutator. The type of `Interface` will be deduced from the method type.
// aMethod will be called on the target object if it successfully QIs to
// `Interface`, and the arguments will be passed to the call.
template <typename Method, typename... Args>
std::function<nsresult(nsIURIMutator*)>
NS_MutatorMethod(Method aMethod, Args ...aArgs)
{
// Capture arguments by value, otherwise we crash.
return [=](nsIURIMutator* aMutator) {
typedef typename nsMethodTypeTraits<Method>::class_type Interface;
nsresult rv;
nsCOMPtr<Interface> target = do_QueryInterface(aMutator, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = (target->*aMethod)(aArgs...);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
};
}
// This class provides a useful helper that allows chaining of setter operations
class MOZ_STACK_CLASS NS_MutateURI
{
@ -417,7 +377,7 @@ public:
* nsCOMPtr<nsIURI> uri;
* nsresult rv = NS_MutateURI(new URIClass::Mutator())
* .SetSpec(aSpec)
* .Apply(NS_MutatorMethod(&SomeInterface::Method, arg1, arg2))
* .Apply<SomeInterface>(&SomeInterface::Method, arg1, arg2)
* .Finalize(uri);
*
* If mMutator does not implement SomeInterface, do_QueryInterface will fail
@ -425,11 +385,13 @@ public:
* If aMethod does not exist, or if there is a mismatch between argument
* types, or the number of arguments, then there will be a compile error.
*/
NS_MutateURI& Apply(std::function<nsresult(nsIURIMutator*)> aFunction)
template <typename Interface, typename Method, typename... Args>
NS_MutateURI& Apply(Method aMethod, Args ...aArgs)
{
NS_ENSURE_SUCCESS(mStatus, *this);
mStatus = aFunction(mMutator);
nsCOMPtr<Interface> target = do_QueryInterface(mMutator, &mStatus);
NS_ENSURE_SUCCESS(mStatus, *this);
mStatus = (target->*aMethod)(aArgs...);
return *this;
}

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

@ -3063,7 +3063,7 @@ NS_GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI)
// Change the default port to 443:
nsCOMPtr<nsIStandardURL> stdURL = do_QueryInterface(aURI);
if (stdURL) {
mutator.Apply(NS_MutatorMethod(&nsIStandardURLMutator::SetDefaultPort, 443, nullptr));
mutator.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::SetDefaultPort, 443, nullptr);
} else {
// If we don't have a nsStandardURL, fall back to using GetPort/SetPort.
// XXXdholbert Is this function even called with a non-nsStandardURL arg,

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

@ -313,9 +313,10 @@ TRRService::MaybeBootstrap(const nsACString &aPossible, nsACString &aResult)
nsCOMPtr<nsIURI> url;
nsresult rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, 443,
mPrivateURI, nullptr, nullptr, nullptr))
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, 443,
mPrivateURI, nullptr, nullptr,
nullptr)
.Finalize(url);
if (NS_FAILED(rv)) {
LOG(("TRRService::MaybeBootstrap failed to create URI!\n"));

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

@ -178,10 +178,11 @@ nsFileProtocolHandler::NewURI(const nsACString &spec,
#endif
return NS_MutateURI(url)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY,
-1, buf, charset, baseURI, nullptr))
.Finalize(result);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_NO_AUTHORITY, -1,
buf, charset, baseURI,
nullptr)
.Finalize(result);
}
NS_IMETHODIMP

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

@ -185,10 +185,11 @@ nsFtpProtocolHandler::NewURI(const nsACString &aSpec,
nsCOMPtr<nsIURI> url;
return NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
21, nsCString(aSpec), aCharset, aBaseURI, nullptr))
.Finalize(result);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY, 21,
nsCString(aSpec), aCharset, aBaseURI,
nullptr)
.Finalize(result);
}
NS_IMETHODIMP

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

@ -1033,10 +1033,11 @@ nsGIOProtocolHandler::NewURI(const nsACString &aSpec,
}
return NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD,
-1, flatSpec, aOriginCharset, aBaseURI, nullptr))
.Finalize(aResult);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, -1,
flatSpec, aOriginCharset, aBaseURI,
nullptr)
.Finalize(aResult);
}
NS_IMETHODIMP

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

@ -356,12 +356,14 @@ Http2Stream::MakeOriginURL(const nsACString &scheme, const nsACString &origin,
nsCOMPtr<nsIURI> &url)
{
return NS_MutateURI(new nsStandardURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
scheme.EqualsLiteral("http") ? NS_HTTP_DEFAULT_PORT
: NS_HTTPS_DEFAULT_PORT,
nsCString(origin), nullptr, nullptr, nullptr))
.Finalize(url);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
scheme.EqualsLiteral("http") ?
NS_HTTP_DEFAULT_PORT :
NS_HTTPS_DEFAULT_PORT,
nsCString(origin), nullptr, nullptr,
nullptr)
.Finalize(url);
}
void

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

@ -137,11 +137,11 @@ NewURI(const nsACString &aSpec,
nsIURI **aURI)
{
return NS_MutateURI(new nsStandardURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
aDefaultPort, nsCString(aSpec), aCharset,
aBaseURI, nullptr))
.Finalize(aURI);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
aDefaultPort, nsCString(aSpec), aCharset, aBaseURI,
nullptr)
.Finalize(aURI);
}
#ifdef ANDROID

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

@ -235,10 +235,11 @@ SubstitutingProtocolHandler::NewURI(const nsACString &aSpec,
spec.Append(last, src-last);
return NS_MutateURI(new SubstitutingURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD,
-1, spec, aCharset, aBaseURI, nullptr))
.Finalize(result);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, -1,
spec, aCharset, aBaseURI,
nullptr)
.Finalize(result);
}
nsresult

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

@ -307,11 +307,11 @@ BaseWebSocketChannel::NewURI(const nsACString & aSpec, const char *aOriginCharse
return rv;
return NS_MutateURI(new nsStandardURL::Mutator())
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY,
port, nsCString(aSpec), aOriginCharset,
aBaseURI, nullptr))
.Finalize(_retval);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_AUTHORITY, port,
nsCString(aSpec), aOriginCharset, aBaseURI,
nullptr)
.Finalize(_retval);
}
NS_IMETHODIMP

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

@ -142,11 +142,11 @@ nsAndroidProtocolHandler::NewURI(const nsACString &aSpec,
nsIURI **result)
{
return NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID)
.Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD,
-1, nsCString(aSpec), aCharset,
aBaseURI, nullptr))
.Finalize(result);
.Apply<nsIStandardURLMutator>(&nsIStandardURLMutator::Init,
nsIStandardURL::URLTYPE_STANDARD, -1,
nsCString(aSpec), aCharset, aBaseURI,
nullptr)
.Finalize(result);
}
NS_IMETHODIMP