Bug 1037164 - Add an implementation for Preferences::SetFloat. r=bz
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 11 Jul 2014 08:25:12 -0400
changeset 215499 76928ae5c15565e3fdc56030d9f949eb9afeb321
parent 215498 059b364302aff7371bf82aa4f534ad32e6b915e8
child 215500 c109e4bd68acd46d02a33a97f04b2f0ad85dc371
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1037164
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1037164 - Add an implementation for Preferences::SetFloat. r=bz
modules/libpref/public/Preferences.h
modules/libpref/src/Preferences.cpp
--- a/modules/libpref/public/Preferences.h
+++ b/modules/libpref/public/Preferences.h
@@ -196,16 +196,17 @@ public:
    * Sets various type pref values.
    */
   static nsresult SetBool(const char* aPref, bool aValue);
   static nsresult SetInt(const char* aPref, int32_t aValue);
   static nsresult SetUint(const char* aPref, uint32_t aValue)
   {
     return SetInt(aPref, static_cast<int32_t>(aValue));
   }
+  static nsresult SetFloat(const char* aPref, float aValue);
   static nsresult SetCString(const char* aPref, const char* aValue);
   static nsresult SetCString(const char* aPref, const nsACString &aValue);
   static nsresult SetString(const char* aPref, const char16_t* aValue);
   static nsresult SetString(const char* aPref, const nsAString &aValue);
 
   static nsresult SetComplex(const char* aPref, const nsIID &aType,
                              nsISupports* aValue);
 
@@ -344,17 +345,16 @@ public:
   static int32_t GetDefaultType(const char* aPref);
 
   // Used to synchronise preferences between chrome and content processes.
   static void GetPreferences(InfallibleTArray<PrefSetting>* aPrefs);
   static void GetPreference(PrefSetting* aPref);
   static void SetPreference(const PrefSetting& aPref);
 
   static int64_t SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeOf);
-  static nsresult SetFloat(const char* aPref, float aValue);
 
 protected:
   virtual ~Preferences();
 
   nsresult NotifyServiceObservers(const char *aSubject);
   /**
    * Reads the default pref file or, if that failed, try to save a new one.
    *
--- a/modules/libpref/src/Preferences.cpp
+++ b/modules/libpref/src/Preferences.cpp
@@ -1564,16 +1564,23 @@ Preferences::SetInt(const char* aPref, i
 {
   ENSURE_MAIN_PROCESS("Cannot SetInt from content process:", aPref);
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   return PREF_SetIntPref(aPref, aValue, false);
 }
 
 // static
 nsresult
+Preferences::SetFloat(const char* aPref, float aValue)
+{
+  return SetCString(aPref, nsPrintfCString("%f", aValue).get());
+}
+
+// static
+nsresult
 Preferences::SetComplex(const char* aPref, const nsIID &aType,
                         nsISupports* aValue)
 {
   NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
   return sRootBranch->SetComplexValue(aPref, aType, aValue);
 }
 
 // static