author | Nicholas Nethercote <nnethercote@mozilla.com> |
Fri, 26 Aug 2016 16:40:57 +1000 | |
changeset 313375 | fbe1cc85a7e6b96ba60f8b61f5721f18ab2ee2d6 |
parent 313374 | daea33341cc4ede84bea27d9c682230c09f70dcb |
child 313376 | ee83d585ff9db5e419c9ed5bf21884c8689df19a |
push id | 32169 |
push user | cbook@mozilla.com |
push date | Fri, 09 Sep 2016 10:20:44 +0000 |
treeherder | autoland@68ae5adc4232 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | hurley, dragana |
bugs | 1297300 |
milestone | 51.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/chrome/nsChromeRegistryChrome.cpp +++ b/chrome/nsChromeRegistryChrome.cpp @@ -421,17 +421,18 @@ nsChromeRegistryChrome::SendRegisteredCh NS_ENSURE_TRUE_VOID(io); nsCOMPtr<nsIProtocolHandler> ph; nsresult rv = io->GetProtocolHandler("resource", getter_AddRefs(ph)); NS_ENSURE_SUCCESS_VOID(rv); nsCOMPtr<nsIResProtocolHandler> irph (do_QueryInterface(ph)); nsResProtocolHandler* rph = static_cast<nsResProtocolHandler*>(irph.get()); - rph->CollectSubstitutions(resources); + rv = rph->CollectSubstitutions(resources); + NS_ENSURE_SUCCESS_VOID(rv); } for (auto iter = mOverrideTable.Iter(); !iter.Done(); iter.Next()) { SerializedURI chromeURI, overrideURI; SerializeURI(iter.Key(), chromeURI); SerializeURI(iter.UserData(), overrideURI);
--- a/netwerk/base/nsPACMan.cpp +++ b/netwerk/base/nsPACMan.cpp @@ -448,17 +448,18 @@ nsPACMan::StartLoading() nsCOMPtr<nsIIOService> ios = do_GetIOService(); if (ios) { nsCOMPtr<nsIChannel> channel; nsCOMPtr<nsIURI> pacURI; NS_NewURI(getter_AddRefs(pacURI), mPACURISpec); // NOTE: This results in GetProxyForURI being called if (pacURI) { - pacURI->GetSpec(mNormalPACURISpec); + nsresult rv = pacURI->GetSpec(mNormalPACURISpec); + MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv)); NS_NewChannel(getter_AddRefs(channel), pacURI, nsContentUtils::GetSystemPrincipal(), nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL, nsIContentPolicy::TYPE_OTHER, nullptr, // aLoadGroup nullptr, // aCallbacks nsIRequest::LOAD_NORMAL,
--- a/netwerk/base/nsPACMan.h +++ b/netwerk/base/nsPACMan.h @@ -156,21 +156,26 @@ public: */ bool IsPACURI(const nsACString &spec) { return mPACURISpec.Equals(spec) || mPACURIRedirectSpec.Equals(spec) || mNormalPACURISpec.Equals(spec); } bool IsPACURI(nsIURI *uri) { - if (mPACURISpec.IsEmpty() && mPACURIRedirectSpec.IsEmpty()) + if (mPACURISpec.IsEmpty() && mPACURIRedirectSpec.IsEmpty()) { return false; + } nsAutoCString tmp; - uri->GetSpec(tmp); + nsresult rv = uri->GetSpec(tmp); + if (NS_FAILED(rv)) { + return false; + } + return IsPACURI(tmp); } nsresult Init(nsISystemProxySettings *); static nsPACMan *sInstance; // PAC thread operations only void ProcessPendingQ();
--- a/netwerk/base/nsURIHashKey.h +++ b/netwerk/base/nsURIHashKey.h @@ -4,16 +4,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #ifndef nsURIHashKey_h__ #define nsURIHashKey_h__ #include "PLDHashTable.h" #include "nsCOMPtr.h" #include "nsIURI.h" #include "nsHashKeys.h" +#include "mozilla/Unused.h" /** * Hashtable key class to use with nsTHashtable/nsBaseHashtable */ class nsURIHashKey : public PLDHashEntryHdr { public: typedef nsIURI* KeyType; @@ -40,17 +41,19 @@ public: static const nsIURI* KeyToPointer(nsIURI* aKey) { return aKey; } static PLDHashNumber HashKey(const nsIURI* aKey) { if (!aKey) { // If the key is null, return hash for empty string. return mozilla::HashString(EmptyCString()); } nsAutoCString spec; - const_cast<nsIURI*>(aKey)->GetSpec(spec); + // If GetSpec() fails, ignoring the failure and proceeding with an + // empty |spec| seems like the best thing to do. + mozilla::Unused << const_cast<nsIURI*>(aKey)->GetSpec(spec); return mozilla::HashString(spec); } enum { ALLOW_MEMMOVE = true }; protected: nsCOMPtr<nsIURI> mKey; };
--- a/netwerk/ipc/NeckoChild.cpp +++ b/netwerk/ipc/NeckoChild.cpp @@ -423,21 +423,21 @@ NeckoChild::RecvAppOfflineStatus(const u if (gIOService) { gIOService->SetAppOfflineInternal(aId, aOffline ? nsIAppOfflineInfo::OFFLINE : nsIAppOfflineInfo::ONLINE); } return true; } bool -NeckoChild::RecvSpeculativeConnectRequest(const nsCString& aNotificationData) +NeckoChild::RecvSpeculativeConnectRequest() { nsCOMPtr<nsIObserverService> obsService = services::GetObserverService(); if (obsService) { obsService->NotifyObservers(nullptr, "speculative-connect-request", - NS_ConvertUTF8toUTF16(aNotificationData).get()); + nullptr); } return true; } } // namespace net } // namespace mozilla
--- a/netwerk/ipc/NeckoChild.h +++ b/netwerk/ipc/NeckoChild.h @@ -89,17 +89,17 @@ protected: virtual bool DeallocPWebSocketEventListenerChild(PWebSocketEventListenerChild*) override; /* Predictor Messsages */ virtual bool RecvPredOnPredictPrefetch(const URIParams& aURI, const uint32_t& aHttpStatus) override; virtual bool RecvPredOnPredictPreconnect(const URIParams& aURI) override; virtual bool RecvPredOnPredictDNS(const URIParams& aURI) override; - virtual bool RecvSpeculativeConnectRequest(const nsCString& aNotificationData) override; + virtual bool RecvSpeculativeConnectRequest() override; }; /** * Reference to the PNecko Child protocol. * Null if this is not a content process. */ extern PNeckoChild *gNeckoChild;
--- a/netwerk/ipc/PNecko.ipdl +++ b/netwerk/ipc/PNecko.ipdl @@ -127,17 +127,17 @@ child: // Notifies child that a given app is now offline (or online) async AppOfflineStatus(uint32_t appId, bool offline); /* Predictor Methods */ async PredOnPredictPrefetch(URIParams uri, uint32_t httpStatus); async PredOnPredictPreconnect(URIParams uri); async PredOnPredictDNS(URIParams uri); - async SpeculativeConnectRequest(nsCString notificationData); + async SpeculativeConnectRequest(); async PTransportProvider(); both: // Actually we need PTCPSocket() for parent. But ipdl disallows us having different // signatures on parent and child. So when constructing the parent side object, we just // leave host/port unused. async PTCPSocket(nsString host, uint16_t port);
--- a/netwerk/ipc/RemoteOpenFileChild.cpp +++ b/netwerk/ipc/RemoteOpenFileChild.cpp @@ -140,17 +140,18 @@ RemoteOpenFileChild::Init(nsIURI* aRemot // scheme of URI is not file:// so this is not a nsIFileURL. Convert to one. nsCOMPtr<nsIURI> clonedURI; rv = aRemoteOpenUri->Clone(getter_AddRefs(clonedURI)); NS_ENSURE_SUCCESS(rv, rv); clonedURI->SetScheme(NS_LITERAL_CSTRING("file")); nsAutoCString spec; - clonedURI->GetSpec(spec); + rv = clonedURI->GetSpec(spec); + NS_ENSURE_SUCCESS(rv, rv); rv = NS_NewURI(getter_AddRefs(mURI), spec); NS_ENSURE_SUCCESS(rv, rv); // Get nsIFile nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(mURI); if (!fileURL) { return NS_ERROR_UNEXPECTED;
--- a/netwerk/protocol/device/nsDeviceChannel.cpp +++ b/netwerk/protocol/device/nsDeviceChannel.cpp @@ -76,17 +76,18 @@ nsDeviceChannel::OpenContentStream(bool nsCOMPtr<nsIURI> uri = nsBaseChannel::URI(); *aStream = nullptr; *aChannel = nullptr; NS_NAMED_LITERAL_CSTRING(width, "width="); NS_NAMED_LITERAL_CSTRING(height, "height="); nsAutoCString spec; - uri->GetSpec(spec); + nsresult rv = uri->GetSpec(spec); + NS_ENSURE_SUCCESS(rv, rv); nsAutoCString type; RefPtr<nsDeviceCaptureProvider> capture; nsCaptureParams captureParams; captureParams.camera = 0; if (kNotFound != spec.Find(NS_LITERAL_CSTRING("type=image/png"), true,
--- a/netwerk/protocol/ftp/FTPChannelChild.cpp +++ b/netwerk/protocol/ftp/FTPChannelChild.cpp @@ -315,21 +315,28 @@ FTPChannelChild::DoOnStartRequest(const mContentLength = aContentLength; SetContentType(aContentType); mLastModifiedTime = aLastModified; mEntityID = aEntityID; nsCString spec; nsCOMPtr<nsIURI> uri = DeserializeURI(aURI); - uri->GetSpec(spec); - nsBaseChannel::URI()->SetSpec(spec); + nsresult rv = uri->GetSpec(spec); + if (NS_SUCCEEDED(rv)) { + rv = nsBaseChannel::URI()->SetSpec(spec); + if (NS_FAILED(rv)) { + Cancel(rv); + } + } else { + Cancel(rv); + } AutoEventEnqueuer ensureSerialDispatch(mEventQ); - nsresult rv = mListener->OnStartRequest(this, mListenerContext); + rv = mListener->OnStartRequest(this, mListenerContext); if (NS_FAILED(rv)) Cancel(rv); if (mDivertingToParent) { mListener = nullptr; mListenerContext = nullptr; if (mLoadGroup) { mLoadGroup->RemoveRequest(this, nullptr, mStatus);
--- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -2201,17 +2201,17 @@ HttpBaseChannel::AddSecurityMessage(cons rv = nsContentUtils::GetLocalizedString( nsContentUtils::eSECURITY_PROPERTIES, NS_ConvertUTF16toUTF8(aMessageTag).get(), errorText); NS_ENSURE_SUCCESS(rv, rv); nsAutoCString spec; if (mURI) { - mURI->GetSpec(spec); + spec = mURI->GetSpecOrDefault(); } nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID)); error->InitWithWindowID(errorText, NS_ConvertUTF8toUTF16(spec), EmptyString(), 0, 0, nsIScriptError::warningFlag, NS_ConvertUTF16toUTF8(aMessageCategory), innerWindowID); console->LogMessage(error);
--- a/netwerk/protocol/http/nsCORSListenerProxy.cpp +++ b/netwerk/protocol/http/nsCORSListenerProxy.cpp @@ -74,17 +74,17 @@ LogBlockedRequest(nsIRequest* aRequest, return; } nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest); nsCOMPtr<nsIURI> aUri; channel->GetURI(getter_AddRefs(aUri)); nsAutoCString spec; if (aUri) { - aUri->GetSpec(spec); + spec = aUri->GetSpecOrDefault(); } // Generate the error message nsXPIDLString blockedMessage; NS_ConvertUTF8toUTF16 specUTF16(spec); const char16_t* params[] = { specUTF16.get(), aParam }; rv = nsContentUtils::FormatLocalizedString(nsContentUtils::eSECURITY_PROPERTIES, aProperty,
--- a/netwerk/protocol/http/nsHttpChannel.cpp +++ b/netwerk/protocol/http/nsHttpChannel.cpp @@ -940,19 +940,17 @@ CallTypeSniffers(void *aClosure, const u // Helper Function to report messages to the console when loading // a resource was blocked due to a MIME type mismatch. void ReportTypeBlocking(nsIURI* aURI, nsILoadInfo* aLoadInfo, const char* aMessageName) { - nsAutoCString spec; - aURI->GetSpec(spec); - NS_ConvertUTF8toUTF16 specUTF16(spec); + NS_ConvertUTF8toUTF16 specUTF16(aURI->GetSpecOrDefault()); const char16_t* params[] = { specUTF16.get() }; nsCOMPtr<nsIDocument> doc; if (aLoadInfo) { nsCOMPtr<nsIDOMDocument> domDoc; aLoadInfo->GetLoadingDocument(getter_AddRefs(domDoc)); if (domDoc) { doc = do_QueryInterface(domDoc); }
--- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -2207,25 +2207,22 @@ nsHttpHandler::SpeculativeConnectInterna } if (!mHandlerActive) return NS_OK; MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIObserverService> obsService = services::GetObserverService(); if (mDebugObservations && obsService) { - // this is basically used for test coverage of an otherwise 'hintable' feature - nsAutoCString spec; - aURI->GetSpec(spec); - spec.Append(anonymous ? NS_LITERAL_CSTRING("[A]") : NS_LITERAL_CSTRING("[.]")); - obsService->NotifyObservers(nullptr, - "speculative-connect-request", - NS_ConvertUTF8toUTF16(spec).get()); + // this is basically used for test coverage of an otherwise 'hintable' + // feature + obsService->NotifyObservers(nullptr, "speculative-connect-request", + nullptr); if (!IsNeckoChild() && gNeckoParent) { - Unused << gNeckoParent->SendSpeculativeConnectRequest(spec); + Unused << gNeckoParent->SendSpeculativeConnectRequest(); } } nsISiteSecurityService* sss = gHttpHandler->GetSSService(); bool isStsHost = false; if (!sss) return NS_OK;
--- a/netwerk/protocol/res/SubstitutingProtocolHandler.cpp +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.cpp @@ -108,55 +108,61 @@ SubstitutingProtocolHandler::ConstructIn mIOService = do_GetIOService(&rv); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && mIOService); } // // IPC marshalling. // -void +nsresult SubstitutingProtocolHandler::CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aMappings) { for (auto iter = mSubstitutions.ConstIter(); !iter.Done(); iter.Next()) { nsCOMPtr<nsIURI> uri = iter.Data(); SerializedURI serialized; if (uri) { - uri->GetSpec(serialized.spec); + nsresult rv = uri->GetSpec(serialized.spec); + NS_ENSURE_SUCCESS(rv, rv); uri->GetOriginCharset(serialized.charset); } SubstitutionMapping substitution = { mScheme, nsCString(iter.Key()), serialized }; aMappings.AppendElement(substitution); } + + return NS_OK; } -void +nsresult SubstitutingProtocolHandler::SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI) { if (GeckoProcessType_Content == XRE_GetProcessType()) { - return; + return NS_OK; } nsTArray<ContentParent*> parents; ContentParent::GetAll(parents); if (!parents.Length()) { - return; + return NS_OK; } SubstitutionMapping mapping; mapping.scheme = mScheme; mapping.path = aRoot; if (aBaseURI) { - aBaseURI->GetSpec(mapping.resolvedURI.spec); + nsresult rv = aBaseURI->GetSpec(mapping.resolvedURI.spec); + NS_ENSURE_SUCCESS(rv, rv); aBaseURI->GetOriginCharset(mapping.resolvedURI.charset); } for (uint32_t i = 0; i < parents.Length(); i++) { Unused << parents[i]->SendRegisterChromeItem(mapping); } + + return NS_OK; } //---------------------------------------------------------------------------- // nsIProtocolHandler //---------------------------------------------------------------------------- nsresult SubstitutingProtocolHandler::GetScheme(nsACString &result) @@ -278,48 +284,45 @@ SubstitutingProtocolHandler::AllowPort(i // nsISubstitutingProtocolHandler //---------------------------------------------------------------------------- nsresult SubstitutingProtocolHandler::SetSubstitution(const nsACString& root, nsIURI *baseURI) { if (!baseURI) { mSubstitutions.Remove(root); - SendSubstitution(root, baseURI); - return NS_OK; + return SendSubstitution(root, baseURI); } // If baseURI isn't a same-scheme URI, we can set the substitution immediately. nsAutoCString scheme; nsresult rv = baseURI->GetScheme(scheme); NS_ENSURE_SUCCESS(rv, rv); if (!scheme.Equals(mScheme)) { if (mEnforceFileOrJar && !scheme.EqualsLiteral("file") && !scheme.EqualsLiteral("jar") && !scheme.EqualsLiteral("app")) { NS_WARNING("Refusing to create substituting URI to non-file:// target"); return NS_ERROR_INVALID_ARG; } mSubstitutions.Put(root, baseURI); - SendSubstitution(root, baseURI); - return NS_OK; + return SendSubstitution(root, baseURI); } // baseURI is a same-type substituting URI, let's resolve it first. nsAutoCString newBase; rv = ResolveURI(baseURI, newBase); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIURI> newBaseURI; rv = mIOService->NewURI(newBase, nullptr, nullptr, getter_AddRefs(newBaseURI)); NS_ENSURE_SUCCESS(rv, rv); mSubstitutions.Put(root, newBaseURI); - SendSubstitution(root, newBaseURI); - return NS_OK; + return SendSubstitution(root, newBaseURI); } nsresult SubstitutingProtocolHandler::GetSubstitution(const nsACString& root, nsIURI **result) { NS_ENSURE_ARG_POINTER(result); if (mSubstitutions.Get(root, result))
--- a/netwerk/protocol/res/SubstitutingProtocolHandler.h +++ b/netwerk/protocol/res/SubstitutingProtocolHandler.h @@ -32,23 +32,23 @@ public: explicit SubstitutingProtocolHandler(const char* aScheme); NS_INLINE_DECL_REFCOUNTING(SubstitutingProtocolHandler); NS_DECL_NON_VIRTUAL_NSIPROTOCOLHANDLER; NS_DECL_NON_VIRTUAL_NSISUBSTITUTINGPROTOCOLHANDLER; bool HasSubstitution(const nsACString& aRoot) const { return mSubstitutions.Get(aRoot, nullptr); } - void CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources); + nsresult CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources); protected: virtual ~SubstitutingProtocolHandler() {} void ConstructInternal(); - void SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI); + nsresult SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI); // Override this in the subclass to try additional lookups after checking // mSubstitutions. virtual nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) { *aResult = nullptr; return NS_ERROR_NOT_AVAILABLE; }
--- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp @@ -234,17 +234,20 @@ nsViewSourceChannel::GetURI(nsIURI* *aUR // protect ourselves against broken channel implementations if (!uri) { NS_ERROR("inner channel returned NS_OK and a null URI"); return NS_ERROR_UNEXPECTED; } nsAutoCString spec; - uri->GetSpec(spec); + rv = uri->GetSpec(spec); + if (NS_FAILED(rv)) { + return rv; + } /* XXX Gross hack -- NS_NewURI goes into an infinite loop on non-flat specs. See bug 136980 */ return NS_NewURI(aURI, nsAutoCString(NS_LITERAL_CSTRING("view-source:")+spec), nullptr); } NS_IMETHODIMP nsViewSourceChannel::Open(nsIInputStream **_retval)
--- a/netwerk/test/gtest/TestStandardURL.cpp +++ b/netwerk/test/gtest/TestStandardURL.cpp @@ -47,18 +47,18 @@ TEST(TestStandardURL, Simple) { #define COUNT 10000 MOZ_GTEST_BENCH(TestStandardURL, Perf, [] { nsCOMPtr<nsIURL> url( do_CreateInstance(NS_STANDARDURL_CONTRACTID) ); ASSERT_TRUE(url); nsAutoCString out; for (int i = COUNT; i; --i) { - url->SetSpec(NS_LITERAL_CSTRING("http://example.com")); - url->GetSpec(out); + ASSERT_EQ(url->SetSpec(NS_LITERAL_CSTRING("http://example.com")), NS_OK); + ASSERT_EQ(url->GetSpec(out), NS_OK); url->Resolve(NS_LITERAL_CSTRING("foo.html?q=45"), out); url->SetScheme(NS_LITERAL_CSTRING("foo")); url->GetScheme(out); url->SetHost(NS_LITERAL_CSTRING("www.yahoo.com")); url->GetHost(out); url->SetPath(NS_LITERAL_CSTRING("/some-path/one-the-net/about.html?with-a-query#for-you")); url->GetPath(out); url->SetQuery(NS_LITERAL_CSTRING("a=b&d=c&what-ever-you-want-to-be-called=45"));
--- a/netwerk/test/urltest.cpp +++ b/netwerk/test/urltest.cpp @@ -49,17 +49,22 @@ nsresult writeoutto(const char* i_pURL, nsIURI* url; result = CallCreateInstance(kStdURLCID, &url); if (NS_FAILED(result)) { printf("CreateInstance failed\n"); return NS_ERROR_FAILURE; } pURL = url; - pURL->SetSpec(nsDependentCString(i_pURL)); + result = pURL->SetSpec(nsDependentCString(i_pURL)); + if (NS_FAILED(result)) + { + printf("SetSpec failed\n"); + return NS_ERROR_FAILURE; + } break; } case URL_FACTORY_DEFAULT: { nsCOMPtr<nsIIOService> pService = do_GetService(kIOServiceCID, &result); if (NS_FAILED(result)) { printf("Service failed!\n");