Bug 1323946 - Use MOZ_MUST_USE for netwerk/protocol/res r=valentin

MozReview-Commit-ID: 7tcOml6jKdj

--HG--
extra : rebase_source : 76cae2125b93ad68871408187f04ef02bcc228c6
This commit is contained in:
Wei-Cheng Pan 2016-11-04 18:13:13 +08:00
Родитель 0b4ad7bfb1
Коммит 2351d9ac6c
6 изменённых файлов: 36 добавлений и 26 удалений

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

@ -987,5 +987,10 @@ nsChromeRegistryChrome::ManifestResource(ManifestProcessingContext& cx, int line
return;
}
rph->SetSubstitution(host, resolved);
rv = rph->SetSubstitution(host, resolved);
if (NS_FAILED(rv)) {
LogMessageWithContext(cx.GetManifestURI(), lineno, nsIScriptError::warningFlag,
"Warning: cannot set substitution for '%s'.",
uri);
}
}

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

@ -599,7 +599,10 @@ AnnotateCrashReport(nsIURI* aURI)
annotation.AppendLiteral("(ResolveURI failed)\n");
} else {
nsAutoCString resolvedSpec;
handler->ResolveURI(aURI, resolvedSpec);
nsresult rv = handler->ResolveURI(aURI, resolvedSpec);
if (NS_FAILED(rv)) {
annotation.AppendPrintf("(ResolveURI failed with 0x%08x)\n", rv);
}
annotation.Append(NS_ConvertUTF8toUTF16(resolvedSpec));
annotation.Append('\n');
}

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

@ -28,12 +28,14 @@ public:
protected:
~ExtensionProtocolHandler() {}
bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult) override;
MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult) override;
virtual nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result) override;
virtual MOZ_MUST_USE nsresult SubstituteChannel(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result) override;
};
} // namespace net

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

@ -37,17 +37,17 @@ public:
bool HasSubstitution(const nsACString& aRoot) const { return mSubstitutions.Get(aRoot, nullptr); }
nsresult CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources);
MOZ_MUST_USE nsresult CollectSubstitutions(InfallibleTArray<SubstitutionMapping>& aResources);
protected:
virtual ~SubstitutingProtocolHandler() {}
void ConstructInternal();
nsresult SendSubstitution(const nsACString& aRoot, nsIURI* aBaseURI);
MOZ_MUST_USE 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)
virtual MOZ_MUST_USE nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult)
{
*aResult = nullptr;
return NS_ERROR_NOT_AVAILABLE;
@ -55,17 +55,17 @@ protected:
// Override this in the subclass to check for special case when resolving URIs
// _before_ checking substitutions.
virtual bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult)
virtual MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult)
{
return false;
}
// Override this in the subclass to check for special case when opening
// channels.
virtual nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result)
virtual MOZ_MUST_USE nsresult SubstituteChannel(nsIURI* uri, nsILoadInfo* aLoadInfo, nsIChannel** result)
{
return NS_OK;
}
@ -97,7 +97,7 @@ class SubstitutingURL : public nsStandardURL
public:
SubstitutingURL() : nsStandardURL(true) {}
virtual nsStandardURL* StartClone();
virtual nsresult EnsureFile();
virtual MOZ_MUST_USE nsresult EnsureFile();
NS_IMETHOD GetClassIDNoAlloc(nsCID *aCID);
};

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

@ -21,19 +21,19 @@ interface nsISubstitutingProtocolHandler : nsIProtocolHandler
* A root key should always be lowercase; however, this may not be
* enforced.
*/
void setSubstitution(in ACString root, in nsIURI baseURI);
[must_use] void setSubstitution(in ACString root, in nsIURI baseURI);
/**
* Gets the substitution for the root key.
*
* @throws NS_ERROR_NOT_AVAILABLE if none exists.
*/
nsIURI getSubstitution(in ACString root);
[must_use] nsIURI getSubstitution(in ACString root);
/**
* Returns TRUE if the substitution exists and FALSE otherwise.
*/
boolean hasSubstitution(in ACString root);
[must_use] boolean hasSubstitution(in ACString root);
/**
* Utility function to resolve a substituted URI. A resolved URI is not
@ -42,5 +42,5 @@ interface nsISubstitutingProtocolHandler : nsIProtocolHandler
*
* @throws NS_ERROR_NOT_AVAILABLE if resURI.host() is an unknown root key.
*/
AUTF8String resolveURI(in nsIURI resURI);
[must_use] AUTF8String resolveURI(in nsIURI resURI);
};

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

@ -29,7 +29,7 @@ public:
/* aEnforceFileOrJar = */ false)
{}
nsresult Init();
MOZ_MUST_USE nsresult Init();
NS_IMETHOD SetSubstitution(const nsACString& aRoot, nsIURI* aBaseURI) override;
@ -49,13 +49,13 @@ public:
}
protected:
nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) override;
MOZ_MUST_USE nsresult GetSubstitutionInternal(const nsACString& aRoot, nsIURI** aResult) override;
virtual ~nsResProtocolHandler() {}
bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult) override;
MOZ_MUST_USE bool ResolveSpecialCases(const nsACString& aHost,
const nsACString& aPath,
const nsACString& aPathname,
nsACString& aResult) override;
private:
nsCString mAppURI;