Bug 1429885 Support a rounding value of 0 for reduceTimerPrecision r=bkelly,timhuang
authorTom Ritter <tom@mozilla.com>
Thu, 11 Jan 2018 14:25:14 -0600
changeset 453498 cbb0db087e5e5960ee25391873cde70998efbf88
parent 453497 860a997f95c9f7961efd94b48ffb6500afb3b1a9
child 453499 0a4e3d4de37415d0fec3f5bfb644ffa3da7eb659
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbkelly, timhuang
bugs1429885
milestone59.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 1429885 Support a rounding value of 0 for reduceTimerPrecision r=bkelly,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).