Bug 1419771 - Introduce DOMPreferences, a thread-safe access to preferences for DOM - part 10 - StorageManager enabled, r=asuth

This commit is contained in:
Andrea Marchesini 2017-12-13 14:02:45 -06:00
Родитель e21d3ed9a0
Коммит 2ee056048d
7 изменённых файлов: 9 добавлений и 21 удалений

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

@ -44,6 +44,7 @@ PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.en
PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
PREF(StorageManagerEnabled, "dom.storageManager.enabled")
#undef PREF
@ -59,6 +60,7 @@ PREF_WEBIDL(DOMCachesEnabled)
PREF_WEBIDL(NotificationEnabledInServiceWorkers)
PREF_WEBIDL(NotificationRIEnabled)
PREF_WEBIDL(ServiceWorkersEnabled)
PREF_WEBIDL(StorageManagerEnabled)
#undef PREF_WEBIDL

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

@ -51,6 +51,10 @@ public:
// 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);
};
} // dom namespace

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

@ -6,6 +6,7 @@
#include "StorageManager.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/quota/QuotaManagerService.h"
#include "mozilla/dom/StorageManagerBinding.h"
@ -865,20 +866,6 @@ StorageManager::Estimate(ErrorResult& aRv)
aRv);
}
// static
bool
StorageManager::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.storageManager.enabled");
}
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->StorageManagerEnabled();
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(StorageManager, mOwner)
NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageManager)

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

@ -25,10 +25,6 @@ class StorageManager final
nsCOMPtr<nsIGlobalObject> mOwner;
public:
// Return dom.quota.storageManager.enabled on main/worker thread.
static bool
PrefEnabled(JSContext* aCx, JSObject* aObj);
explicit
StorageManager(nsIGlobalObject* aGlobal);

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

@ -89,7 +89,7 @@ interface NavigatorContentUtils {
[SecureContext, NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorStorage {
[Func="mozilla::dom::StorageManager::PrefEnabled"]
[Func="mozilla::dom::DOMPreferences::StorageManagerEnabled"]
readonly attribute StorageManager storage;
};

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

@ -10,7 +10,7 @@
[SecureContext,
Exposed=(Window,Worker),
Func="mozilla::dom::StorageManager::PrefEnabled"]
Func="mozilla::dom::DOMPreferences::StorageManagerEnabled"]
interface StorageManager {
[Throws]
Promise<boolean> persisted();

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

@ -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.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)