Bug 568271 - e10s: remote nsIPrefBranch::GetComplexValue(). Part 2: assert on pref set. r=jdm
authorDan Witte <dwitte@mozilla.com>
Wed, 26 May 2010 12:29:29 -0700
changeset 46883 0227403e8a15ddd9967d3dbf902e3f4ced86599c
parent 46882 ee0c3deb3ac47fcc3c10bbecbc1130253b4cbc66
child 46884 dc9cc3820b0223e3120eb8563554bf301a63727c
push idunknown
push userunknown
push dateunknown
reviewersjdm
bugs568271
milestone1.9.3a5pre
Bug 568271 - e10s: remote nsIPrefBranch::GetComplexValue(). Part 2: assert on pref set. r=jdm
modules/libpref/src/nsPrefBranch.cpp
--- a/modules/libpref/src/nsPrefBranch.cpp
+++ b/modules/libpref/src/nsPrefBranch.cpp
@@ -193,16 +193,23 @@ NS_IMETHODIMP nsPrefBranch::GetBoolPref(
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_GetBoolPref(pref, _retval, mIsDefault);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsPrefBranch::SetBoolPref(const char *aPrefName, PRInt32 aValue)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_SetBoolPref(pref, aValue, mIsDefault);
   }
   return rv;
@@ -233,16 +240,23 @@ NS_IMETHODIMP nsPrefBranch::GetCharPref(
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_CopyCharPref(pref, _retval, mIsDefault);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsPrefBranch::SetCharPref(const char *aPrefName, const char *aValue)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   NS_ENSURE_ARG_POINTER(aValue);
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_SetCharPref(pref, aValue, mIsDefault);
   }
@@ -272,16 +286,23 @@ NS_IMETHODIMP nsPrefBranch::GetIntPref(c
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_GetIntPref(pref, _retval, mIsDefault);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsPrefBranch::SetIntPref(const char *aPrefName, PRInt32 aValue)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_SetIntPref(pref, aValue, mIsDefault);
   }
   return rv;
@@ -433,16 +454,23 @@ NS_IMETHODIMP nsPrefBranch::GetComplexVa
   }
 
   NS_WARNING("nsPrefBranch::GetComplexValue - Unsupported interface type");
   return NS_NOINTERFACE;
 }
 
 NS_IMETHODIMP nsPrefBranch::SetComplexValue(const char *aPrefName, const nsIID & aType, nsISupports *aValue)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   nsresult   rv = NS_NOINTERFACE;
 
   if (aType.Equals(NS_GET_IID(nsILocalFile))) {
     nsCOMPtr<nsILocalFile> file = do_QueryInterface(aValue);
     if (!file)
       return NS_NOINTERFACE;
     nsCAutoString descriptorString;
 
@@ -515,16 +543,23 @@ NS_IMETHODIMP nsPrefBranch::SetComplexVa
   }
 
   NS_WARNING("nsPrefBranch::SetComplexValue - Unsupported interface type");
   return NS_NOINTERFACE;
 }
 
 NS_IMETHODIMP nsPrefBranch::ClearUserPref(const char *aPrefName)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_ClearUserPref(pref);
   }
   return rv;
@@ -555,16 +590,23 @@ NS_IMETHODIMP nsPrefBranch::PrefHasUserV
   if (NS_SUCCEEDED(rv)) {
     *_retval = PREF_HasUserPref(pref);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsPrefBranch::LockPref(const char *aPrefName)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot lock pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_LockPref(pref, PR_TRUE);
   }
   return rv;
@@ -595,16 +637,23 @@ NS_IMETHODIMP nsPrefBranch::PrefIsLocked
   if (NS_SUCCEEDED(rv)) {
     *_retval = PREF_PrefIsLocked(pref);
   }
   return rv;
 }
 
 NS_IMETHODIMP nsPrefBranch::UnlockPref(const char *aPrefName)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot unlock pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aPrefName, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_LockPref(pref, PR_FALSE);
   }
   return rv;
@@ -613,16 +662,23 @@ NS_IMETHODIMP nsPrefBranch::UnlockPref(c
 /* void resetBranch (in string startingAt); */
 NS_IMETHODIMP nsPrefBranch::ResetBranch(const char *aStartingAt)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP nsPrefBranch::DeleteBranch(const char *aStartingAt)
 {
+#ifdef MOZ_IPC
+    if (XRE_GetProcessType() == GeckoProcessType_Content) {
+      NS_ERROR("cannot set pref from content process");
+      return NS_ERROR_NOT_AVAILABLE;
+    }
+#endif
+
   const char *pref;
   nsresult   rv;
 
   rv = getValidatedPrefName(aStartingAt, &pref);
   if (NS_SUCCEEDED(rv)) {
     rv = PREF_DeleteBranch(pref);
   }
   return rv;