mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1419771 - Introduce DOMPrefs, a thread-safe access to preferences for DOM - part 22 - DOMPrefs initialized at startup, r=asuth
This commit is contained in:
parent
112a861fb6
commit
e10464a465
@ -11,7 +11,26 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
#define PREF(name, pref) \
|
||||
void
|
||||
DOMPrefs::Initialize()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
// Let's cache all the values on the main-thread.
|
||||
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
|
||||
DOMPrefs::DumpEnabled();
|
||||
#endif
|
||||
|
||||
#define DOM_PREF(name, pref) DOMPrefs::name();
|
||||
#define DOM_WEBIDL_PREF(name)
|
||||
|
||||
#include "DOMPrefsInternal.h"
|
||||
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
}
|
||||
|
||||
#define DOM_PREF(name, pref) \
|
||||
/* static */ bool \
|
||||
DOMPrefs::name() \
|
||||
{ \
|
||||
@ -24,8 +43,15 @@ namespace dom {
|
||||
return cachedValue; \
|
||||
}
|
||||
|
||||
#define DOM_WEBIDL_PREF(name) \
|
||||
/* static */ bool \
|
||||
DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
|
||||
{ \
|
||||
return DOMPrefs::name(); \
|
||||
}
|
||||
|
||||
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
|
||||
PREF(DumpEnabled, "browser.dom.window.dump.enabled")
|
||||
DOM_PREF(DumpEnabled, "browser.dom.window.dump.enabled")
|
||||
#else
|
||||
/* static */ bool
|
||||
DOMPrefs::DumpEnabled()
|
||||
@ -34,52 +60,10 @@ DOMPrefs::DumpEnabled()
|
||||
}
|
||||
#endif
|
||||
|
||||
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")
|
||||
PREF(NotificationEnabled, "dom.webnotifications.enabled")
|
||||
PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
|
||||
PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
|
||||
PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
|
||||
PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
|
||||
PREF(StorageManagerEnabled, "dom.storageManager.enabled")
|
||||
PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
|
||||
PREF(PushEnabled, "dom.push.enabled")
|
||||
PREF(StreamsEnabled, "dom.streams.enabled")
|
||||
PREF(RequestContextEnabled, "dom.requestcontext.enabled")
|
||||
PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
|
||||
PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
|
||||
PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
|
||||
PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
|
||||
PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
|
||||
PREF(DevToolsEnabled, "devtools.enabled")
|
||||
#include "DOMPrefsInternal.h"
|
||||
|
||||
#undef PREF
|
||||
|
||||
#define PREF_WEBIDL(name) \
|
||||
/* static */ bool \
|
||||
DOMPrefs::name(JSContext* aCx, JSObject* aObj) \
|
||||
{ \
|
||||
return DOMPrefs::name(); \
|
||||
}
|
||||
|
||||
PREF_WEBIDL(ImageBitmapExtensionsEnabled)
|
||||
PREF_WEBIDL(DOMCachesEnabled)
|
||||
PREF_WEBIDL(NotificationEnabledInServiceWorkers)
|
||||
PREF_WEBIDL(NotificationRIEnabled)
|
||||
PREF_WEBIDL(ServiceWorkersEnabled)
|
||||
PREF_WEBIDL(StorageManagerEnabled)
|
||||
PREF_WEBIDL(PromiseRejectionEventsEnabled)
|
||||
PREF_WEBIDL(PushEnabled)
|
||||
PREF_WEBIDL(StreamsEnabled)
|
||||
PREF_WEBIDL(RequestContextEnabled)
|
||||
PREF_WEBIDL(OffscreenCanvasEnabled)
|
||||
PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
|
||||
PREF_WEBIDL(NetworkInformationEnabled)
|
||||
PREF_WEBIDL(FetchObserverEnabled)
|
||||
|
||||
#undef PREF_WEBIDL
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
@ -13,86 +13,19 @@ namespace dom {
|
||||
class DOMPrefs final
|
||||
{
|
||||
public:
|
||||
// This must be called on the main-thread.
|
||||
static void Initialize();
|
||||
|
||||
// Returns true if the browser.dom.window.dump.enabled pref is set.
|
||||
static bool DumpEnabled();
|
||||
|
||||
// Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
|
||||
static bool ImageBitmapExtensionsEnabled();
|
||||
static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
|
||||
#define DOM_PREF(name, pref) static bool name();
|
||||
#define DOM_WEBIDL_PREF(name) static bool name(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.caches.enabled pref is set.
|
||||
static bool DOMCachesEnabled();
|
||||
static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
|
||||
#include "DOMPrefsInternal.h"
|
||||
|
||||
// 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();
|
||||
|
||||
// Returns true if the dom.webnotifications.enabled pref is set.
|
||||
// Note that you should use NotificationEnabledInServiceWorkers if you need to
|
||||
// enable Notification API for ServiceWorkers
|
||||
static bool NotificationEnabled();
|
||||
|
||||
// Returns true if the dom.webnotifications.serviceworker.enabled pref is set.
|
||||
static bool NotificationEnabledInServiceWorkers();
|
||||
static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
|
||||
JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.webnotifications.requireinteraction.enabled pref is
|
||||
// set.
|
||||
static bool NotificationRIEnabled();
|
||||
static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.serviceWorkers.enabled pref is set.
|
||||
static bool ServiceWorkersEnabled();
|
||||
static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.serviceWorkers.testing.enabled pref is set.
|
||||
static bool ServiceWorkersTestingEnabled();
|
||||
|
||||
// Returns true if the dom.storageManager.enabled pref is set.
|
||||
static bool StorageManagerEnabled();
|
||||
static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.promise_rejection_events.enabled pref is set.
|
||||
static bool PromiseRejectionEventsEnabled();
|
||||
static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.push.enabled pref is set.
|
||||
static bool PushEnabled();
|
||||
static bool PushEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.streams.enabled pref is set.
|
||||
static bool StreamsEnabled();
|
||||
static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.requestcontext.enabled pref is set.
|
||||
static bool RequestContextEnabled();
|
||||
static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the gfx.offscreencanvas.enabled pref is set.
|
||||
static bool OffscreenCanvasEnabled();
|
||||
static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
|
||||
static bool WebkitBlinkDirectoryPickerEnabled();
|
||||
static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.netinfo.enabled pref is set.
|
||||
static bool NetworkInformationEnabled();
|
||||
static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the dom.fetchObserver.enabled pref is set.
|
||||
static bool FetchObserverEnabled();
|
||||
static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
|
||||
|
||||
// Returns true if the privacy.resistFingerprinting pref is set.
|
||||
static bool ResistFingerprintingEnabled();
|
||||
|
||||
// Returns true if the devtools.enabled pref is set.
|
||||
static bool DevToolsEnabled();
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
|
56
dom/base/DOMPrefsInternal.h
Normal file
56
dom/base/DOMPrefsInternal.h
Normal file
@ -0,0 +1,56 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* 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/. */
|
||||
|
||||
// This is the list of the preferences that are exposed to workers and
|
||||
// main-thread in DOM.
|
||||
// The format is as follows:
|
||||
//
|
||||
// DOM_PREF(FooBar, "foo.bar")
|
||||
//
|
||||
// * First argument is the name of the getter function. This defines a
|
||||
// DOMPrefs::FooBar()
|
||||
// * The second argument is the name of the pref.
|
||||
//
|
||||
// DOM_WEBIDL_PREF(FooBar)
|
||||
//
|
||||
// * This defines DOMPrefs::FooBar(JSContext* aCx, JSObject* aObj);
|
||||
// This is allows the use of DOMPrefs in WebIDL files.
|
||||
|
||||
DOM_PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
|
||||
DOM_PREF(DOMCachesEnabled, "dom.caches.enabled")
|
||||
DOM_PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
|
||||
DOM_PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
|
||||
DOM_PREF(NotificationEnabled, "dom.webnotifications.enabled")
|
||||
DOM_PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
|
||||
DOM_PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
|
||||
DOM_PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
|
||||
DOM_PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
|
||||
DOM_PREF(StorageManagerEnabled, "dom.storageManager.enabled")
|
||||
DOM_PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
|
||||
DOM_PREF(PushEnabled, "dom.push.enabled")
|
||||
DOM_PREF(StreamsEnabled, "dom.streams.enabled")
|
||||
DOM_PREF(RequestContextEnabled, "dom.requestcontext.enabled")
|
||||
DOM_PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
|
||||
DOM_PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
|
||||
DOM_PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
|
||||
DOM_PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
|
||||
DOM_PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
|
||||
DOM_PREF(DevToolsEnabled, "devtools.enabled")
|
||||
|
||||
DOM_WEBIDL_PREF(ImageBitmapExtensionsEnabled)
|
||||
DOM_WEBIDL_PREF(DOMCachesEnabled)
|
||||
DOM_WEBIDL_PREF(NotificationEnabledInServiceWorkers)
|
||||
DOM_WEBIDL_PREF(NotificationRIEnabled)
|
||||
DOM_WEBIDL_PREF(ServiceWorkersEnabled)
|
||||
DOM_WEBIDL_PREF(StorageManagerEnabled)
|
||||
DOM_WEBIDL_PREF(PromiseRejectionEventsEnabled)
|
||||
DOM_WEBIDL_PREF(PushEnabled)
|
||||
DOM_WEBIDL_PREF(StreamsEnabled)
|
||||
DOM_WEBIDL_PREF(RequestContextEnabled)
|
||||
DOM_WEBIDL_PREF(OffscreenCanvasEnabled)
|
||||
DOM_WEBIDL_PREF(WebkitBlinkDirectoryPickerEnabled)
|
||||
DOM_WEBIDL_PREF(NetworkInformationEnabled)
|
||||
DOM_WEBIDL_PREF(FetchObserverEnabled)
|
@ -173,6 +173,7 @@ EXPORTS.mozilla.dom += [
|
||||
'DOMParser.h',
|
||||
'DOMPoint.h',
|
||||
'DOMPrefs.h',
|
||||
'DOMPrefsInternal.h',
|
||||
'DOMQuad.h',
|
||||
'DOMRect.h',
|
||||
'DOMRequest.h',
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "mozilla/dom/ClientOpenWindowOpActors.h"
|
||||
#include "mozilla/dom/ContentBridgeChild.h"
|
||||
#include "mozilla/dom/ContentBridgeParent.h"
|
||||
#include "mozilla/dom/DOMPrefs.h"
|
||||
#include "mozilla/dom/VideoDecoderManagerChild.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/DataTransfer.h"
|
||||
@ -1228,6 +1229,8 @@ ContentChild::InitXPCOM(const XPCOMInitData& aXPCOMInit,
|
||||
|
||||
// Set the dynamic scalar definitions for this process.
|
||||
TelemetryIPC::AddDynamicScalarDefinitions(aXPCOMInit.dynamicScalarDefs());
|
||||
|
||||
DOMPrefs::Initialize();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
|
@ -319,6 +319,13 @@ nsLayoutStatics::Initialize()
|
||||
mozilla::dom::IPCBlobInputStreamStorage::Initialize();
|
||||
|
||||
mozilla::dom::U2FTokenManager::Initialize();
|
||||
|
||||
if (XRE_IsParentProcess()) {
|
||||
// On content process we initialize DOMPrefs when PContentChild is fully
|
||||
// initialized.
|
||||
mozilla::dom::DOMPrefs::Initialize();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class DomGroup;
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
@ -39,7 +40,7 @@ public:
|
||||
NS_IMETHOD GetParentRule(nsIDOMCSSRule **aParent) override;
|
||||
|
||||
virtual nsINode* GetParentObject() override;
|
||||
virtual DocGroup* GetDocGroup() const override;
|
||||
virtual mozilla::dom::DocGroup* GetDocGroup() const override;
|
||||
|
||||
NS_IMETHOD SetPropertyValue(const nsCSSPropertyID aPropID,
|
||||
const nsAString& aValue,
|
||||
|
Loading…
Reference in New Issue
Block a user