Bug 709490 - Part 10: Using mechanism in RuntimeService to get pref in worker thread instead of gfxPref, r=baku

This commit is contained in:
Morris Tseng 2015-09-29 11:51:25 +01:00
parent 7c548ee466
commit d99c93a009
5 changed files with 25 additions and 2 deletions

View File

@ -210,7 +210,13 @@ OffscreenCanvas::CreateFromCloneData(OffscreenCanvasCloneData* aData)
/* static */ bool
OffscreenCanvas::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
return gfxPrefs::OffscreenCanvasEnabled();
if (NS_IsMainThread()) {
return Preferences::GetBool("gfx.offscreencanvas.enabled");
} else {
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->OffscreenCanvasEnabled();
}
}
/* static */ bool

View File

@ -170,6 +170,7 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
#define PREF_INTERCEPTION_OPAQUE_ENABLED "dom.serviceWorkers.interception.opaque.enabled"
#define PREF_PUSH_ENABLED "dom.push.enabled"
#define PREF_REQUESTCONTEXT_ENABLED "dom.requestcontext.enabled"
#define PREF_OFFSCREENCANVAS_ENABLED "gfx.offscreencanvas.enabled"
namespace {
@ -1968,6 +1969,10 @@ RuntimeService::Init()
WorkerPrefChanged,
PREF_REQUESTCONTEXT_ENABLED,
reinterpret_cast<void *>(WORKERPREF_REQUESTCONTEXT))) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
WorkerPrefChanged,
PREF_OFFSCREENCANVAS_ENABLED,
reinterpret_cast<void *>(WORKERPREF_OFFSCREENCANVAS))) ||
NS_FAILED(Preferences::RegisterCallback(LoadRuntimeOptions,
PREF_JS_OPTIONS_PREFIX,
nullptr)) ||
@ -2207,6 +2212,10 @@ RuntimeService::Cleanup()
WorkerPrefChanged,
PREF_REQUESTCONTEXT_ENABLED,
reinterpret_cast<void *>(WORKERPREF_REQUESTCONTEXT))) ||
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
PREF_OFFSCREENCANVAS_ENABLED,
reinterpret_cast<void *>(WORKERPREF_OFFSCREENCANVAS))) ||
#if DUMP_CONTROLLED_BY_PREF
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
@ -2768,6 +2777,7 @@ RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
case WORKERPREF_SERVICEWORKERS_TESTING:
case WORKERPREF_PUSH:
case WORKERPREF_REQUESTCONTEXT:
case WORKERPREF_OFFSCREENCANVAS:
sDefaultPreferences[key] = Preferences::GetBool(aPrefName, false);
break;

View File

@ -1313,6 +1313,13 @@ public:
return mPreferences[WORKERPREF_REQUESTCONTEXT];
}
bool
OffscreenCanvasEnabled() const
{
AssertIsOnWorkerThread();
return mPreferences[WORKERPREF_OFFSCREENCANVAS];
}
bool
OnLine() const
{

View File

@ -209,6 +209,7 @@ enum WorkerPreference
WORKERPREF_PERFORMANCE_LOGGING_ENABLED, // dom.performance.enable_user_timing_logging
WORKERPREF_PUSH, // dom.push.enabled
WORKERPREF_REQUESTCONTEXT, // dom.requestcontext.enabled
WORKERPREF_OFFSCREENCANVAS, // gfx.offscreencanvas.enabled
WORKERPREF_COUNT
};

View File

@ -244,7 +244,6 @@ private:
DECL_GFX_PREF(Live, "gfx.layerscope.port", LayerScopePort, int32_t, 23456);
// Note that "gfx.logging.level" is defined in Logging.h
DECL_GFX_PREF(Once, "gfx.logging.crash.length", GfxLoggingCrashLength, uint32_t, 6);
DECL_GFX_PREF(Live, "gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, bool, false);
DECL_GFX_PREF(Live, "gfx.perf-warnings.enabled", PerfWarnings, bool, false);
DECL_GFX_PREF(Live, "gfx.SurfaceTexture.detach.enabled", SurfaceTextureDetachEnabled, bool, true);
DECL_GFX_PREF(Live, "gfx.testing.device-reset", DeviceResetForTesting, int32_t, 0);