Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r?timhuang draft
authorTom Ritter <tom@mozilla.com>
Thu, 11 Jan 2018 14:25:14 -0600
changeset 719702 78472335f3331824c9395e44dbce3c4575837490
parent 719593 d2edd256c3aadb1cea48da0c8f62f725bd53cb76
child 719723 b7668e07d4d8b2be67eedaaca225750429916c67
child 719908 13a41c958bab914718ee3daad43ed0b6cd6f41b7
child 720170 1817e2115368d8c3b8689c649915b549606b38bc
child 720747 a2d2dacb2c306ceb4481830ae2e9f2ee50ed1d7c
push id95349
push userbmo:tom@mozilla.com
push dateFri, 12 Jan 2018 17:17:44 +0000
reviewerstimhuang
bugs1429885
milestone59.0a1
Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r?timhuang 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
@@ -48,24 +48,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).