From 3645d7dba0f4e1a14422b05f4088159ca18dfa30 Mon Sep 17 00:00:00 2001 From: Cameron McCormack Date: Thu, 30 Apr 2020 09:18:23 +0000 Subject: [PATCH] Bug 1582293 - Part 1: Fix pref observation code formatting. r=asuth Differential Revision: https://phabricator.services.mozilla.com/D70590 --- dom/workers/RuntimeService.cpp | 51 ++++++++++++++++------------------ 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/dom/workers/RuntimeService.cpp b/dom/workers/RuntimeService.cpp index 32add56d7b53..c6d86e4d8a1c 100644 --- a/dom/workers/RuntimeService.cpp +++ b/dom/workers/RuntimeService.cpp @@ -1525,6 +1525,9 @@ nsresult RuntimeService::Init() { MOZ_ASSERT(!gRuntimeServiceDuringInit, "This should be false!"); gRuntimeServiceDuringInit = true; +#define WORKER_PREF(name, callback) \ + NS_FAILED(Preferences::RegisterCallbackAndCall(callback, name)) + if (NS_FAILED(Preferences::RegisterPrefixCallback( LoadJSGCMemoryOptions, PREF_JS_OPTIONS_PREFIX PREF_MEM_OPTIONS_PREFIX)) || @@ -1535,25 +1538,22 @@ nsresult RuntimeService::Init() { NS_FAILED(Preferences::RegisterCallback( LoadGCZealOptions, PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) || #endif - -#define WORKER_PREF(name, callback) \ - NS_FAILED(Preferences::RegisterCallbackAndCall(callback, name)) || - WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) WORKER_PREF( - "general.appname.override", AppNameOverrideChanged) - WORKER_PREF("general.appversion.override", AppVersionOverrideChanged) - WORKER_PREF("general.platform.override", PlatformOverrideChanged) + WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) || + WORKER_PREF("general.appname.override", AppNameOverrideChanged) || + WORKER_PREF("general.appversion.override", AppVersionOverrideChanged) || + WORKER_PREF("general.platform.override", PlatformOverrideChanged) || #ifdef JS_GC_ZEAL - WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions) + WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions) || #endif -#undef WORKER_PREF - - NS_FAILED(Preferences::RegisterPrefixCallbackAndCall( - LoadContextOptions, PREF_WORKERS_OPTIONS_PREFIX)) || + NS_FAILED(Preferences::RegisterPrefixCallbackAndCall( + LoadContextOptions, PREF_WORKERS_OPTIONS_PREFIX)) || NS_FAILED(Preferences::RegisterPrefixCallback(LoadContextOptions, PREF_JS_OPTIONS_PREFIX))) { NS_WARNING("Failed to register pref callbacks!"); } +#undef WORKER_PREF + MOZ_ASSERT(gRuntimeServiceDuringInit, "Should be true!"); gRuntimeServiceDuringInit = false; @@ -1802,27 +1802,22 @@ void RuntimeService::Cleanup() { NS_ASSERTION(!mWindowMap.Count(), "All windows should have been released!"); +#define WORKER_PREF(name, callback) \ + NS_FAILED(Preferences::UnregisterCallback(callback, name)) + if (mObserved) { if (NS_FAILED(Preferences::UnregisterPrefixCallback( LoadContextOptions, PREF_JS_OPTIONS_PREFIX)) || NS_FAILED(Preferences::UnregisterPrefixCallback( LoadContextOptions, PREF_WORKERS_OPTIONS_PREFIX)) || -#define WORKER_PREF(name, callback) \ - NS_FAILED(Preferences::UnregisterCallback(callback, name)) || - WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) WORKER_PREF( - "general.appname.override", - AppNameOverrideChanged) WORKER_PREF("general.appversion.override", - AppVersionOverrideChanged) - WORKER_PREF("general.platform.override", PlatformOverrideChanged) + WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) || + WORKER_PREF("general.appname.override", AppNameOverrideChanged) || + WORKER_PREF("general.appversion.override", AppVersionOverrideChanged) || + WORKER_PREF("general.platform.override", PlatformOverrideChanged) || #ifdef JS_GC_ZEAL - WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions) -#endif -#undef WORKER_PREF - -#ifdef JS_GC_ZEAL - NS_FAILED(Preferences::UnregisterCallback( - LoadGCZealOptions, - PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) || + WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions) || + NS_FAILED(Preferences::UnregisterCallback( + LoadGCZealOptions, PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) || #endif NS_FAILED(Preferences::UnregisterPrefixCallback( LoadJSGCMemoryOptions, @@ -1833,6 +1828,8 @@ void RuntimeService::Cleanup() { NS_WARNING("Failed to unregister pref callbacks!"); } +#undef WORKER_PREF + if (obs) { if (NS_FAILED(obs->RemoveObserver(this, GC_REQUEST_OBSERVER_TOPIC))) { NS_WARNING("Failed to unregister for GC request notifications!");