From 01eef6aff19de9eb1f30500f4fbb949bf946677c Mon Sep 17 00:00:00 2001 From: "nbeleuzu@mozilla.com" Date: Wed, 21 Feb 2018 00:06:46 +0200 Subject: [PATCH] Backed out changeset c9dcce0a1068 (bug 1435671) for build bustages on nsIURIMutator.h. CLOSED TREE --- chrome/nsChromeProtocolHandler.cpp | 7 ++- dom/base/nsContentAreaDragDrop.cpp | 5 +- dom/base/nsCopySupport.cpp | 5 +- dom/file/nsHostObjectProtocolHandler.cpp | 4 +- dom/url/URLWorker.cpp | 10 ++-- dom/webbrowserpersist/nsWebBrowserPersist.cpp | 18 +++---- modules/libjar/nsJARURI.cpp | 39 ++++++++------- netwerk/base/nsIURIMutator.idl | 48 ++----------------- netwerk/base/nsNetUtil.cpp | 2 +- netwerk/dns/TRRService.cpp | 7 +-- .../protocol/file/nsFileProtocolHandler.cpp | 9 ++-- netwerk/protocol/ftp/nsFtpProtocolHandler.cpp | 9 ++-- netwerk/protocol/gio/nsGIOProtocolHandler.cpp | 9 ++-- netwerk/protocol/http/Http2Stream.cpp | 14 +++--- netwerk/protocol/http/nsHttpHandler.cpp | 10 ++-- .../res/SubstitutingProtocolHandler.cpp | 9 ++-- .../websocket/BaseWebSocketChannel.cpp | 10 ++-- widget/android/nsAndroidProtocolHandler.cpp | 10 ++-- 18 files changed, 101 insertions(+), 124 deletions(-) diff --git a/chrome/nsChromeProtocolHandler.cpp b/chrome/nsChromeProtocolHandler.cpp index 2145cbeac074..3ac13228d344 100644 --- a/chrome/nsChromeProtocolHandler.cpp +++ b/chrome/nsChromeProtocolHandler.cpp @@ -79,10 +79,9 @@ nsChromeProtocolHandler::NewURI(const nsACString &aSpec, nsresult rv; nsCOMPtr 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::Init, + nsIStandardURL::URLTYPE_STANDARD, -1, + nsCString(aSpec), aCharset, aBaseURI, nullptr) .Finalize(surl); if (NS_FAILED(rv)) { return rv; diff --git a/dom/base/nsContentAreaDragDrop.cpp b/dom/base/nsContentAreaDragDrop.cpp index 69b77596ccdb..d848b3bac327 100644 --- a/dom/base/nsContentAreaDragDrop.cpp +++ b/dom/base/nsContentAreaDragDrop.cpp @@ -606,8 +606,9 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer, mimeInfo->GetPrimaryExtension(primaryExtension); rv = NS_MutateURI(imgUrl) - .Apply(NS_MutatorMethod(&nsIURLMutator::SetFileExtension, - primaryExtension, nullptr)) + .Apply(&nsIURLMutator::SetFileExtension, + primaryExtension, + nullptr) .Finalize(imgUrl); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/dom/base/nsCopySupport.cpp b/dom/base/nsCopySupport.cpp index 0f680c21c126..2be487052062 100644 --- a/dom/base/nsCopySupport.cpp +++ b/dom/base/nsCopySupport.cpp @@ -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::SetFileExtension, + primaryExtension, + nullptr) .Finalize(imgUrl); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/dom/file/nsHostObjectProtocolHandler.cpp b/dom/file/nsHostObjectProtocolHandler.cpp index 900d06fb59e1..2643d93ba629 100644 --- a/dom/file/nsHostObjectProtocolHandler.cpp +++ b/dom/file/nsHostObjectProtocolHandler.cpp @@ -900,8 +900,8 @@ nsHostObjectProtocolHandler::NewURI(const nsACString& aSpec, nsCOMPtr uri; rv = NS_MutateURI(new nsHostObjectURI::Mutator()) .SetSpec(aSpec) - .Apply(NS_MutatorMethod(&nsIBlobURIMutator::SetBlobImpl, blob)) - .Apply(NS_MutatorMethod(&nsIPrincipalURIMutator::SetPrincipal, principal)) + .Apply(&nsIBlobURIMutator::SetBlobImpl, blob) + .Apply(&nsIPrincipalURIMutator::SetPrincipal, principal) .Finalize(uri); NS_ENSURE_SUCCESS(rv, rv); diff --git a/dom/url/URLWorker.cpp b/dom/url/URLWorker.cpp index 3cceeb25193e..7da2f5d970e4 100644 --- a/dom/url/URLWorker.cpp +++ b/dom/url/URLWorker.cpp @@ -647,11 +647,11 @@ URLWorker::Init(const nsAString& aURL, const Optional& aBase, } nsCOMPtr 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::Init, + nsIStandardURL::URLTYPE_STANDARD, -1, + NS_ConvertUTF16toUTF8(aURL), + nullptr, baseURL, nullptr) + .Finalize(uri); aRv = rv; if (NS_SUCCEEDED(rv)) { mStdURL = static_cast(uri.get()); diff --git a/dom/webbrowserpersist/nsWebBrowserPersist.cpp b/dom/webbrowserpersist/nsWebBrowserPersist.cpp index 5a9c53576df3..c388c97a7131 100644 --- a/dom/webbrowserpersist/nsWebBrowserPersist.cpp +++ b/dom/webbrowserpersist/nsWebBrowserPersist.cpp @@ -2120,10 +2120,11 @@ nsWebBrowserPersist::CalculateUniqueFilename(nsIURI *aURI, nsCOMPtr& aOu } else { - return NS_MutateURI(url) - .Apply(NS_MutatorMethod(&nsIURLMutator::SetFileName, - filename, nullptr)) - .Finalize(aOutURI); + return NS_MutateURI(url) + .Apply(&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::SetFileName, + newFileName, + nullptr) + .Finalize(aOutURI); } } diff --git a/modules/libjar/nsJARURI.cpp b/modules/libjar/nsJARURI.cpp index 1ff9ca1bccd1..d87e55d88a78 100644 --- a/modules/libjar/nsJARURI.cpp +++ b/modules/libjar/nsJARURI.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, + spec, charset, nullptr, + nullptr) + .Finalize(url); } //////////////////////////////////////////////////////////////////////////////// @@ -333,10 +334,11 @@ nsJARURI::SetSpecWithBase(const nsACString &aSpec, nsIURI* aBaseURL) nsCOMPtr 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::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::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::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::SetFileExtension, + nsCString(fileExtension), + nullptr) + .Finalize(mJAREntry); } NS_IMETHODIMP diff --git a/netwerk/base/nsIURIMutator.idl b/netwerk/base/nsIURIMutator.idl index 09762fc07896..797418754afe 100644 --- a/netwerk/base/nsIURIMutator.idl +++ b/netwerk/base/nsIURIMutator.idl @@ -11,7 +11,6 @@ interface nsIURIMutator; %{C++ #include "nsString.h" #include "nsCOMPtr.h" -#include #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 -struct nsMethodTypeTraits; - -template -struct nsMethodTypeTraits -{ - typedef C class_type; -}; - -#ifdef NS_HAVE_STDCALL -template -struct nsMethodTypeTraits -{ - 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 -std::function -NS_MutatorMethod(Method aMethod, Args ...aArgs) -{ - // Capture arguments by value, otherwise we crash. - return [=](nsIURIMutator* aMutator) { - typedef typename nsMethodTypeTraits::class_type Interface; - nsresult rv; - nsCOMPtr 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 uri; * nsresult rv = NS_MutateURI(new URIClass::Mutator()) * .SetSpec(aSpec) - * .Apply(NS_MutatorMethod(&SomeInterface::Method, arg1, arg2)) + * .Apply(&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 aFunction) + template + NS_MutateURI& Apply(Method aMethod, Args ...aArgs) { NS_ENSURE_SUCCESS(mStatus, *this); - mStatus = aFunction(mMutator); + nsCOMPtr target = do_QueryInterface(mMutator, &mStatus); NS_ENSURE_SUCCESS(mStatus, *this); + mStatus = (target->*aMethod)(aArgs...); return *this; } diff --git a/netwerk/base/nsNetUtil.cpp b/netwerk/base/nsNetUtil.cpp index 9f76c94cd7f3..82eeecba49ce 100644 --- a/netwerk/base/nsNetUtil.cpp +++ b/netwerk/base/nsNetUtil.cpp @@ -3063,7 +3063,7 @@ NS_GetSecureUpgradedURI(nsIURI* aURI, nsIURI** aUpgradedURI) // Change the default port to 443: nsCOMPtr stdURL = do_QueryInterface(aURI); if (stdURL) { - mutator.Apply(NS_MutatorMethod(&nsIStandardURLMutator::SetDefaultPort, 443, nullptr)); + mutator.Apply(&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, diff --git a/netwerk/dns/TRRService.cpp b/netwerk/dns/TRRService.cpp index b8df905088e2..a73c0c917346 100644 --- a/netwerk/dns/TRRService.cpp +++ b/netwerk/dns/TRRService.cpp @@ -313,9 +313,10 @@ TRRService::MaybeBootstrap(const nsACString &aPossible, nsACString &aResult) nsCOMPtr url; nsresult rv = NS_MutateURI(NS_STANDARDURLMUTATOR_CONTRACTID) - .Apply(NS_MutatorMethod(&nsIStandardURLMutator::Init, - nsIStandardURL::URLTYPE_STANDARD, 443, - mPrivateURI, nullptr, nullptr, nullptr)) + .Apply(&nsIStandardURLMutator::Init, + nsIStandardURL::URLTYPE_STANDARD, 443, + mPrivateURI, nullptr, nullptr, + nullptr) .Finalize(url); if (NS_FAILED(rv)) { LOG(("TRRService::MaybeBootstrap failed to create URI!\n")); diff --git a/netwerk/protocol/file/nsFileProtocolHandler.cpp b/netwerk/protocol/file/nsFileProtocolHandler.cpp index 0ea24576aa12..1483955bc66b 100644 --- a/netwerk/protocol/file/nsFileProtocolHandler.cpp +++ b/netwerk/protocol/file/nsFileProtocolHandler.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_NO_AUTHORITY, -1, + buf, charset, baseURI, + nullptr) + .Finalize(result); } NS_IMETHODIMP diff --git a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp index 6feb5bbdc65b..d835f850afe0 100644 --- a/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp +++ b/netwerk/protocol/ftp/nsFtpProtocolHandler.cpp @@ -185,10 +185,11 @@ nsFtpProtocolHandler::NewURI(const nsACString &aSpec, nsCOMPtr 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::Init, + nsIStandardURL::URLTYPE_AUTHORITY, 21, + nsCString(aSpec), aCharset, aBaseURI, + nullptr) + .Finalize(result); } NS_IMETHODIMP diff --git a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp index 1f0b8aa89de5..b14fa0b42496 100644 --- a/netwerk/protocol/gio/nsGIOProtocolHandler.cpp +++ b/netwerk/protocol/gio/nsGIOProtocolHandler.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_STANDARD, -1, + flatSpec, aOriginCharset, aBaseURI, + nullptr) + .Finalize(aResult); } NS_IMETHODIMP diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 802193b2cc7d..f6d45f01e2c2 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -356,12 +356,14 @@ Http2Stream::MakeOriginURL(const nsACString &scheme, const nsACString &origin, nsCOMPtr &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::Init, + nsIStandardURL::URLTYPE_AUTHORITY, + scheme.EqualsLiteral("http") ? + NS_HTTP_DEFAULT_PORT : + NS_HTTPS_DEFAULT_PORT, + nsCString(origin), nullptr, nullptr, + nullptr) + .Finalize(url); } void diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 2dc5571ffbc8..997816af948e 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_AUTHORITY, + aDefaultPort, nsCString(aSpec), aCharset, aBaseURI, + nullptr) + .Finalize(aURI); } #ifdef ANDROID diff --git a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp index 64737076451e..339cb1ae0b55 100644 --- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_STANDARD, -1, + spec, aCharset, aBaseURI, + nullptr) + .Finalize(result); } nsresult diff --git a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp index 9cc3f1df914a..a6112dd22270 100644 --- a/netwerk/protocol/websocket/BaseWebSocketChannel.cpp +++ b/netwerk/protocol/websocket/BaseWebSocketChannel.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_AUTHORITY, port, + nsCString(aSpec), aOriginCharset, aBaseURI, + nullptr) + .Finalize(_retval); } NS_IMETHODIMP diff --git a/widget/android/nsAndroidProtocolHandler.cpp b/widget/android/nsAndroidProtocolHandler.cpp index f64d514d31ed..f193e42f1984 100644 --- a/widget/android/nsAndroidProtocolHandler.cpp +++ b/widget/android/nsAndroidProtocolHandler.cpp @@ -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::Init, + nsIStandardURL::URLTYPE_STANDARD, -1, + nsCString(aSpec), aCharset, aBaseURI, + nullptr) + .Finalize(result); } NS_IMETHODIMP