Backed out changeset 3d0093f961ee (bug 1410794) for Mac plugin crashes and Android test_worker_interfaces.html failures

MozReview-Commit-ID: 20UosHyIr0t
This commit is contained in:
Phil Ringnalda 2017-10-24 22:46:36 -07:00
parent b1ece7d851
commit 93456fb0f4
20 changed files with 169 additions and 131 deletions

View File

@ -109,9 +109,9 @@ AppendDistroSearchDirs(nsIProperties* aDirSvc, nsCOMArray<nsIFile> &array)
localePlugins->AppendNative(NS_LITERAL_CSTRING("locale"));
nsAutoCString defLocale;
nsCString defLocale;
rv = prefs->GetCharPref("distribution.searchplugins.defaultLocale",
defLocale);
getter_Copies(defLocale));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIFile> defLocalePlugins;

View File

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

View File

@ -102,10 +102,10 @@ static PRFuncPtr KLCacheHasValidTicketsPtr;
static nsresult
gssInit()
{
nsAutoCString libPath;
nsCString libPath;
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
if (prefs) {
prefs->GetCharPref(kNegotiateAuthGssLib, libPath);
prefs->GetCharPref(kNegotiateAuthGssLib, getter_Copies(libPath));
prefs->GetBoolPref(kNegotiateAuthNativeImp, &gssNativeImp);
}

View File

@ -458,7 +458,7 @@ nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
{
nsresult rv;
nsAutoCString prefValue;
nsCString prefValue;
/* Getting an email address through set of three preferences:
First getting a default account with
@ -468,12 +468,12 @@ nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
*/
rv = mPrefBranch->GetCharPref("mail.accountmanager.defaultaccount",
prefValue);
getter_Copies(prefValue));
if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty()) {
emailAddr = NS_LITERAL_CSTRING("mail.account.") +
prefValue + NS_LITERAL_CSTRING(".identities");
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
prefValue);
getter_Copies(prefValue));
if (NS_FAILED(rv) || prefValue.IsEmpty())
return PromptForEMailAddress(emailAddr);
int32_t commandIndex = prefValue.FindChar(',');
@ -482,14 +482,15 @@ nsresult nsAutoConfig::getEmailAddr(nsACString & emailAddr)
emailAddr = NS_LITERAL_CSTRING("mail.identity.") +
prefValue + NS_LITERAL_CSTRING(".useremail");
rv = mPrefBranch->GetCharPref(PromiseFlatCString(emailAddr).get(),
prefValue);
getter_Copies(prefValue));
if (NS_FAILED(rv) || prefValue.IsEmpty())
return PromptForEMailAddress(emailAddr);
emailAddr = prefValue;
}
else {
// look for 4.x pref in case we just migrated.
rv = mPrefBranch->GetCharPref("mail.identity.useremail", prefValue);
rv = mPrefBranch->GetCharPref("mail.identity.useremail",
getter_Copies(prefValue));
if (NS_SUCCEEDED(rv) && !prefValue.IsEmpty())
emailAddr = prefValue;
else

View File

@ -115,8 +115,8 @@ NS_IMETHODIMP nsReadConfig::Observe(nsISupports *aSubject, const char *aTopic, c
nsresult nsReadConfig::readConfigFile()
{
nsresult rv = NS_OK;
nsAutoCString lockFileName;
nsAutoCString lockVendor;
nsCString lockFileName;
nsCString lockVendor;
uint32_t fileNameLen = 0;
nsCOMPtr<nsIPrefBranch> defaultPrefBranch;
@ -133,7 +133,7 @@ nsresult nsReadConfig::readConfigFile()
// running mozilla or netscp6)
rv = defaultPrefBranch->GetCharPref("general.config.filename",
lockFileName);
getter_Copies(lockFileName));
MOZ_LOG(MCD, LogLevel::Debug, ("general.config.filename = %s\n", lockFileName.get()));
@ -179,14 +179,16 @@ nsresult nsReadConfig::readConfigFile()
return rv;
}
rv = prefBranch->GetCharPref("general.config.filename", lockFileName);
rv = prefBranch->GetCharPref("general.config.filename",
getter_Copies(lockFileName));
if (NS_FAILED(rv))
// There is NO REASON we should ever get here. This is POST reading
// of the config file.
return NS_ERROR_FAILURE;
rv = prefBranch->GetCharPref("general.config.vendor", lockVendor);
rv = prefBranch->GetCharPref("general.config.vendor",
getter_Copies(lockVendor));
// If vendor is not nullptr, do this check
if (NS_SUCCEEDED(rv)) {
@ -201,8 +203,9 @@ nsresult nsReadConfig::readConfigFile()
}
// get the value of the autoconfig url
nsAutoCString urlName;
rv = prefBranch->GetCharPref("autoadmin.global_config_url", urlName);
nsCString urlName;
rv = prefBranch->GetCharPref("autoadmin.global_config_url",
getter_Copies(urlName));
if (NS_SUCCEEDED(rv) && !urlName.IsEmpty()) {
// Instantiating nsAutoConfig object if the pref is present

View File

@ -314,8 +314,8 @@ mozHunspell::LoadDictionaryList(bool aNotifyChildProcesses)
// check preferences first
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
if (prefs) {
nsAutoCString extDictPath;
rv = prefs->GetCharPref("spellchecker.dictionary_path", extDictPath);
nsCString extDictPath;
rv = prefs->GetCharPref("spellchecker.dictionary_path", getter_Copies(extDictPath));
if (NS_SUCCEEDED(rv)) {
// set the spellchecker.dictionary_path
rv = NS_NewNativeLocalFile(extDictPath, true, getter_AddRefs(dictDir));

View File

@ -457,7 +457,7 @@ NrIceCtx::InitializeGlobals(bool allow_loopback,
&ice_tcp_listen_backlog);
branch->GetCharPref(
"media.peerconnection.ice.force_interface",
force_net_interface);
getter_Copies(force_net_interface));
}
}
@ -633,8 +633,8 @@ NrIceCtx::Initialize(const std::string& ufrag,
}
}
nsAutoCString mapping_type;
nsAutoCString filtering_type;
nsCString mapping_type;
nsCString filtering_type;
bool block_udp = false;
bool block_tcp = false;
@ -648,10 +648,10 @@ NrIceCtx::Initialize(const std::string& ufrag,
if (NS_SUCCEEDED(rv)) {
rv = pref_branch->GetCharPref(
"media.peerconnection.nat_simulator.mapping_type",
mapping_type);
getter_Copies(mapping_type));
rv = pref_branch->GetCharPref(
"media.peerconnection.nat_simulator.filtering_type",
filtering_type);
getter_Copies(filtering_type));
rv = pref_branch->GetBoolPref(
"media.peerconnection.nat_simulator.block_udp",
&block_udp);

View File

@ -485,25 +485,20 @@ StrEscape(const char* aOriginal, nsCString& aResult)
// Each set returns PREF_VALUECHANGED if the user value changed (triggering a
// callback), or PREF_NOERROR if the value was unchanged.
static nsresult
PREF_SetCStringPref(const char* aPrefName,
const nsACString& aValue,
bool aSetDefault)
PREF_SetCharPref(const char* aPrefName, const char* aValue, bool aSetDefault)
{
if (aValue.Length() > MAX_PREF_LENGTH) {
if (strlen(aValue) > MAX_PREF_LENGTH) {
return NS_ERROR_ILLEGAL_VALUE;
}
// It's ok to stash a pointer to the temporary PromiseFlatCString's chars in
// pref because pref_HashPref() duplicates those chars.
PrefValue pref;
const nsCString& flat = PromiseFlatCString(aValue);
pref.mStringVal = const_cast<char*>(flat.get());
pref.mStringVal = const_cast<char*>(aValue);
return pref_HashPref(
aPrefName, pref, PrefType::String, aSetDefault ? kPrefSetDefault : 0);
}
// Like PREF_SetCStringPref(), but for integers.
// Like PREF_SetCharPref(), but for integers.
static nsresult
PREF_SetIntPref(const char* aPrefName, int32_t aValue, bool aSetDefault)
{
@ -514,7 +509,7 @@ PREF_SetIntPref(const char* aPrefName, int32_t aValue, bool aSetDefault)
aPrefName, pref, PrefType::Int, aSetDefault ? kPrefSetDefault : 0);
}
// Like PREF_SetCStringPref(), but for booleans.
// Like PREF_SetCharPref(), but for booleans.
static nsresult
PREF_SetBoolPref(const char* aPrefName, bool aValue, bool aSetDefault)
{
@ -540,7 +535,8 @@ SetPrefValue(const char* aPrefName,
switch (aValue.type()) {
case dom::PrefValue::TnsCString:
return PREF_SetCStringPref(aPrefName, aValue.get_nsCString(), setDefault);
return PREF_SetCharPref(
aPrefName, aValue.get_nsCString().get(), setDefault);
case dom::PrefValue::Tint32_t:
return PREF_SetIntPref(aPrefName, aValue.get_int32_t(), setDefault);
@ -722,10 +718,9 @@ PREF_HasUserPref(const char* aPrefName)
return pref && pref->mPrefFlags.HasUserValue();
}
// This function allocates memory and the caller is responsible for freeing it.
static nsresult
PREF_GetCStringPref(const char* aPrefName,
nsACString& aValueOut,
bool aGetDefault)
PREF_CopyCharPref(const char* aPrefName, char** aValueOut, bool aGetDefault)
{
if (!gHashTable) {
return NS_ERROR_NOT_INITIALIZED;
@ -744,7 +739,7 @@ PREF_GetCStringPref(const char* aPrefName,
}
if (stringVal) {
aValueOut = stringVal;
*aValueOut = moz_xstrdup(stringVal);
rv = NS_OK;
}
}
@ -2238,13 +2233,14 @@ protected:
nsAString& aReturn);
// As SetCharPref, but without any check on the length of |aValue|.
nsresult SetCharPrefInternal(const char* aPrefName, const nsACString& aValue);
nsresult SetCharPrefInternal(const char* aPrefName, const char* aValue);
// Reject strings that are more than 1Mb, warn if strings are more than 16kb.
nsresult CheckSanityOfStringLength(const char* aPrefName,
const nsAString& aValue);
nsresult CheckSanityOfStringLength(const char* aPrefName,
const nsACString& aValue);
nsresult CheckSanityOfStringLength(const char* aPrefName, const char* aValue);
nsresult CheckSanityOfStringLength(const char* aPrefName,
const uint32_t aLength);
@ -2337,9 +2333,11 @@ NS_INTERFACE_MAP_BEGIN(nsPrefBranch)
NS_INTERFACE_MAP_END
NS_IMETHODIMP
nsPrefBranch::GetRoot(nsACString& aRoot)
nsPrefBranch::GetRoot(char** aRoot)
{
aRoot = mPrefRoot;
NS_ENSURE_ARG_POINTER(aRoot);
*aRoot = ToNewCString(mPrefRoot);
return NS_OK;
}
@ -2425,7 +2423,7 @@ nsPrefBranch::GetFloatPref(const char* aPrefName, float* aRetVal)
NS_ENSURE_ARG(aPrefName);
nsAutoCString stringVal;
nsresult rv = GetCharPref(aPrefName, stringVal);
nsresult rv = GetCharPref(aPrefName, getter_Copies(stringVal));
if (NS_SUCCEEDED(rv)) {
*aRetVal = stringVal.ToFloat(&rv);
}
@ -2435,14 +2433,15 @@ nsPrefBranch::GetFloatPref(const char* aPrefName, float* aRetVal)
NS_IMETHODIMP
nsPrefBranch::GetCharPrefWithDefault(const char* aPrefName,
const nsACString& aDefaultValue,
const char* aDefaultValue,
uint8_t aArgc,
nsACString& aRetVal)
char** aRetVal)
{
nsresult rv = GetCharPref(aPrefName, aRetVal);
if (NS_FAILED(rv) && aArgc == 1) {
aRetVal = aDefaultValue;
NS_ENSURE_ARG(aDefaultValue);
*aRetVal = moz_xstrdup(aDefaultValue);
return NS_OK;
}
@ -2450,15 +2449,15 @@ nsPrefBranch::GetCharPrefWithDefault(const char* aPrefName,
}
NS_IMETHODIMP
nsPrefBranch::GetCharPref(const char* aPrefName, nsACString& aRetVal)
nsPrefBranch::GetCharPref(const char* aPrefName, char** aRetVal)
{
NS_ENSURE_ARG(aPrefName);
const PrefName& pref = GetPrefName(aPrefName);
return PREF_GetCStringPref(pref.get(), aRetVal, mIsDefault);
return PREF_CopyCharPref(pref.get(), aRetVal, mIsDefault);
}
NS_IMETHODIMP
nsPrefBranch::SetCharPref(const char* aPrefName, const nsACString& aValue)
nsPrefBranch::SetCharPref(const char* aPrefName, const char* aValue)
{
nsresult rv = CheckSanityOfStringLength(aPrefName, aValue);
if (NS_FAILED(rv)) {
@ -2468,14 +2467,15 @@ nsPrefBranch::SetCharPref(const char* aPrefName, const nsACString& aValue)
}
nsresult
nsPrefBranch::SetCharPrefInternal(const char* aPrefName,
const nsACString& aValue)
nsPrefBranch::SetCharPrefInternal(const char* aPrefName, const char* aValue)
{
ENSURE_MAIN_PROCESS("SetCharPref", aPrefName);
NS_ENSURE_ARG(aPrefName);
NS_ENSURE_ARG(aValue);
const PrefName& pref = GetPrefName(aPrefName);
return PREF_SetCStringPref(pref.get(), aValue, mIsDefault);
return PREF_SetCharPref(pref.get(), aValue, mIsDefault);
}
NS_IMETHODIMP
@ -2485,7 +2485,7 @@ nsPrefBranch::GetStringPref(const char* aPrefName,
nsACString& aRetVal)
{
nsCString utf8String;
nsresult rv = GetCharPref(aPrefName, utf8String);
nsresult rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
aRetVal = utf8String;
return rv;
@ -2507,7 +2507,7 @@ nsPrefBranch::SetStringPref(const char* aPrefName, const nsACString& aValue)
return rv;
}
return SetCharPrefInternal(aPrefName, aValue);
return SetCharPrefInternal(aPrefName, PromiseFlatCString(aValue).get());
}
NS_IMETHODIMP
@ -2551,7 +2551,7 @@ nsPrefBranch::GetComplexValue(const char* aPrefName,
NS_ENSURE_ARG(aPrefName);
nsresult rv;
nsAutoCString utf8String;
nsCString utf8String;
// we have to do this one first because it's different than all the rest
if (aType.Equals(NS_GET_IID(nsIPrefLocalizedString))) {
@ -2582,7 +2582,7 @@ nsPrefBranch::GetComplexValue(const char* aPrefName,
theString->SetData(utf16String);
}
} else {
rv = GetCharPref(aPrefName, utf8String);
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_SUCCEEDED(rv)) {
theString->SetData(NS_ConvertUTF8toUTF16(utf8String));
}
@ -2596,7 +2596,7 @@ nsPrefBranch::GetComplexValue(const char* aPrefName,
}
// if we can't get the pref, there's no point in being here
rv = GetCharPref(aPrefName, utf8String);
rv = GetCharPref(aPrefName, getter_Copies(utf8String));
if (NS_FAILED(rv)) {
return rv;
}
@ -2706,6 +2706,16 @@ nsPrefBranch::GetComplexValue(const char* aPrefName,
return NS_NOINTERFACE;
}
nsresult
nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName,
const char* aValue)
{
if (!aValue) {
return NS_OK;
}
return CheckSanityOfStringLength(aPrefName, strlen(aValue));
}
nsresult
nsPrefBranch::CheckSanityOfStringLength(const char* aPrefName,
const nsAString& aValue)
@ -2786,7 +2796,7 @@ nsPrefBranch::SetComplexValue(const char* aPrefName,
nsAutoCString descriptorString;
rv = file->GetPersistentDescriptor(descriptorString);
if (NS_SUCCEEDED(rv)) {
rv = SetCharPrefInternal(aPrefName, descriptorString);
rv = SetCharPrefInternal(aPrefName, descriptorString.get());
}
return rv;
}
@ -2830,7 +2840,7 @@ nsPrefBranch::SetComplexValue(const char* aPrefName,
descriptorString.Append(relativeToKey);
descriptorString.Append(']');
descriptorString.Append(relDescriptor);
return SetCharPrefInternal(aPrefName, descriptorString);
return SetCharPrefInternal(aPrefName, descriptorString.get());
}
if (aType.Equals(NS_GET_IID(nsISupportsString)) ||
@ -2847,7 +2857,8 @@ nsPrefBranch::SetComplexValue(const char* aPrefName,
if (NS_FAILED(rv)) {
return rv;
}
rv = SetCharPrefInternal(aPrefName, NS_ConvertUTF16toUTF8(wideString));
rv = SetCharPrefInternal(aPrefName,
NS_ConvertUTF16toUTF8(wideString).get());
}
}
return rv;
@ -3138,8 +3149,9 @@ nsPrefBranch::GetDefaultFromPropertiesFile(const char* aPrefName,
{
// The default value contains a URL to a .properties file.
nsAutoCString propertyFileURL;
nsresult rv = PREF_GetCStringPref(aPrefName, propertyFileURL, true);
nsCString propertyFileURL;
nsresult rv =
PREF_CopyCharPref(aPrefName, getter_Copies(propertyFileURL), true);
if (NS_FAILED(rv)) {
return rv;
}
@ -3966,7 +3978,7 @@ Preferences::Init()
return Ok();
}
nsAutoCString 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
@ -3974,8 +3986,8 @@ Preferences::Init()
// all-ns.js (netscape 6), and if it exists we startup the pref config
// category which will do the rest.
nsresult rv =
PREF_GetCStringPref("general.config.filename", lockFileName, false);
nsresult rv = PREF_CopyCharPref(
"general.config.filename", getter_Copies(lockFileName), false);
if (NS_SUCCEEDED(rv)) {
NS_CreateServicesFromCategory(
"pref-config-startup",
@ -4902,7 +4914,7 @@ Preferences::GetFloat(const char* aPref, float* aResult)
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsAutoCString result;
nsresult rv = PREF_GetCStringPref(aPref, result, false);
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
*aResult = result.ToFloat(&rv);
}
@ -4913,7 +4925,12 @@ Preferences::GetFloat(const char* aPref, float* aResult)
Preferences::GetCString(const char* aPref, nsACString& aResult)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_GetCStringPref(aPref, aResult, false);
char* result;
nsresult rv = PREF_CopyCharPref(aPref, &result, false);
if (NS_SUCCEEDED(rv)) {
aResult.Adopt(result);
}
return rv;
}
/* static */ nsresult
@ -4921,7 +4938,7 @@ Preferences::GetString(const char* aPref, nsAString& aResult)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsAutoCString result;
nsresult rv = PREF_GetCStringPref(aPref, result, false);
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(result, aResult);
}
@ -4965,7 +4982,7 @@ Preferences::SetCString(const char* aPref, const char* aValue)
{
ENSURE_MAIN_PROCESS_WITH_WARNING("SetCString", aPref);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCStringPref(aPref, nsDependentCString(aValue), false);
return PREF_SetCharPref(aPref, aValue, false);
}
/* static */ nsresult
@ -4973,7 +4990,7 @@ Preferences::SetCString(const char* aPref, const nsACString& aValue)
{
ENSURE_MAIN_PROCESS_WITH_WARNING("SetCString", aPref);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCStringPref(aPref, aValue, false);
return PREF_SetCharPref(aPref, PromiseFlatCString(aValue).get(), false);
}
/* static */ nsresult
@ -4981,7 +4998,7 @@ Preferences::SetString(const char* aPref, const char16ptr_t aValue)
{
ENSURE_MAIN_PROCESS_WITH_WARNING("SetString", aPref);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCStringPref(aPref, NS_ConvertUTF16toUTF8(aValue), false);
return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
}
/* static */ nsresult
@ -4989,7 +5006,7 @@ Preferences::SetString(const char* aPref, const nsAString& aValue)
{
ENSURE_MAIN_PROCESS_WITH_WARNING("SetString", aPref);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCStringPref(aPref, NS_ConvertUTF16toUTF8(aValue), false);
return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
}
/* static */ nsresult
@ -5388,7 +5405,12 @@ Preferences::GetDefaultInt(const char* aPref, int32_t* aResult)
Preferences::GetDefaultCString(const char* aPref, nsACString& aResult)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_GetCStringPref(aPref, aResult, true);
char* result;
nsresult rv = PREF_CopyCharPref(aPref, &result, true);
if (NS_SUCCEEDED(rv)) {
aResult.Adopt(result);
}
return rv;
}
/* static */ nsresult
@ -5396,7 +5418,7 @@ Preferences::GetDefaultString(const char* aPref, nsAString& aResult)
{
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsAutoCString result;
nsresult rv = PREF_GetCStringPref(aPref, result, true);
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), true);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(result, aResult);
}

View File

@ -41,7 +41,7 @@ interface nsIPrefBranch : nsISupports
* Called to get the root on which this branch is based, such as
* "browser.startup."
*/
readonly attribute ACString root;
readonly attribute string root;
/**
* Called to determine the type of a specific preference.
@ -104,15 +104,14 @@ interface nsIPrefBranch : nsISupports
* @param aPrefName The string preference to retrieve.
* @param aDefaultValue The string to return if the preference is not set.
*
* @return ACString The value of the requested string preference.
* @return string The value of the requested string preference.
*
* @see setCharPref
*/
[optional_argc,binaryname(GetCharPrefWithDefault)]
ACString getCharPref(in string aPrefName,
[optional] in ACString aDefaultValue);
string getCharPref(in string aPrefName, [optional] in string aDefaultValue);
[noscript,binaryname(GetCharPref)]
ACString getCharPrefXPCOM(in string aPrefName);
string getCharPrefXPCOM(in string aPrefName);
/**
* Called to set the state of an individual ascii string preference.
@ -125,7 +124,7 @@ interface nsIPrefBranch : nsISupports
*
* @see getCharPref
*/
void setCharPref(in string aPrefName, in ACString aValue);
void setCharPref(in string aPrefName, in string aValue);
/**
* Called to get the state of an individual unicode string preference.
@ -133,7 +132,7 @@ interface nsIPrefBranch : nsISupports
* @param aPrefName The string preference to retrieve.
* @param aDefaultValue The string to return if the preference is not set.
*
* @return ACString The value of the requested string preference.
* @return string The value of the requested string preference.
*
* @see setStringPref
*/

View File

@ -1364,10 +1364,10 @@ nsIOService::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
void
nsIOService::ParsePortList(nsIPrefBranch *prefBranch, const char *pref, bool remove)
{
nsAutoCString portList;
nsCString portList;
// Get a pref string and chop it up into a list of ports.
prefBranch->GetCharPref(pref, portList);
prefBranch->GetCharPref(pref, getter_Copies(portList));
if (!portList.IsVoid()) {
nsTArray<nsCString> portListArray;
ParseString(portList, ',', portListArray);

View File

@ -427,8 +427,8 @@ proxy_GetStringPref(nsIPrefBranch *aPrefBranch,
const char *aPref,
nsCString &aResult)
{
nsAutoCString temp;
nsresult rv = aPrefBranch->GetCharPref(aPref, temp);
nsCString temp;
nsresult rv = aPrefBranch->GetCharPref(aPref, getter_Copies(temp));
if (NS_FAILED(rv))
aResult.Truncate();
else {
@ -560,8 +560,9 @@ nsProtocolProxyService::ReloadNetworkPAC()
}
if (type == PROXYCONFIG_PAC) {
nsAutoCString pacSpec;
prefs->GetCharPref(PROXY_PREF("autoconfig_url"), pacSpec);
nsCString pacSpec;
prefs->GetCharPref(PROXY_PREF("autoconfig_url"),
getter_Copies(pacSpec));
if (!pacSpec.IsEmpty()) {
nsCOMPtr<nsIURI> pacURI;
rv = NS_NewURI(getter_AddRefs(pacURI), pacSpec);
@ -691,7 +692,7 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
{
nsresult rv = NS_OK;
bool reloadPAC = false;
nsAutoCString tempString;
nsCString tempString;
if (!pref || !strcmp(pref, PROXY_PREF("type"))) {
int32_t type = -1;
@ -775,7 +776,8 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
mFailedProxyTimeout);
if (!pref || !strcmp(pref, PROXY_PREF("no_proxies_on"))) {
rv = prefBranch->GetCharPref(PROXY_PREF("no_proxies_on"), tempString);
rv = prefBranch->GetCharPref(PROXY_PREF("no_proxies_on"),
getter_Copies(tempString));
if (NS_SUCCEEDED(rv))
LoadHostFilters(tempString);
}
@ -796,7 +798,8 @@ nsProtocolProxyService::PrefsChanged(nsIPrefBranch *prefBranch,
if (reloadPAC) {
tempString.Truncate();
if (mProxyConfig == PROXYCONFIG_PAC) {
prefBranch->GetCharPref(PROXY_PREF("autoconfig_url"), tempString);
prefBranch->GetCharPref(PROXY_PREF("autoconfig_url"),
getter_Copies(tempString));
if (mPACMan && !mPACMan->IsPACURI(tempString)) {
LOG(("PAC Thread URI Changed - Reset Pac Thread"));
ResetPACThread();
@ -1243,9 +1246,9 @@ nsProtocolProxyService::ReloadPAC()
if (NS_FAILED(rv))
return NS_OK;
nsAutoCString pacSpec;
nsCString pacSpec;
if (type == PROXYCONFIG_PAC)
prefs->GetCharPref(PROXY_PREF("autoconfig_url"), pacSpec);
prefs->GetCharPref(PROXY_PREF("autoconfig_url"), getter_Copies(pacSpec));
else if (type == PROXYCONFIG_WPAD)
pacSpec.AssignLiteral(WPAD_URL);
else if (type == PROXYCONFIG_SYSTEM) {

View File

@ -547,9 +547,9 @@ nsDNSService::Init()
int proxyType = nsIProtocolProxyService::PROXYCONFIG_DIRECT;
bool notifyResolution = false;
nsAutoCString ipv4OnlyDomains;
nsAutoCString localDomains;
nsAutoCString forceResolve;
nsCString ipv4OnlyDomains;
nsCString localDomains;
nsCString forceResolve;
// read prefs
nsCOMPtr<nsIPrefBranch> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
@ -564,9 +564,9 @@ nsDNSService::Init()
// ASSUMPTION: pref branch does not modify out params on failure
prefs->GetBoolPref(kPrefDisableIPv6, &disableIPv6);
prefs->GetCharPref(kPrefIPv4OnlyDomains, ipv4OnlyDomains);
prefs->GetCharPref(kPrefDnsLocalDomains, localDomains);
prefs->GetCharPref(kPrefDnsForceResolve, forceResolve);
prefs->GetCharPref(kPrefIPv4OnlyDomains, getter_Copies(ipv4OnlyDomains));
prefs->GetCharPref(kPrefDnsLocalDomains, getter_Copies(localDomains));
prefs->GetCharPref(kPrefDnsForceResolve, getter_Copies(forceResolve));
prefs->GetBoolPref(kPrefDnsOfflineLocalhost, &offlineLocalhost);
prefs->GetBoolPref(kPrefDisablePrefetch, &disablePrefetch);
prefs->GetBoolPref(kPrefBlockDotOnion, &blockDotOnion);

View File

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

View File

@ -785,7 +785,7 @@ nsFtpState::S_pass() {
// XXX Is UTF-8 the best choice?
AppendUTF16toUTF8(mPassword, passwordStr);
} else {
nsAutoCString anonPassword;
nsCString anonPassword;
bool useRealEmail = false;
nsCOMPtr<nsIPrefBranch> prefs =
do_GetService(NS_PREFSERVICE_CONTRACTID);
@ -793,7 +793,7 @@ nsFtpState::S_pass() {
rv = prefs->GetBoolPref("advanced.mailftp", &useRealEmail);
if (NS_SUCCEEDED(rv) && useRealEmail) {
prefs->GetCharPref("network.ftp.anonymous_password",
anonPassword);
getter_Copies(anonPassword));
}
}
if (!anonPassword.IsEmpty()) {

View File

@ -924,7 +924,7 @@ nsGIOProtocolHandler::InitSupportedProtocolsPref(nsIPrefBranch *prefs)
// irrelevant to process by browser. By default accept only smb and sftp
// protocols so far.
nsresult rv = prefs->GetCharPref(MOZ_GIO_SUPPORTED_PROTOCOLS,
mSupportedProtocols);
getter_Copies(mSupportedProtocols));
if (NS_SUCCEEDED(rv)) {
mSupportedProtocols.StripWhitespace();
ToLowerCase(mSupportedProtocols);

View File

@ -137,11 +137,15 @@ URIMatchesPrefPattern(nsIURI *uri, const char *pref)
return false;
}
nsAutoCString hostList;
if (NS_FAILED(prefs->GetCharPref(pref, hostList)) || hostList.IsEmpty()) {
char *hostList;
if (NS_FAILED(prefs->GetCharPref(pref, &hostList)) || !hostList) {
return false;
}
struct FreePolicy { void operator()(void* p) { free(p); } };
mozilla::UniquePtr<char[], FreePolicy> hostListScope;
hostListScope.reset(hostList);
// pseudo-BNF
// ----------
//

View File

@ -1165,7 +1165,8 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
// general.useragent.override
if (PREF_CHANGED(UA_PREF("override"))) {
prefs->GetCharPref(UA_PREF("override"), mUserAgentOverride);
prefs->GetCharPref(UA_PREF("override"),
getter_Copies(mUserAgentOverride));
mUserAgentIsDirty = true;
}
@ -1342,8 +1343,8 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("version"))) {
nsAutoCString httpVersion;
prefs->GetCharPref(HTTP_PREF("version"), httpVersion);
nsCString httpVersion;
prefs->GetCharPref(HTTP_PREF("version"), getter_Copies(httpVersion));
if (!httpVersion.IsVoid()) {
if (httpVersion.EqualsLiteral("1.1"))
mHttpVersion = NS_HTTP_VERSION_1_1;
@ -1355,8 +1356,8 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("proxy.version"))) {
nsAutoCString httpVersion;
prefs->GetCharPref(HTTP_PREF("proxy.version"), httpVersion);
nsCString httpVersion;
prefs->GetCharPref(HTTP_PREF("proxy.version"), getter_Copies(httpVersion));
if (!httpVersion.IsVoid()) {
if (httpVersion.EqualsLiteral("1.1"))
mProxyHttpVersion = NS_HTTP_VERSION_1_1;
@ -1373,8 +1374,9 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("accept.default"))) {
nsAutoCString accept;
rv = prefs->GetCharPref(HTTP_PREF("accept.default"), accept);
nsCString accept;
rv = prefs->GetCharPref(HTTP_PREF("accept.default"),
getter_Copies(accept));
if (NS_SUCCEEDED(rv)) {
rv = SetAccept(accept.get());
MOZ_ASSERT(NS_SUCCEEDED(rv));
@ -1382,8 +1384,9 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("accept-encoding"))) {
nsAutoCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"), acceptEncodings);
nsCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding"),
getter_Copies(acceptEncodings));
if (NS_SUCCEEDED(rv)) {
rv = SetAcceptEncodings(acceptEncodings.get(), false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
@ -1391,9 +1394,9 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("accept-encoding.secure"))) {
nsAutoCString acceptEncodings;
nsCString acceptEncodings;
rv = prefs->GetCharPref(HTTP_PREF("accept-encoding.secure"),
acceptEncodings);
getter_Copies(acceptEncodings));
if (NS_SUCCEEDED(rv)) {
rv = SetAcceptEncodings(acceptEncodings.get(), true);
MOZ_ASSERT(NS_SUCCEEDED(rv));
@ -1401,8 +1404,9 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
}
if (PREF_CHANGED(HTTP_PREF("default-socket-type"))) {
nsAutoCString sval;
rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"), sval);
nsCString sval;
rv = prefs->GetCharPref(HTTP_PREF("default-socket-type"),
getter_Copies(sval));
if (NS_SUCCEEDED(rv)) {
if (sval.IsEmpty())
mDefaultSocketType.SetIsVoid(true);

View File

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

View File

@ -136,8 +136,9 @@ CreateClientInfo()
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID);
nsAutoCString clientId;
nsresult rv = prefBranch->GetCharPref("browser.safebrowsing.id", clientId);
nsCString clientId;
nsresult rv = prefBranch->GetCharPref("browser.safebrowsing.id",
getter_Copies(clientId));
if (NS_FAILED(rv)) {
clientId = "Firefox"; // Use "Firefox" as fallback.
@ -343,8 +344,8 @@ nsUrlClassifierUtils::GetProtocolVersion(const nsACString& aProvider,
if (prefBranch) {
nsPrintfCString prefName("browser.safebrowsing.provider.%s.pver",
nsCString(aProvider).get());
nsAutoCString version;
nsresult rv = prefBranch->GetCharPref(prefName.get(), version);
nsCString version;
nsresult rv = prefBranch->GetCharPref(prefName.get(), getter_Copies(version));
aVersion = NS_SUCCEEDED(rv) ? version.get() : DEFAULT_PROTOCOL_VERSION;
} else {
@ -835,8 +836,9 @@ nsUrlClassifierUtils::ReadProvidersFromPrefs(ProviderDictType& aDict)
nsCString provider(entry->GetKey());
nsPrintfCString owninListsPref("%s.lists", provider.get());
nsAutoCString owningLists;
nsresult rv = prefBranch->GetCharPref(owninListsPref.get(), owningLists);
nsCString owningLists;
nsresult rv = prefBranch->GetCharPref(owninListsPref.get(),
getter_Copies(owningLists));
if (NS_FAILED(rv)) {
continue;
}

View File

@ -4359,8 +4359,8 @@ XREMain::XRE_mainRun()
rv = prefs->GetDefaultBranch(nullptr, getter_AddRefs(defaultPrefBranch));
if (NS_SUCCEEDED(rv)) {
nsAutoCString sval;
rv = defaultPrefBranch->GetCharPref("app.update.channel", sval);
nsCString sval;
rv = defaultPrefBranch->GetCharPref("app.update.channel", getter_Copies(sval));
if (NS_SUCCEEDED(rv)) {
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("ReleaseChannel"),
sval);