Bug 1390428 (part 1) - Remove many nsXPIDLCString local variables. r=erahm.

These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is only used in ways that nsCStrings can also be used
(i.e. no null checks or implicit conversions to |char*|).

In every case the patch trivially replaces the nsXPIDLCString with an
nsCString. (Also, there are a couple of unused nsXPIDLCString variables that
the patch simply removes.)
This commit is contained in:
Nicholas Nethercote 2017-08-16 13:58:35 +10:00
Родитель 81d6ed725c
Коммит 025461bde7
39 изменённых файлов: 59 добавлений и 64 удалений

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

@ -656,7 +656,7 @@ nsChromeRegistry::GetDirectionForLocale(const nsACString& aLocale)
return false;
}
nsXPIDLCString dir;
nsCString dir;
prefBranch->GetCharPref(prefString.get(), getter_Copies(dir));
if (dir.IsEmpty()) {
int32_t hyphen = prefString.FindChar('-');

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

@ -128,7 +128,7 @@ nsChromeRegistryChrome::Init()
if (!prefs) {
NS_WARNING("Could not get pref service!");
} else {
nsXPIDLCString provider;
nsCString provider;
rv = prefs->GetCharPref(SELECTED_SKIN_PREF, getter_Copies(provider));
if (NS_SUCCEEDED(rv))
mSelectedSkin = provider;
@ -275,7 +275,7 @@ nsChromeRegistryChrome::Observe(nsISupports *aSubject, const char *aTopic,
NS_ConvertUTF16toUTF8 pref(someData);
if (pref.EqualsLiteral(SELECTED_SKIN_PREF)) {
nsXPIDLCString provider;
nsCString provider;
rv = prefs->GetCharPref(pref.get(), getter_Copies(provider));
if (NS_FAILED(rv)) {
NS_ERROR("Couldn't get new skin pref!");

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

@ -580,7 +580,7 @@ DragDataProducer::Produce(DataTransfer* aDataTransfer,
nsAutoCString extension;
imgUrl->GetFileExtension(extension);
nsXPIDLCString mimeType;
nsCString mimeType;
imgRequest->GetMimeType(getter_Copies(mimeType));
nsCOMPtr<nsIMIMEInfo> mimeInfo;

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

@ -628,7 +628,7 @@ static nsresult AppendImagePromise(nsITransferable* aTransferable,
rv = imgUrl->GetFileExtension(extension);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString mimeType;
nsCString mimeType;
rv = aImgRequest->GetMimeType(getter_Copies(mimeType));
NS_ENSURE_SUCCESS(rv, rv);

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

@ -783,7 +783,7 @@ nsClipboardGetContentsCommand::DoClipboardCommand(const char *aCommandName, nsIC
nsAutoCString mimeType("text/plain");
nsXPIDLCString format; // nsICommandParams needs to use nsACString
nsCString format; // nsICommandParams needs to use nsACString
if (NS_SUCCEEDED(aParams->GetCStringValue("format", getter_Copies(format))))
mimeType.Assign(format);

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

@ -777,13 +777,13 @@ ImageDocument::UpdateTitleAndCharset()
}
if (imageRequest) {
nsXPIDLCString mimeType;
nsCString mimeType;
imageRequest->GetMimeType(getter_Copies(mimeType));
ToUpperCase(mimeType);
nsXPIDLCString::const_iterator start, end;
nsCString::const_iterator start, end;
mimeType.BeginReading(start);
mimeType.EndReading(end);
nsXPIDLCString::const_iterator iter = end;
nsCString::const_iterator iter = end;
if (FindInReadable(NS_LITERAL_CSTRING("IMAGE/"), start, iter) &&
iter != end) {
// strip out "X-" if any

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

@ -1371,7 +1371,7 @@ nsHTMLDocument::GetCookie(nsAString& aCookie, ErrorResult& rv)
}
}
nsXPIDLCString cookie;
nsCString cookie;
service->GetCookieString(codebaseURI, channel, getter_Copies(cookie));
// CopyUTF8toUTF16 doesn't handle error
// because it assumes that the input is valid.
@ -3668,7 +3668,7 @@ nsHTMLDocument::QueryCommandValue(const nsAString& commandID,
// aValue will wind up being the empty string. This is fine -- we want to
// return "" in that case anyway (bug 738385), so we just return NS_OK
// regardless.
nsXPIDLCString cStringResult;
nsCString cStringResult;
cmdParams->GetCStringValue("state_attribute",
getter_Copies(cStringResult));
CopyUTF8toUTF16(cStringResult, aValue);

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

@ -432,7 +432,7 @@ ConsoleListener::Observe(nsIConsoleMessage* aMessage)
nsCOMPtr<nsIScriptError> scriptError = do_QueryInterface(aMessage);
if (scriptError) {
nsAutoString msg, sourceName, sourceLine;
nsXPIDLCString category;
nsCString category;
uint32_t lineNum, colNum, flags;
nsresult rv = scriptError->GetErrorMessage(msg);

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

@ -115,7 +115,7 @@ SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded()
nsAutoCString name;
icStr->GetData(name);
nsXPIDLCString spec;
nsCString spec;
catMan->GetCategoryEntry("agent-style-sheets", name.get(),
getter_Copies(spec));

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

@ -1042,7 +1042,7 @@ findFunction(nsIAtom* aName, int32_t aNamespaceID,
rv = txNamespaceManager::getNamespaceURI(aNamespaceID, namespaceURI);
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString contractID;
nsCString contractID;
rv = catman->GetCategoryEntry("XSLT-extension-functions",
NS_ConvertUTF16toUTF8(namespaceURI).get(),
getter_Copies(contractID));

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

@ -627,7 +627,7 @@ nsMultiStateCommand::DoCommandParams(const char *aCommandName,
nsAutoString tString;
if (aParams) {
nsXPIDLCString s;
nsCString s;
nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
if (NS_SUCCEEDED(rv))
CopyASCIItoUTF16(s, tString);
@ -1508,7 +1508,7 @@ nsInsertTagCommand::DoCommandParams(const char *aCommandName,
}
// do we have an href to use for creating link?
nsXPIDLCString s;
nsCString s;
nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE, getter_Copies(s));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoString attrib;

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

@ -275,7 +275,7 @@ nsSetDocumentStateCommand::DoCommandParams(const char *aCommandName,
return NS_ERROR_INVALID_ARG;
}
nsXPIDLCString newValue;
nsCString newValue;
nsresult rv = aParams->GetCStringValue(STATE_ATTRIBUTE,
getter_Copies(newValue));
if (NS_WARN_IF(NS_FAILED(rv))) {

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

@ -102,7 +102,7 @@ static PRFuncPtr KLCacheHasValidTicketsPtr;
static nsresult
gssInit()
{
nsXPIDLCString libPath;
nsCString libPath;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
prefs->GetCharPref(kNegotiateAuthGssLib, getter_Copies(libPath));

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

@ -208,7 +208,6 @@ nsresult nsAutoConfig::downloadAutoConfig()
{
nsresult rv;
nsAutoCString emailAddr;
nsXPIDLCString urlName;
static bool firstTime = true;
if (mConfigURL.IsEmpty()) {
@ -463,7 +462,7 @@ nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
{
nsresult rv;
nsXPIDLCString prefValue;
nsCString prefValue;
/* Getting an email address through set of three preferences:
First getting a default account with

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

@ -643,7 +643,6 @@ nsStringBundleService::FormatWithBundle(nsIStringBundle* bundle, nsresult aStatu
nsAString& result)
{
nsresult rv;
nsXPIDLCString key;
// try looking up the error message with the int key:
uint16_t code = NS_ERROR_GET_CODE(aStatus);

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

@ -56,7 +56,7 @@ XPCNativeMember::Resolve(XPCCallContext& ccx, XPCNativeInterface* iface,
MOZ_ASSERT(iface == GetInterface());
if (IsConstant()) {
RootedValue resultVal(ccx);
nsXPIDLCString name;
nsCString name;
if (NS_FAILED(iface->GetInterfaceInfo()->GetConstant(mIndex, &resultVal,
getter_Copies(name))))
return false;

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

@ -73,7 +73,7 @@ nsStyleSheetService::RegisterFromEnumerator(nsICategoryManager *aManager,
nsAutoCString name;
icStr->GetData(name);
nsXPIDLCString spec;
nsCString spec;
aManager->GetCategoryEntry(aCategory, name.get(), getter_Copies(spec));
nsCOMPtr<nsIURI> uri;

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

@ -754,7 +754,7 @@ Preferences::Init()
return NS_OK;
}
nsXPIDLCString lockFileName;
nsCString lockFileName;
/*
* The following is a small hack which will allow us to only load the library
* which supports the netscape.cfg file if the preference is defined. We

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

@ -242,7 +242,7 @@ NS_IMETHODIMP nsPrefBranch::GetStringPref(const char *aPrefName,
uint8_t _argc,
nsACString& _retval)
{
nsXPIDLCString utf8String;
nsCString utf8String;
nsresult rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
_retval = utf8String;
@ -300,8 +300,8 @@ NS_IMETHODIMP nsPrefBranch::GetComplexValue(const char *aPrefName, const nsIID &
{
NS_ENSURE_ARG(aPrefName);
nsresult rv;
nsXPIDLCString utf8String;
nsresult rv;
nsCString utf8String;
// we have to do this one first because it's different than all the rest
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {

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

@ -744,7 +744,7 @@ nsChannelClassifier::HasBeenClassified(nsIChannel *aChannel)
return false;
}
nsXPIDLCString tag;
nsCString tag;
cacheEntry->GetMetaDataElement("necko:classified", getter_Copies(tag));
return tag.EqualsLiteral("1");
}

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

@ -428,7 +428,7 @@ proxy_GetStringPref(nsIPrefBranch *aPrefBranch,
const char *aPref,
nsCString &aResult)
{
nsXPIDLCString temp;
nsCString temp;
nsresult rv = aPrefBranch->GetCharPref(aPref, getter_Copies(temp));
if (NS_FAILED(rv))
aResult.Truncate();
@ -561,7 +561,7 @@ nsProtocolProxyService::ReloadNetworkPAC()
}
if (type == PROXYCONFIG_PAC) {
nsXPIDLCString pacSpec;
nsCString pacSpec;
prefs->GetCharPref(PROXY_PREF("autoconfig_url"),
getter_Copies(pacSpec));
if (!pacSpec.IsEmpty()) {
@ -693,7 +693,7 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
{
nsresult rv = NS_OK;
bool reloadPAC = false;
nsXPIDLCString tempString;
nsCString tempString;
if (!pref || !strcmp(pref, PROXY_PREF("type"))) {
int32_t type = -1;
@ -1247,7 +1247,7 @@ nsProtocolProxyService::ReloadPAC()
if (NS_FAILED(rv))
return NS_OK;
nsXPIDLCString pacSpec;
nsCString pacSpec;
if (type == PROXYCONFIG_PAC)
prefs->GetCharPref(PROXY_PREF("autoconfig_url"), getter_Copies(pacSpec));
else if (type == PROXYCONFIG_WPAD)

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

@ -207,7 +207,7 @@ NS_IMETHODIMP _OldVisitCallbackWrapper::VisitEntry(const char * deviceID,
*_retval = true;
// Read all informative properties from the entry.
nsXPIDLCString clientId;
nsCString clientId;
rv = entryInfo->GetClientID(getter_Copies(clientId));
if (NS_FAILED(rv))
return NS_OK;

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

@ -124,7 +124,7 @@ void nsIDNService::prefsChanged(nsIPrefBranch *prefBranch, const char16_t *pref)
mIDNUseWhitelist = val;
}
if (!pref || NS_LITERAL_STRING(NS_NET_PREF_IDNRESTRICTION).Equals(pref)) {
nsXPIDLCString profile;
nsCString profile;
if (NS_FAILED(prefBranch->GetCharPref(NS_NET_PREF_IDNRESTRICTION,
getter_Copies(profile)))) {
profile.Truncate();

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

@ -78,8 +78,8 @@ nsMIMEHeaderParamImpl::DoGetParameter(const nsACString& aHeaderVal,
// get parameter (decode RFC 2231/5987 when applicable, as specified by
// aDecoding (5987 being a subset of 2231) and return charset.)
nsXPIDLCString med;
nsXPIDLCString charset;
nsCString med;
nsCString charset;
rv = DoParameterInternal(PromiseFlatCString(aHeaderVal).get(), aParamName,
aDecoding, getter_Copies(charset), aLang,
getter_Copies(med));

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

@ -1924,7 +1924,7 @@ Http2Session::CachePushCheckCallback::OnCacheEntryCheck(nsICacheEntry *entry, ns
}
// Get the method that was used to generate the cached response
nsXPIDLCString buf;
nsCString buf;
rv = entry->GetMetaDataElement("request-method", getter_Copies(buf));
if (NS_FAILED(rv)) {
// Can't check request method, accept the push
@ -1986,7 +1986,7 @@ Http2Session::CachePushCheckCallback::OnCacheEntryCheck(nsICacheEntry *entry, ns
return NS_OK;
}
nsXPIDLCString cachedAuth;
nsCString cachedAuth;
rv = entry->GetMetaDataElement("auth", getter_Copies(cachedAuth));
if (NS_SUCCEEDED(rv)) {
uint32_t lastModifiedTime;

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

@ -3201,7 +3201,7 @@ HttpBaseChannel::AddCookiesToRequest()
bool useCookieService =
(XRE_IsParentProcess());
nsXPIDLCString cookie;
nsCString cookie;
if (useCookieService) {
nsICookieService *cs = gHttpHandler->GetCookieService();
if (cs) {

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

@ -473,7 +473,7 @@ ValidationRequired(bool isForcedValid, nsHttpResponseHead *cachedResponseHead,
nsresult
GetHttpResponseHeadFromCacheEntry(nsICacheEntry *entry, nsHttpResponseHead *cachedResponseHead)
{
nsXPIDLCString buf;
nsCString buf;
// A "original-response-headers" metadata element holds network original headers,
// i.e. the headers in the form as they arrieved from the network.
// We need to get the network original headers first, because we need to keep them
@ -532,7 +532,7 @@ DetermineFramingAndImmutability(nsICacheEntry *entry,
nsHttpResponseHead *responseHead, bool isHttps,
bool *weaklyFramed, bool *isImmutable)
{
nsXPIDLCString framedBuf;
nsCString framedBuf;
nsresult rv = entry->GetMetaDataElement("strongly-framed", getter_Copies(framedBuf));
// describe this in terms of explicitly weakly framed so as to be backwards
// compatible with old cache contents which dont have strongly-framed makers

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

@ -3166,7 +3166,7 @@ nsHttpChannel::ResponseWouldVary(nsICacheEntry* entry)
// check the last value of the given request header to see if it has
// since changed. if so, then indeed the cached response is invalid.
nsXPIDLCString lastVal;
nsCString lastVal;
entry->GetMetaDataElement(metaKey.get(), getter_Copies(lastVal));
LOG(("nsHttpChannel::ResponseWouldVary [channel=%p] "
"stored value = \"%s\"\n",
@ -4044,7 +4044,7 @@ nsHttpChannel::OnCacheEntryCheck(nsICacheEntry* entry, nsIApplicationCache* appC
*aResult = ENTRY_WANTED;
mCachedContentIsValid = false;
nsXPIDLCString buf;
nsCString buf;
// Get the method that was used to generate the cached response
rv = entry->GetMetaDataElement("request-method", getter_Copies(buf));
@ -7859,7 +7859,7 @@ nsHttpChannel::GetCacheTokenCachedCharset(nsACString &_retval)
if (!mCacheEntry)
return NS_ERROR_NOT_AVAILABLE;
nsXPIDLCString cachedCharset;
nsCString cachedCharset;
rv = mCacheEntry->GetMetaDataElement("charset",
getter_Copies(cachedCharset));
if (NS_SUCCEEDED(rv))

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

@ -952,7 +952,7 @@ nsHttpChannelAuthProvider::GetCredentialsForChallenge(const char *challenge,
// that we don't transparently authenticate as someone they're not
// expecting to authenticate as.
//
nsXPIDLCString result;
nsCString result;
rv = GenCredsAndSetEntry(auth, proxyAuth, scheme.get(), host, port,
path.get(), realm.get(), challenge, *ident,
sessionStateGrip, getter_Copies(result));
@ -1353,7 +1353,7 @@ NS_IMETHODIMP nsHttpChannelAuthProvider::OnAuthAvailable(nsISupports *aContext,
return NS_OK;
}
nsXPIDLCString creds;
nsCString creds;
rv = GenCredsAndSetEntry(auth, mProxyAuth,
scheme.get(), host, port, path.get(),
realm.get(), mCurrentChallenge.get(), *ident,
@ -1693,7 +1693,7 @@ nsHttpChannelAuthProvider::SetAuthorizationHeader(nsHttpAuthCache *authCache,
else
identFromURI = true;
nsXPIDLCString temp;
nsCString temp; // this must have the same lifetime as creds
const char *creds = entry->Creds();
const char *challenge = entry->Challenge();
// we can only send a preemptive Authorization header if we have either

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

@ -533,14 +533,14 @@ nsWyciwygChannel::GetCharsetAndSource(int32_t* aSource, nsACString& aCharset)
return NS_ERROR_NOT_AVAILABLE;
}
nsXPIDLCString data;
nsCString data;
mCacheEntry->GetMetaDataElement("charset", getter_Copies(data));
if (data.IsEmpty()) {
return NS_ERROR_NOT_AVAILABLE;
}
nsXPIDLCString sourceStr;
nsCString sourceStr;
mCacheEntry->GetMetaDataElement("charset-source", getter_Copies(sourceStr));
int32_t source;

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

@ -1512,7 +1512,7 @@ nsNSSCertificate::Read(nsIObjectInputStream* aStream)
return rv;
}
nsXPIDLCString str;
nsCString str;
rv = aStream->ReadBytes(len, getter_Copies(str));
if (NS_FAILED(rv)) {
return rv;

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

@ -149,7 +149,7 @@ nsTypeAheadFind::PrefsReset()
bool isSoundEnabled = true;
prefBranch->GetBoolPref("accessibility.typeaheadfind.enablesound",
&isSoundEnabled);
nsXPIDLCString soundStr;
nsCString soundStr;
if (isSoundEnabled)
prefBranch->GetCharPref("accessibility.typeaheadfind.soundURL", getter_Copies(soundStr));

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

@ -131,7 +131,7 @@ CreateClientInfo()
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID);
nsXPIDLCString clientId;
nsCString clientId;
nsresult rv = prefBranch->GetCharPref("browser.safebrowsing.id",
getter_Copies(clientId));
@ -552,7 +552,7 @@ nsUrlClassifierUtils::ReadProvidersFromPrefs(ProviderDictType& aDict)
nsCString provider(entry->GetKey());
nsPrintfCString owninListsPref("%s.lists", provider.get());
nsXPIDLCString owningLists;
nsCString owningLists;
nsresult rv = prefBranch->GetCharPref(owninListsPref.get(),
getter_Copies(owningLists));
if (NS_FAILED(rv)) {

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

@ -1797,7 +1797,7 @@ StartRemoteClient(const char* aDesktopStartupID,
if (NS_FAILED(rv))
return REMOTE_NOT_FOUND;
nsXPIDLCString response;
nsCString response;
bool success = false;
rv = client.SendCommandLine(program.get(), username, profile,
gArgc, gArgv, aDesktopStartupID,
@ -4324,7 +4324,7 @@ XREMain::XRE_mainRun()
rv = prefs->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch));
if (NS_SUCCEEDED(rv)) {
nsXPIDLCString sval;
nsCString sval;
rv = defaultPrefBranch->GetCharPref("app.update.channel", getter_Copies(sval));
if (NS_SUCCEEDED(rv)) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ReleaseChannel"),

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

@ -412,9 +412,6 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
LOG((" forceExternalHandling: %s", forceExternalHandling ? "yes" : "no"));
// The type or data the contentListener wants.
nsXPIDLCString desiredContentType;
if (!forceExternalHandling)
{
//
@ -690,7 +687,7 @@ nsDocumentOpenInfo::TryContentListener(nsIURIContentListener* aListener,
NS_PRECONDITION(aChannel, "Must have a channel");
bool listenerWantsContent = false;
nsXPIDLCString typeToUse;
nsCString typeToUse;
if (mFlags & nsIURILoader::IS_CONTENT_PREFERRED) {
aListener->IsPreferred(mContentType.get(),

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

@ -2737,7 +2737,7 @@ nsExternalHelperAppService::GetTypeFromExtension(const nsACString& aFileExt,
nsAutoCString lowercaseFileExt(aFileExt);
ToLowerCase(lowercaseFileExt);
// Read the MIME type from the category entry, if available
nsXPIDLCString type;
nsCString type;
nsresult rv = catMan->GetCategoryEntry("ext-to-type-mapping",
lowercaseFileExt.get(),
getter_Copies(type));

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

@ -444,7 +444,7 @@ nsClipboard::HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
do_QueryElementAt(transferableFlavorList, j);
if (!currentTransferableFlavor)
continue;
nsXPIDLCString transferableFlavorStr;
nsCString transferableFlavorStr;
currentTransferableFlavor->ToString(getter_Copies(transferableFlavorStr));
for (uint32_t k = 0; k < aLength; k++) {

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

@ -599,7 +599,7 @@ nsDragService::IsDataFlavorSupported(const char *aDataFlavor, bool *_retval)
nsCOMPtr<nsISupportsCString> currentFlavor = do_QueryElementAt(flavorList, j);
if (!currentFlavor)
continue;
nsXPIDLCString flavorStr;
nsCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
if (dataFlavor.Equals(flavorStr)) {
*_retval = true;

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

@ -325,7 +325,7 @@ nsHTTPIndex::OnStopRequest(nsIRequest *request,
nsresult rv;
nsXPIDLCString commentStr;
nsCString commentStr;
mParser->GetComment(getter_Copies(commentStr));
nsCOMPtr<nsIRDFLiteral> comment;
@ -379,7 +379,7 @@ nsHTTPIndex::OnIndexAvailable(nsIRequest* aRequest, nsISupports *aContext,
// we found the filename; construct a resource for its entry
nsAutoCString entryuriC(baseStr);
nsXPIDLCString filename;
nsCString filename;
nsresult rv = aIndex->GetLocation(getter_Copies(filename));
if (NS_FAILED(rv)) return rv;
entryuriC.Append(filename);