Bug 1165796 - Part 1: Make PrefEnabledRunnable usable for other preference names. r=baku
authorHiroyuki Ikezoe <hiikezoe@mozilla-japan.org>
Mon, 17 Aug 2015 15:13:13 -0700
changeset 290706 d6f22fa46223a470094e8fa9aa9eb951904bd97b
parent 290705 dd56d26a2ec98bdede7f31cf13cbf6145b2efa35
child 290707 12cb9596968948300f2f024ce7efb89b4326d395
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1165796
milestone43.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 1165796 - Part 1: Make PrefEnabledRunnable usable for other preference names. r=baku
dom/base/nsPerformance.cpp
--- a/dom/base/nsPerformance.cpp
+++ b/dom/base/nsPerformance.cpp
@@ -687,52 +687,56 @@ public:
                "Trying to compare null performance entries");
     return aElem1->StartTime() < aElem2->StartTime();
   }
 };
 
 class PrefEnabledRunnable final : public WorkerMainThreadRunnable
 {
 public:
-  explicit PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate)
+  PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate,
+                      const nsCString& aPrefName)
     : WorkerMainThreadRunnable(aWorkerPrivate)
     , mEnabled(false)
+    , mPrefName(aPrefName)
   { }
 
   bool MainThreadRun() override
   {
     MOZ_ASSERT(NS_IsMainThread());
-    mEnabled = Preferences::GetBool("dom.enable_user_timing", false);
+    mEnabled = Preferences::GetBool(mPrefName.get(), false);
     return true;
   }
 
   bool IsEnabled() const
   {
     return mEnabled;
   }
 
 private:
   bool mEnabled;
+  nsCString mPrefName;
 };
 
 } // namespace
 
 /* static */ bool
 nsPerformance::IsEnabled(JSContext* aCx, JSObject* aGlobal)
 {
   if (NS_IsMainThread()) {
     return Preferences::GetBool("dom.enable_user_timing", false);
   }
 
   WorkerPrivate* workerPrivate = GetCurrentThreadWorkerPrivate();
   MOZ_ASSERT(workerPrivate);
   workerPrivate->AssertIsOnWorkerThread();
 
   nsRefPtr<PrefEnabledRunnable> runnable =
-    new PrefEnabledRunnable(workerPrivate);
+    new PrefEnabledRunnable(workerPrivate,
+                            NS_LITERAL_CSTRING("dom.enable_user_timing"));
   runnable->Dispatch(workerPrivate->GetJSContext());
 
   return runnable->IsEnabled();
 }
 
 void
 nsPerformance::InsertUserEntry(PerformanceEntry* aEntry)
 {