Bug 940273 - Part 2 - Add a pref to enable Service Worker Cache. r=ehsan

This commit is contained in:
Ben Kelly 2015-03-02 14:12:00 +01:00
parent 86b1b38852
commit cd6213057e
4 changed files with 27 additions and 0 deletions

View File

@ -156,6 +156,7 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
#endif
#define PREF_DOM_FETCH_ENABLED "dom.fetch.enabled"
#define PREF_DOM_CACHES_ENABLED "dom.caches.enabled"
#define PREF_WORKERS_LATEST_JS_VERSION "dom.workers.latestJSVersion"
#define PREF_INTL_ACCEPT_LANGUAGES "intl.accept_languages"
@ -1778,6 +1779,10 @@ RuntimeService::Init()
WorkerPrefChanged,
PREF_DOM_FETCH_ENABLED,
reinterpret_cast<void *>(WORKERPREF_DOM_FETCH))) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
WorkerPrefChanged,
PREF_DOM_CACHES_ENABLED,
reinterpret_cast<void *>(WORKERPREF_DOM_CACHES))) ||
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeOptions,
PREF_JS_OPTIONS_PREFIX,
nullptr)) ||
@ -1967,6 +1972,10 @@ RuntimeService::Cleanup()
NS_FAILED(Preferences::UnregisterCallback(LoadRuntimeOptions,
PREF_WORKERS_OPTIONS_PREFIX,
nullptr)) ||
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
PREF_DOM_CACHES_ENABLED,
reinterpret_cast<void *>(WORKERPREF_DOM_CACHES))) ||
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
PREF_DOM_FETCH_ENABLED,
@ -2561,6 +2570,12 @@ RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
Preferences::GetBool(PREF_DOM_FETCH_ENABLED, false);
}
if (key == WORKERPREF_DOM_CACHES) {
key = WORKERPREF_DOM_CACHES;
sDefaultPreferences[WORKERPREF_DOM_CACHES] =
Preferences::GetBool(PREF_DOM_CACHES_ENABLED, false);
}
// This function should never be registered as a callback for a preference it
// does not handle.
MOZ_ASSERT(key != WORKERPREF_COUNT);

View File

@ -1180,6 +1180,13 @@ public:
return mPreferences[WORKERPREF_DOM_FETCH];
}
bool
DOMCachesEnabled() const
{
AssertIsOnWorkerThread();
return mPreferences[WORKERPREF_DOM_CACHES];
}
bool
OnLine() const
{

View File

@ -166,6 +166,7 @@ enum WorkerPreference
{
WORKERPREF_DUMP = 0, // browser.dom.window.dump.enabled
WORKERPREF_DOM_FETCH,// dom.fetch.enabled
WORKERPREF_DOM_CACHES, // dom.caches.enabled
WORKERPREF_COUNT
};

View File

@ -4433,6 +4433,10 @@ pref("camera.control.face_detection.enabled", true);
// Fetch API.
pref("dom.fetch.enabled", false);
// SW Cache API
pref("dom.caches.enabled", false);
#ifdef MOZ_WIDGET_GONK
// Empirically, this is the value returned by hal::GetTotalSystemMemory()
// when Flame's memory is limited to 512MiB. If the camera stack determines