Bug 1419771 - Introduce DOMPreferences, a thread-safe access to preferences for DOM - part 5 - Performance logging enabled, r=asuth

This commit is contained in:
Andrea Marchesini
2017-11-30 18:16:44 +01:00
parent b107b07f59
commit e0c43ef19a
7 changed files with 9 additions and 17 deletions

View File

@@ -38,6 +38,7 @@ DOMPreferences::DumpEnabled()
PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
PREF(DOMCachesEnabled, "dom.caches.enabled")
PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
#undef PREF

View File

@@ -26,6 +26,9 @@ public:
// Returns true if the dom.caches.testing.enabled pref is set.
static bool DOMCachesTestingEnabled();
// Returns true if the dom.performance.enable_user_timing_logging pref is set.
static bool PerformanceLoggingEnabled();
};
} // dom namespace

View File

@@ -294,7 +294,6 @@ bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
bool nsContentUtils::sIsPerformanceTimingEnabled = false;
bool nsContentUtils::sIsResourceTimingEnabled = false;
bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
bool nsContentUtils::sIsWebComponentsEnabled = false;
bool nsContentUtils::sIsCustomElementsEnabled = false;
@@ -653,9 +652,6 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sIsPerformanceNavigationTimingEnabled,
"dom.enable_performance_navigation_timing", true);
Preferences::AddBoolVarCache(&sIsUserTimingLoggingEnabled,
"dom.performance.enable_user_timing_logging", false);
Preferences::AddBoolVarCache(&sIsFrameTimingPrefEnabled,
"dom.enable_frame_timing", false);

View File

@@ -2276,14 +2276,6 @@ public:
return sIsPerformanceTimingEnabled;
}
/*
* Returns true if user timing API should print to console.
*/
static bool IsUserTimingLoggingEnabled()
{
return sIsUserTimingLoggingEnabled;
}
/*
* Returns true if the performance timing APIs are enabled.
*/
@@ -3413,7 +3405,6 @@ private:
static bool sIsPerformanceTimingEnabled;
static bool sIsResourceTimingEnabled;
static bool sIsPerformanceNavigationTimingEnabled;
static bool sIsUserTimingLoggingEnabled;
static bool sIsFrameTimingPrefEnabled;
static bool sIsFormAutofillAutocompleteEnabled;
static bool sIsWebComponentsEnabled;

View File

@@ -6,6 +6,7 @@
#include "PerformanceMainThread.h"
#include "PerformanceNavigation.h"
#include "mozilla/dom/DOMPreferences.h"
#include "nsICacheInfoChannel.h"
namespace mozilla {
@@ -271,7 +272,7 @@ PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry)
nsAutoCString uri;
uint64_t markCreationEpoch = 0;
if (nsContentUtils::IsUserTimingLoggingEnabled() ||
if (DOMPreferences::PerformanceLoggingEnabled() ||
nsContentUtils::SendPerformanceTimingNotifications()) {
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
@@ -285,7 +286,7 @@ PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry)
}
markCreationEpoch = static_cast<uint64_t>(PR_Now() / PR_USEC_PER_MSEC);
if (nsContentUtils::IsUserTimingLoggingEnabled()) {
if (DOMPreferences::PerformanceLoggingEnabled()) {
Performance::LogEntry(aEntry, uri);
}
}

View File

@@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PerformanceWorker.h"
#include "mozilla/dom/DOMPreferences.h"
#include "WorkerPrivate.h"
namespace mozilla {
@@ -26,7 +27,7 @@ PerformanceWorker::~PerformanceWorker()
void
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
{
if (mWorkerPrivate->PerformanceLoggingEnabled()) {
if (DOMPreferences::PerformanceLoggingEnabled()) {
nsAutoCString uri;
nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {

View File

@@ -21,7 +21,6 @@
// * First argument is the name of the pref.
// * The name of the function that updates the new value of a pref.
WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)