Bug 1570212 - Convert media.video_stats.enabled to a static pref. r=jya
authorNicholas Nethercote <nnethercote@mozilla.com>
Fri, 02 Aug 2019 12:35:01 +0000
changeset 486140 bb17231625801d44a0df8cee99e8f2376a27f4a7
parent 486139 8e72c66c307675d621018cb7638f4c0292a9ab9f
child 486141 6b2199650f33a32b6710a1ea22b8510b452c24d7
push id36390
push usercbrindusan@mozilla.com
push dateMon, 05 Aug 2019 09:54:13 +0000
treeherdermozilla-central@d681969e4480 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1570212
milestone70.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 1570212 - Convert media.video_stats.enabled to a static pref. r=jya Also remove HTMLVideoElement::InitStatics(), which is no longer needed. Differential Revision: https://phabricator.services.mozilla.com/D40340
dom/html/HTMLVideoElement.cpp
dom/html/HTMLVideoElement.h
layout/build/nsLayoutStatics.cpp
modules/libpref/init/StaticPrefList.yaml
modules/libpref/init/all.js
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -46,18 +46,16 @@ nsGenericHTMLElement* NS_NewHTMLVideoEle
       new mozilla::dom::HTMLVideoElement(std::move(aNodeInfo));
   element->Init();
   return element;
 }
 
 namespace mozilla {
 namespace dom {
 
-static bool sVideoStatsEnabled;
-
 nsresult HTMLVideoElement::Clone(mozilla::dom::NodeInfo* aNodeInfo,
                                  nsINode** aResult) const {
   *aResult = nullptr;
   RefPtr<mozilla::dom::NodeInfo> ni(aNodeInfo);
   HTMLVideoElement* it = new HTMLVideoElement(ni.forget());
   it->Init();
   nsCOMPtr<nsINode> kungFuDeathGrip = it;
   nsresult rv = const_cast<HTMLVideoElement*>(this)->CopyInnerTo(it);
@@ -412,24 +410,20 @@ bool HTMLVideoElement::SetVisualCloneSou
       (aVisualCloneSource->IsInComposedDoc() && !mVisualCloneTarget)) {
     mVisualCloneSource = aVisualCloneSource;
     return true;
   }
   return false;
 }
 
 /* static */
-void HTMLVideoElement::InitStatics() {
-  Preferences::AddBoolVarCache(&sVideoStatsEnabled,
-                               "media.video_stats.enabled");
+bool HTMLVideoElement::IsVideoStatsEnabled() {
+  return StaticPrefs::media_video_stats_enabled();
 }
 
-/* static */
-bool HTMLVideoElement::IsVideoStatsEnabled() { return sVideoStatsEnabled; }
-
 double HTMLVideoElement::TotalPlayTime() const {
   double total = 0.0;
 
   if (mPlayed) {
     uint32_t timeRangeCount = mPlayed->Length();
 
     for (uint32_t i = 0; i < timeRangeCount; i++) {
       double begin = mPlayed->Start(i);
--- a/dom/html/HTMLVideoElement.h
+++ b/dom/html/HTMLVideoElement.h
@@ -39,18 +39,16 @@ class HTMLVideoElement final : public HT
   virtual bool IsVideo() const override { return true; }
 
   virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
                               nsAttrValue& aResult) override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
-  static void InitStatics();
-
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
       const override;
 
   virtual nsresult Clone(NodeInfo*, nsINode** aResult) const override;
 
   virtual void UnbindFromTree(bool aNullParent = true) override;
 
   // Set size with the current video frame's height and width.
--- a/layout/build/nsLayoutStatics.cpp
+++ b/layout/build/nsLayoutStatics.cpp
@@ -260,18 +260,16 @@ nsresult nsLayoutStatics::Initialize() {
 
   ProcessPriorityManager::Init();
 
   nsPermissionManager::Startup();
 
   nsCookieService::AppClearDataObserverInit();
   nsApplicationCacheService::AppClearDataObserverInit();
 
-  HTMLVideoElement::InitStatics();
-
 #ifdef MOZ_XUL
   nsMenuBarListener::InitializeStatics();
 #endif
 
   UIDirectionManager::Initialize();
 
   CacheObserver::Init();
 
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -5053,16 +5053,22 @@
 #if defined(RELEASE_OR_BETA)
   value: 2
 #else
 # Zero tolerance in pre-release builds to detect any decoder regression.
   value: 0
 #endif
   mirror: always
 
+# Are video stats enabled? (Disabling can help prevent fingerprinting.)
+- name: media.video_stats.enabled
+  type: bool
+  value: true
+  mirror: always
+
 # Opus
 - name: media.opus.enabled
   type: RelaxedAtomicBool
   value: true
   mirror: always
 
 # Wave
 - name: media.wave.enabled
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -451,19 +451,16 @@ pref("media.autoplay.enabled.user-gestur
 // The default number of decoded video frames that are enqueued in
 // MediaDecoderReader's mVideoQueue.
 pref("media.video-queue.default-size", 10);
 
 // The maximum number of queued frames to send to the compositor.
 // By default, send all of them.
 pref("media.video-queue.send-to-compositor-size", 9999);
 
-// Whether to disable the video stats to prevent fingerprinting
-pref("media.video_stats.enabled", true);
-
 // Log level for cubeb, the audio input/output system. Valid values are
 // "verbose", "normal" and "" (log disabled).
 pref("media.cubeb.logging_level", "");
 
 // Cubeb sandbox (remoting) control
 #if defined(XP_LINUX) && !defined(MOZ_WIDGET_ANDROID)
 pref("media.cubeb.sandbox", true);
 pref("media.audioipc.pool_size", 1);