Merge mozilla-central and mozilla-inbound

This commit is contained in:
Marco Bonardo 2011-11-07 11:13:04 +01:00
commit 55faf0aa71
3 changed files with 53 additions and 54 deletions

View File

@ -369,7 +369,7 @@ private:
/**
* Init static members. TRUE if it succeeded. Otherwise, FALSE.
*/
static bool InitStaticMembers(bool aForService = false);
static bool InitStaticMembers();
};
} // namespace mozilla

View File

@ -203,29 +203,6 @@ Preferences::GetInstanceForService()
NS_ENSURE_TRUE(!sShutdown, nsnull);
InitStaticMembers(true);
NS_IF_ADDREF(sPreferences);
return sPreferences;
}
// static
bool
Preferences::InitStaticMembers(bool aForService)
{
if (sShutdown || sPreferences) {
return sPreferences != nsnull;
}
// If InitStaticMembers() isn't called for getting nsIPrefService,
// some global components needed by Preferences::Init() may not have been
// initialized yet. Therefore, we must create the singleton instance via
// service manager.
if (!aForService) {
nsCOMPtr<nsIPrefService> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID);
return sPreferences != nsnull;
}
sRootBranch = new nsPrefBranch("", false);
NS_ADDREF(sRootBranch);
sDefaultRootBranch = new nsPrefBranch("", true);
@ -237,7 +214,7 @@ Preferences::InitStaticMembers(bool aForService)
if (NS_FAILED(sPreferences->Init())) {
// The singleton instance will delete sRootBranch and sDefaultRootBranch.
NS_RELEASE(sPreferences);
return false;
return nsnull;
}
gCacheData = new nsTArray<nsAutoPtr<CacheData> >();
@ -245,14 +222,27 @@ Preferences::InitStaticMembers(bool aForService)
gObserverTable = new nsRefPtrHashtable<ValueObserverHashKey, ValueObserver>();
gObserverTable->Init();
return true;
NS_ADDREF(sPreferences);
return sPreferences;
}
// static
bool
Preferences::InitStaticMembers()
{
if (!sShutdown && !sPreferences) {
nsCOMPtr<nsIPrefService> prefService =
do_GetService(NS_PREFSERVICE_CONTRACTID);
}
return sPreferences != nsnull;
}
// static
void
Preferences::Shutdown()
{
if (!sShutdown ) {
if (!sShutdown) {
sShutdown = true; // Don't create the singleton instance after here.
// Don't set NULL to sPreferences here. The instance may be grabbed by
@ -348,7 +338,7 @@ Preferences::Init()
* category which will do the rest.
*/
rv = sRootBranch->GetCharPref("general.config.filename", getter_Copies(lockFileName));
rv = PREF_CopyCharPref("general.config.filename", getter_Copies(lockFileName), false);
if (NS_SUCCEEDED(rv))
NS_CreateServicesFromCategory("pref-config-startup",
static_cast<nsISupports *>(static_cast<void *>(this)),
@ -1129,7 +1119,7 @@ Preferences::GetBool(const char* aPref, bool* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->GetBoolPref(aPref, aResult);
return PREF_GetBoolPref(aPref, aResult, false);
}
// static
@ -1138,7 +1128,7 @@ Preferences::GetInt(const char* aPref, PRInt32* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->GetIntPref(aPref, aResult);
return PREF_GetIntPref(aPref, aResult, false);
}
// static
@ -1146,7 +1136,7 @@ nsAdoptingCString
Preferences::GetCString(const char* aPref)
{
nsAdoptingCString result;
GetCString(aPref, &result);
PREF_CopyCharPref(aPref, getter_Copies(result), false);
return result;
}
@ -1166,7 +1156,7 @@ Preferences::GetCString(const char* aPref, nsACString* aResult)
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsCAutoString result;
nsresult rv = sRootBranch->GetCharPref(aPref, getter_Copies(result));
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
*aResult = result;
}
@ -1180,7 +1170,7 @@ Preferences::GetString(const char* aPref, nsAString* aResult)
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsCAutoString result;
nsresult rv = sRootBranch->GetCharPref(aPref, getter_Copies(result));
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(result, *aResult);
}
@ -1247,47 +1237,54 @@ Preferences::GetComplex(const char* aPref, const nsIID &aType, void** aResult)
nsresult
Preferences::SetCString(const char* aPref, const char* aValue)
{
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->SetCharPref(aPref, aValue);
return PREF_SetCharPref(aPref, aValue, false);
}
// static
nsresult
Preferences::SetCString(const char* aPref, const nsACString &aValue)
{
return SetCString(aPref, PromiseFlatCString(aValue).get());
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCharPref(aPref, PromiseFlatCString(aValue).get(), false);
}
// static
nsresult
Preferences::SetString(const char* aPref, const PRUnichar* aValue)
{
NS_ConvertUTF16toUTF8 utf8(aValue);
return SetCString(aPref, utf8.get());
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
}
// static
nsresult
Preferences::SetString(const char* aPref, const nsAString &aValue)
{
NS_ConvertUTF16toUTF8 utf8(aValue);
return SetCString(aPref, utf8.get());
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return PREF_SetCharPref(aPref, NS_ConvertUTF16toUTF8(aValue).get(), false);
}
// static
nsresult
Preferences::SetBool(const char* aPref, bool aValue)
{
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->SetBoolPref(aPref, aValue);
return PREF_SetBoolPref(aPref, aValue, false);
}
// static
nsresult
Preferences::SetInt(const char* aPref, PRInt32 aValue)
{
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->SetIntPref(aPref, aValue);
return PREF_SetIntPref(aPref, aValue, false);
}
// static
@ -1303,8 +1300,9 @@ Preferences::SetComplex(const char* aPref, const nsIID &aType,
nsresult
Preferences::ClearUser(const char* aPref)
{
NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->ClearUserPref(aPref);
return PREF_ClearUserPref(aPref);
}
// static
@ -1312,12 +1310,7 @@ bool
Preferences::HasUserValue(const char* aPref)
{
NS_ENSURE_TRUE(InitStaticMembers(), false);
bool hasUserValue;
nsresult rv = sRootBranch->PrefHasUserValue(aPref, &hasUserValue);
if (NS_FAILED(rv)) {
return false;
}
return hasUserValue;
return PREF_HasUserPref(aPref);
}
// static
@ -1514,25 +1507,28 @@ Preferences::AddUintVarCache(PRUint32* aCache,
nsresult
Preferences::GetDefaultBool(const char* aPref, bool* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sDefaultRootBranch->GetBoolPref(aPref, aResult);
return PREF_GetBoolPref(aPref, aResult, true);
}
// static
nsresult
Preferences::GetDefaultInt(const char* aPref, PRInt32* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sDefaultRootBranch->GetIntPref(aPref, aResult);
return PREF_GetIntPref(aPref, aResult, true);
}
// static
nsresult
Preferences::GetDefaultCString(const char* aPref, nsACString* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsCAutoString result;
nsresult rv = sDefaultRootBranch->GetCharPref(aPref, getter_Copies(result));
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), true);
if (NS_SUCCEEDED(rv)) {
*aResult = result;
}
@ -1543,9 +1539,10 @@ Preferences::GetDefaultCString(const char* aPref, nsACString* aResult)
nsresult
Preferences::GetDefaultString(const char* aPref, nsAString* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
nsCAutoString result;
nsresult rv = sDefaultRootBranch->GetCharPref(aPref, getter_Copies(result));
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), true);
if (NS_SUCCEEDED(rv)) {
CopyUTF8toUTF16(result, *aResult);
}
@ -1597,7 +1594,7 @@ nsAdoptingCString
Preferences::GetDefaultCString(const char* aPref)
{
nsAdoptingCString result;
GetDefaultCString(aPref, &result);
PREF_CopyCharPref(aPref, getter_Copies(result), true);
return result;
}

View File

@ -318,5 +318,7 @@ GfxInfo::GetFeatureStatusImpl(PRInt32 aFeature,
if (aOS)
*aOS = os;
return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
// XXX disabled for now as this calls GetAdapterVendorID and friends, which currently crash on Android, see bug 700124
// return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
return NS_OK;
}