Bug 1596064 - Remove any access on the database when pref is off. r=jya a=pascalc
authorAlex Chronopoulos <achronop@gmail.com>
Fri, 15 Nov 2019 10:59:50 +0000
changeset 560058 437e904693bcffba0a72c5a7191f1e7ba9490be4
parent 560057 b1c5eb22db7f6649faf938768d956f3d2cda5d54
child 560059 b92fd849eadcf579743bb5b2c4502bc2e4dd8f0f
push id12318
push usercbrindusan@mozilla.com
push dateMon, 18 Nov 2019 11:23:34 +0000
treeherdermozilla-beta@01c5734e16ab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya, pascalc
bugs1596064
milestone71.0
Bug 1596064 - Remove any access on the database when pref is off. r=jya a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D52984
dom/media/MediaFormatReader.cpp
dom/media/mediacapabilities/DecoderBenchmark.cpp
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -901,16 +901,19 @@ void MediaFormatReader::ShutdownDecoder(
   decoder.Flush();
 
   // Shut down the decoder if any.
   decoder.ShutdownDecoder();
 }
 
 void MediaFormatReader::NotifyDecoderBenchmarkStore() {
   MOZ_ASSERT(OnTaskQueue());
+  if (!StaticPrefs::media_mediacapabilities_from_database()) {
+    return;
+  }
   auto& decoder = GetDecoderData(TrackInfo::kVideoTrack);
   if (decoder.GetCurrentInfo() && decoder.GetCurrentInfo()->GetAsVideoInfo()) {
     VideoInfo info = *(decoder.GetCurrentInfo()->GetAsVideoInfo());
     info.SetFrameRate(static_cast<int32_t>(ceil(decoder.mMeanRate.Mean())));
     mOnStoreDecoderBenchmark.Notify(std::move(info));
   }
 }
 
--- a/dom/media/mediacapabilities/DecoderBenchmark.cpp
+++ b/dom/media/mediacapabilities/DecoderBenchmark.cpp
@@ -2,16 +2,17 @@
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DecoderBenchmark.h"
 #include "mozilla/BenchmarkStorageChild.h"
 #include "mozilla/media/MediaUtils.h"
+#include "mozilla/StaticPrefs_media.h"
 
 namespace mozilla {
 
 void DecoderBenchmark::StoreScore(const nsACString& aDecoderName,
                                   const nsACString& aKey,
                                   RefPtr<FrameStatistics> aStats) {
   uint64_t totalFrames = aStats->GetTotalFrames();
   uint64_t droppedFrames = aStats->GetDroppedFrames();
@@ -209,16 +210,20 @@ static nsDataHashtable<nsCStringHashKey,
 /* static */
 void DecoderBenchmark::CheckVersion(const nsACString& aDecoderName) {
   if (!XRE_IsContentProcess()) {
     NS_WARNING(
         "Checking version is only allowed only from the content process.");
     return;
   }
 
+  if (!StaticPrefs::media_mediacapabilities_from_database()) {
+    return;
+  }
+
   nsCString name(aDecoderName);
   int32_t version;
   if (!DecoderVersionTable().Get(name, &version)) {
     // A version is not set for that decoder ignore.
     return;
   }
 
   if (NS_IsMainThread()) {