Bug 1176218 - p1. Constify nsContentTypeParser::Get... methods - r=froydnj
GetType() and GetParameter() don't actually modify the nsContentTypeParser
object, so we can make them const.
It makes it possible to pass the parser as a const-ref, which I think makes
sense as getters (even those doing some actual work) are usually const.
MozReview-Commit-ID: 9vmqKbmt8y8
--- a/dom/base/nsContentTypeParser.h
+++ b/dom/base/nsContentTypeParser.h
@@ -11,18 +11,18 @@
class nsIMIMEHeaderParam;
class nsContentTypeParser {
public:
explicit nsContentTypeParser(const nsAString& aString);
~nsContentTypeParser();
- nsresult GetParameter(const char* aParameterName, nsAString& aResult);
- nsresult GetType(nsAString& aResult);
+ nsresult GetParameter(const char* aParameterName, nsAString& aResult) const;
+ nsresult GetType(nsAString& aResult) const;
private:
NS_ConvertUTF16toUTF8 mString;
nsIMIMEHeaderParam* mService;
};
#endif
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -6123,26 +6123,27 @@ nsContentTypeParser::nsContentTypeParser
}
nsContentTypeParser::~nsContentTypeParser()
{
NS_IF_RELEASE(mService);
}
nsresult
-nsContentTypeParser::GetParameter(const char* aParameterName, nsAString& aResult)
+nsContentTypeParser::GetParameter(const char* aParameterName,
+ nsAString& aResult) const
{
NS_ENSURE_TRUE(mService, NS_ERROR_FAILURE);
return mService->GetParameterHTTP(mString, aParameterName,
EmptyCString(), false, nullptr,
aResult);
}
nsresult
-nsContentTypeParser::GetType(nsAString& aResult)
+nsContentTypeParser::GetType(nsAString& aResult) const
{
nsresult rv = GetParameter(nullptr, aResult);
NS_ENSURE_SUCCESS(rv, rv);
nsContentUtils::ASCIIToLower(aResult);
return NS_OK;
}
/* static */