Bug 1596064 - Remove any access on the database when pref is off. r=jya
authorAlex Chronopoulos <achronop@gmail.com>
Fri, 15 Nov 2019 10:59:50 +0000
changeset 502151 f8d156649aaaa1882bfd57b3c2dd4d2dd6ac9494
parent 502150 530bb2d5095a391392439b7972b6bd02f62640d5
child 502152 2f87baa2ba544e90dacc26eb46afd5b636806b26
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1596064
milestone72.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 1596064 - Remove any access on the database when pref is off. r=jya 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()) {