Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r=bkelly,timhuang a=gchang
authorTom Ritter <tom@mozilla.com>
Thu, 11 Jan 2018 14:25:14 -0600
changeset 445673 4c230b89e05e6a4d87d3f26e2ca862dd59e617d0
parent 445672 f99b1d9d900687eeb166ec6ddcb50fd005d85513
child 445674 814254bd1eb76533621eea0700d0182aa3121350
push id1623
push userarchaeopteryx@coole-files.de
push dateMon, 15 Jan 2018 09:33:19 +0000
treeherdermozilla-release@4c230b89e05e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly, timhuang, gchang
bugs1429885
milestone58.0
Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r=bkelly,timhuang a=gchang MozReview-Commit-ID: F96EUfXgK9F
toolkit/components/resistfingerprinting/nsRFPService.cpp
toolkit/components/resistfingerprinting/nsRFPService.h
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -73,16 +73,31 @@ nsRFPService::GetOrCreate()
     ClearOnShutdown(&sRFPService);
     sInitialized = true;
   }
 
   return sRFPService;
 }
 
 /* static */
+bool
+nsRFPService::IsResistFingerprintingEnabled()
+{
+  return sPrivacyResistFingerprinting;
+}
+
+/* static */
+bool
+nsRFPService::IsTimerPrecisionReductionEnabled()
+{
+  return (sPrivacyTimerPrecisionReduction || IsResistFingerprintingEnabled()) &&
+         sResolutionUSec != 0;
+}
+
+/* static */
 double
 nsRFPService::ReduceTimePrecisionAsMSecs(double aTime)
 {
   if (!IsTimerPrecisionReductionEnabled()) {
     return aTime;
   }
   const double resolutionMSec = sResolutionUSec / 1000.0;
   return floor(aTime / resolutionMSec) * resolutionMSec;
--- a/toolkit/components/resistfingerprinting/nsRFPService.h
+++ b/toolkit/components/resistfingerprinting/nsRFPService.h
@@ -24,24 +24,18 @@ namespace mozilla {
 
 class nsRFPService final : public nsIObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
 
   static nsRFPService* GetOrCreate();
-  static bool IsResistFingerprintingEnabled()
-  {
-    return sPrivacyResistFingerprinting;
-  }
-  static bool IsTimerPrecisionReductionEnabled()
-  {
-    return sPrivacyTimerPrecisionReduction || IsResistFingerprintingEnabled();
-  }
+  static bool IsResistFingerprintingEnabled();
+  static bool IsTimerPrecisionReductionEnabled();
 
   // The following Reduce methods can be called off main thread.
   static double ReduceTimePrecisionAsMSecs(double aTime);
   static double ReduceTimePrecisionAsUSecs(double aTime);
   static double ReduceTimePrecisionAsSecs(double aTime);
 
   // This method calculates the video resolution (i.e. height x width) based
   // on the video quality (480p, 720p, etc).