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

This commit is contained in:
Andrea Marchesini 2018-01-08 14:05:04 +01:00
Родитель 615e4c18e4
Коммит 61778fdf43
7 изменённых файлов: 9 добавлений и 17 удалений

Просмотреть файл

@ -37,6 +37,7 @@ DOMPrefs::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

Просмотреть файл

@ -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

Просмотреть файл

@ -292,7 +292,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;
@ -649,9 +648,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);

Просмотреть файл

@ -2286,14 +2286,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;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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)