From 98461fc4a49902c77291945472e1a5fb42b3766d Mon Sep 17 00:00:00 2001 From: Juan Gomez Date: Wed, 24 Jun 2015 14:11:00 -0400 Subject: [PATCH] Bug 1171931 - Refactor duplicated code using XRE_IsParent/ContentProcess. r=froydnj --- accessible/base/nsAccessibilityService.cpp | 6 +- accessible/base/nsAccessibilityService.h | 2 +- accessible/base/nsCoreUtils.cpp | 2 +- accessible/windows/msaa/nsWinUtils.cpp | 2 +- caps/DomainPolicy.cpp | 12 +-- caps/nsScriptSecurityManager.cpp | 4 +- docshell/base/nsDefaultURIFixup.cpp | 2 +- docshell/base/nsDocShell.cpp | 10 +-- dom/asmjscache/AsmJSCache.cpp | 16 ++-- dom/audiochannel/AudioChannelService.cpp | 18 ++-- dom/base/Crypto.cpp | 2 +- dom/base/Navigator.cpp | 4 +- dom/base/nsCCUncollectableMarker.cpp | 2 +- dom/base/nsContentPermissionHelper.cpp | 2 +- dom/base/nsDocument.cpp | 2 +- dom/base/nsFocusManager.cpp | 4 +- dom/base/nsFrameLoader.cpp | 6 +- dom/base/nsFrameMessageManager.cpp | 8 +- dom/base/nsGlobalWindow.cpp | 4 +- dom/base/nsObjectLoadingContent.cpp | 2 +- dom/base/nsWindowMemoryReporter.cpp | 2 +- dom/base/nsXMLHttpRequest.cpp | 2 +- dom/bluetooth/BluetoothUtils.cpp | 6 -- dom/bluetooth/BluetoothUtils.h | 8 -- dom/bluetooth/bluetooth1/BluetoothAdapter.cpp | 2 +- dom/bluetooth/bluetooth1/BluetoothService.cpp | 10 +-- dom/bluetooth/bluetooth2/BluetoothAdapter.cpp | 2 +- dom/bluetooth/bluetooth2/BluetoothService.cpp | 6 +- dom/bluetooth/bluez/BluetoothHfpManager.cpp | 2 +- dom/cellbroadcast/CellBroadcast.cpp | 2 +- dom/datastore/DataStoreService.cpp | 86 ++++++------------- dom/devicestorage/nsDeviceStorage.cpp | 36 ++++---- dom/events/EventStateManager.cpp | 2 +- dom/events/IMEStateManager.cpp | 2 +- dom/filehandle/FileStreamWrappers.cpp | 2 +- dom/filesystem/CreateDirectoryTask.cpp | 4 +- dom/filesystem/CreateFileTask.cpp | 8 +- dom/filesystem/DeviceStorageFileSystem.cpp | 8 +- dom/filesystem/FileSystemTaskBase.cpp | 10 +-- dom/filesystem/FileSystemUtils.cpp | 7 -- dom/filesystem/FileSystemUtils.h | 3 - dom/filesystem/GetFileOrDirectoryTask.cpp | 4 +- dom/filesystem/RemoveTask.cpp | 4 +- dom/fmradio/FMRadioService.cpp | 4 +- dom/fmradio/ipc/FMRadioChild.cpp | 2 +- dom/gamepad/GamepadFunctions.cpp | 14 +-- dom/gamepad/GamepadMonitoring.cpp | 2 +- dom/gamepad/GamepadService.cpp | 6 +- dom/geolocation/nsGeolocation.cpp | 10 +-- dom/geolocation/nsGeolocationSettings.cpp | 2 +- dom/html/HTMLInputElement.cpp | 6 +- dom/html/nsGenericHTMLFrameElement.cpp | 2 +- dom/icc/IccManager.cpp | 2 +- dom/indexedDB/ActorsChild.cpp | 8 +- dom/indexedDB/FileSnapshot.cpp | 2 +- dom/indexedDB/IndexedDatabaseManager.cpp | 4 +- dom/indexedDB/PermissionRequestBase.cpp | 2 +- dom/ipc/Blob.cpp | 4 +- dom/ipc/ContentChild.cpp | 2 +- dom/ipc/ContentParent.cpp | 14 +-- dom/ipc/ContentProcessManager.cpp | 2 +- dom/ipc/ProcessHangMonitor.cpp | 2 +- dom/ipc/ProcessPriorityManager.cpp | 16 ++-- dom/ipc/TabParent.cpp | 4 +- dom/media/MediaManager.cpp | 2 +- dom/media/gmp/GMPService.cpp | 2 +- dom/media/gmp/GMPServiceChild.cpp | 2 +- dom/media/gmp/GMPServiceParent.cpp | 4 +- dom/media/webspeech/synth/nsSpeechTask.cpp | 12 +-- .../webspeech/synth/nsSynthVoiceRegistry.cpp | 12 +-- .../webspeech/synth/pico/nsPicoService.cpp | 2 +- .../synth/test/nsFakeSynthServices.cpp | 2 +- .../MobileConnectionArray.cpp | 2 +- dom/mobilemessage/MobileMessageManager.cpp | 6 +- dom/network/UDPSocket.cpp | 2 +- dom/nfc/gonk/NfcService.cpp | 2 +- dom/plugins/base/nsNPAPIPlugin.cpp | 4 +- dom/plugins/base/nsPluginHost.cpp | 36 ++++---- dom/plugins/base/nsPluginInstanceOwner.cpp | 8 +- dom/plugins/base/nsPluginNativeWindowGtk.cpp | 2 +- dom/plugins/base/nsPluginNativeWindowWin.cpp | 2 +- dom/plugins/base/nsPluginTags.cpp | 2 +- dom/plugins/ipc/PluginInstanceParent.cpp | 4 +- dom/plugins/ipc/PluginModuleParent.cpp | 4 +- dom/promise/PromiseDebugging.cpp | 2 +- dom/quota/QuotaManager.cpp | 17 ++-- dom/speakermanager/SpeakerManagerService.cpp | 8 +- dom/storage/DOMStorageCache.cpp | 4 +- dom/storage/DOMStorageManager.cpp | 6 +- dom/storage/DOMStorageObserver.cpp | 2 +- dom/system/gonk/AudioManager.cpp | 2 +- dom/system/gonk/AutoMounter.cpp | 10 +-- dom/system/gonk/NetworkWorker.cpp | 2 +- dom/system/gonk/SystemWorkerManager.cpp | 2 +- dom/system/gonk/Volume.cpp | 26 +++--- dom/system/gonk/nsVolume.cpp | 20 ++--- dom/system/gonk/nsVolumeService.cpp | 18 ++-- dom/telephony/Telephony.cpp | 2 +- dom/voicemail/Voicemail.cpp | 2 +- dom/wifi/WifiCertService.cpp | 2 +- dom/wifi/WifiProxyService.cpp | 2 +- dom/workers/ServiceWorkerManager.cpp | 12 +-- dom/workers/ServiceWorkerPeriodicUpdater.cpp | 2 +- dom/workers/ServiceWorkerRegistrar.cpp | 4 +- dom/workers/WorkerPrivate.cpp | 2 +- embedding/browser/nsWebBrowser.cpp | 2 +- .../windowwatcher/nsWindowWatcher.cpp | 2 +- extensions/cookie/nsPermissionManager.cpp | 2 +- extensions/spellcheck/src/mozSpellChecker.cpp | 14 +-- gfx/gl/GLScreenBuffer.cpp | 1 - gfx/layers/client/ClientCanvasLayer.cpp | 3 +- gfx/layers/client/ClientLayerManager.cpp | 4 +- gfx/layers/ipc/CompositorChild.cpp | 2 +- gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp | 4 +- gfx/layers/opengl/TextureClientOGL.cpp | 4 +- gfx/thebes/gfxAndroidPlatform.cpp | 2 +- gfx/thebes/gfxFT2FontList.cpp | 4 +- gfx/thebes/gfxPlatform.cpp | 6 +- gfx/thebes/gfxWindowsPlatform.cpp | 2 +- image/decoders/icon/android/nsIconChannel.cpp | 2 +- ipc/glue/BackgroundImpl.cpp | 23 +---- ipc/glue/BackgroundParentImpl.cpp | 2 +- ipc/glue/InputStreamUtils.cpp | 2 +- ipc/glue/ScopedXREEmbed.cpp | 2 +- js/xpconnect/loader/mozJSComponentLoader.cpp | 2 +- js/xpconnect/src/XPCJSRuntime.cpp | 6 +- js/xpconnect/src/XPCWrappedNativeInfo.cpp | 2 +- js/xpconnect/wrappers/AccessCheck.cpp | 2 +- js/xpconnect/wrappers/WrapperFactory.cpp | 2 +- layout/base/nsDisplayList.cpp | 2 +- layout/base/nsLayoutUtils.cpp | 2 +- layout/base/nsPresContext.cpp | 4 +- layout/base/nsPresShell.cpp | 8 +- layout/base/nsStyleSheetService.cpp | 6 +- layout/forms/nsListControlFrame.cpp | 2 +- layout/generic/nsPluginFrame.cpp | 4 +- layout/ipc/RenderFrameParent.cpp | 6 +- media/mtransport/nr_socket_prsock.cpp | 2 +- .../src/common/browser_logging/WebRtcLog.cpp | 2 +- .../src/peerconnection/PeerConnectionCtx.cpp | 2 +- .../src/peerconnection/PeerConnectionImpl.cpp | 6 +- .../WebrtcGlobalInformation.cpp | 8 +- modules/libjar/nsJARProtocolHandler.cpp | 2 +- modules/libpref/Preferences.cpp | 16 ++-- modules/libpref/nsPrefBranch.cpp | 2 +- netwerk/base/nsBaseChannel.cpp | 2 +- netwerk/base/nsChannelClassifier.cpp | 10 +-- netwerk/base/nsFileStreams.cpp | 2 +- netwerk/base/nsIOService.cpp | 8 +- .../mdns/libmdns/nsDNSServiceDiscovery.cpp | 2 +- netwerk/ipc/NeckoCommon.h | 2 +- netwerk/ipc/NeckoParent.cpp | 2 +- netwerk/protocol/app/AppProtocolHandler.cpp | 2 +- netwerk/protocol/data/nsDataHandler.cpp | 2 +- .../device/AndroidCaptureProvider.cpp | 2 +- netwerk/protocol/http/HttpBaseChannel.cpp | 4 +- netwerk/protocol/http/HttpChannelParent.cpp | 2 +- parser/html/nsHtml5StreamParser.cpp | 2 +- security/manager/ssl/PSMContentListener.cpp | 2 +- .../manager/ssl/TransportSecurityInfo.cpp | 2 +- security/manager/ssl/nsNSSComponent.cpp | 2 +- .../manager/ssl/nsSiteSecurityService.cpp | 2 +- .../sandbox/win/loggingCallbacks.h | 2 +- startupcache/StartupCache.cpp | 2 +- storage/VacuumManager.cpp | 2 +- toolkit/components/alerts/nsAlertsService.cpp | 4 +- .../diskspacewatcher/DiskSpaceWatcher.cpp | 2 +- toolkit/components/places/Database.cpp | 2 +- toolkit/components/places/History.cpp | 16 ++-- .../satchel/nsFormFillController.cpp | 2 +- toolkit/components/telemetry/Telemetry.cpp | 6 +- toolkit/crashreporter/nsExceptionHandler.cpp | 4 +- .../mozapps/extensions/AddonPathService.cpp | 2 +- toolkit/xre/nsAppRunner.cpp | 22 +++-- toolkit/xre/nsSigHandlers.cpp | 2 +- tools/profiler/ProfileEntry.cpp | 2 +- .../exthandler/nsExternalHelperAppService.cpp | 10 +-- widget/GfxInfoBase.cpp | 2 +- widget/PuppetWidget.cpp | 4 +- widget/android/nsAppShell.cpp | 2 +- widget/android/nsLookAndFeel.cpp | 4 +- widget/android/nsWindow.cpp | 4 +- widget/cocoa/nsLookAndFeel.mm | 2 +- widget/gonk/nsAppShell.cpp | 2 +- widget/gonk/nsClipboard.cpp | 8 +- widget/gonk/nsWidgetFactory.cpp | 2 +- widget/nsIWidget.h | 2 +- widget/nsIdleService.cpp | 6 +- widget/nsXPLookAndFeel.cpp | 2 +- widget/windows/AudioSession.cpp | 8 +- widget/windows/nsNativeThemeWin.cpp | 2 +- xpcom/base/nsDebugImpl.cpp | 2 +- xpcom/base/nsDumpUtils.cpp | 2 +- xpcom/base/nsMemoryInfoDumper.cpp | 2 +- xpcom/base/nsTraceRefcnt.cpp | 2 +- xpcom/build/XPCOMInit.cpp | 8 +- xpcom/build/nsXULAppAPI.h | 3 + xpcom/components/ManifestParser.cpp | 2 +- xpcom/io/nsAnonymousTemporaryFile.cpp | 2 +- xpcom/libxpcomrt/XPCOMRTStubs.cpp | 12 +++ xpcom/threads/nsThread.cpp | 2 +- 201 files changed, 506 insertions(+), 579 deletions(-) diff --git a/accessible/base/nsAccessibilityService.cpp b/accessible/base/nsAccessibilityService.cpp index 547aef232c8..4b42af35b97 100644 --- a/accessible/base/nsAccessibilityService.cpp +++ b/accessible/base/nsAccessibilityService.cpp @@ -1260,7 +1260,7 @@ nsAccessibilityService::Init() logging::CheckEnv(); #endif - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) gApplicationAccessible = new ApplicationAccessibleWrap(); else gApplicationAccessible = new ApplicationAccessible(); @@ -1281,7 +1281,7 @@ nsAccessibilityService::Init() gIsShutdown = false; // Now its safe to start platform accessibility. - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) PlatformInit(); return true; @@ -1324,7 +1324,7 @@ nsAccessibilityService::Shutdown() gIsShutdown = true; - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) PlatformShutdown(); gApplicationAccessible->Shutdown(); diff --git a/accessible/base/nsAccessibilityService.h b/accessible/base/nsAccessibilityService.h index 75091fc216b..5c1a3c96336 100644 --- a/accessible/base/nsAccessibilityService.h +++ b/accessible/base/nsAccessibilityService.h @@ -282,7 +282,7 @@ IPCAccessibilityActive() #ifdef MOZ_B2G return false; #else - return XRE_GetProcessType() == GeckoProcessType_Content && + return XRE_IsContentProcess() && mozilla::Preferences::GetBool("accessibility.ipc_architecture.enabled", true); #endif } diff --git a/accessible/base/nsCoreUtils.cpp b/accessible/base/nsCoreUtils.cpp index 2b427e39efd..4e9b2001c4f 100644 --- a/accessible/base/nsCoreUtils.cpp +++ b/accessible/base/nsCoreUtils.cpp @@ -425,7 +425,7 @@ nsCoreUtils::IsTabDocument(nsIDocument* aDocumentNode) treeItem->GetParent(getter_AddRefs(parentTreeItem)); // Tab document running in own process doesn't have parent. - if (XRE_GetProcessType() == GeckoProcessType_Content) + if (XRE_IsContentProcess()) return !parentTreeItem; // Parent of docshell for tab document running in chrome process is root. diff --git a/accessible/windows/msaa/nsWinUtils.cpp b/accessible/windows/msaa/nsWinUtils.cpp index 47a1488dae0..96a2ddb32f6 100644 --- a/accessible/windows/msaa/nsWinUtils.cpp +++ b/accessible/windows/msaa/nsWinUtils.cpp @@ -64,7 +64,7 @@ nsWinUtils::MaybeStartWindowEmulation() if (Compatibility::IsJAWS() || Compatibility::IsWE() || Compatibility::IsDolphin() || - XRE_GetProcessType() == GeckoProcessType_Content) { + XRE_IsContentProcess()) { RegisterNativeWindow(kClassNameTabContent); sHWNDCache = new nsRefPtrHashtable, DocAccessible>(2); return true; diff --git a/caps/DomainPolicy.cpp b/caps/DomainPolicy.cpp index a2ec3e34f68..e1a6a82fb6c 100644 --- a/caps/DomainPolicy.cpp +++ b/caps/DomainPolicy.cpp @@ -22,7 +22,7 @@ static nsresult BroadcastDomainSetChange(DomainSetType aSetType, DomainSetChangeType aChangeType, nsIURI* aDomain = nullptr) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT(XRE_IsParentProcess(), "DomainPolicy should only be exposed to the chrome process."); nsTArray parents; @@ -45,7 +45,7 @@ DomainPolicy::DomainPolicy() : mBlacklist(new DomainSet(BLACKLIST)) , mWhitelist(new DomainSet(WHITELIST)) , mSuperWhitelist(new DomainSet(SUPER_WHITELIST)) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { BroadcastDomainSetChange(NO_TYPE, ACTIVATE_POLICY); } } @@ -112,7 +112,7 @@ DomainPolicy::Deactivate() if (ssm) { ssm->DeactivateDomainPolicy(); } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { BroadcastDomainSetChange(NO_TYPE, DEACTIVATE_POLICY); } return NS_OK; @@ -170,7 +170,7 @@ DomainSet::Add(nsIURI* aDomain) nsCOMPtr clone = GetCanonicalClone(aDomain); NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE); mHashTable.PutEntry(clone); - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) return BroadcastDomainSetChange(mType, ADD_DOMAIN, aDomain); return NS_OK; @@ -182,7 +182,7 @@ DomainSet::Remove(nsIURI* aDomain) nsCOMPtr clone = GetCanonicalClone(aDomain); NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE); mHashTable.RemoveEntry(clone); - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) return BroadcastDomainSetChange(mType, REMOVE_DOMAIN, aDomain); return NS_OK; @@ -192,7 +192,7 @@ NS_IMETHODIMP DomainSet::Clear() { mHashTable.Clear(); - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) return BroadcastDomainSetChange(mType, CLEAR_DOMAINS); return NS_OK; diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 9648bb25e5a..9c73607f434 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -1285,7 +1285,7 @@ nsScriptSecurityManager::~nsScriptSecurityManager(void) // ContentChild might hold a reference to the domain policy, // and it might release it only after the security manager is // gone. But we can still assert this for the main process. - MOZ_ASSERT_IF(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT_IF(XRE_IsParentProcess(), !mDomainPolicy); } @@ -1502,7 +1502,7 @@ nsScriptSecurityManager::GetDomainPolicyActive(bool *aRv) NS_IMETHODIMP nsScriptSecurityManager::ActivateDomainPolicy(nsIDomainPolicy** aRv) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return NS_ERROR_SERVICE_NOT_AVAILABLE; } diff --git a/docshell/base/nsDefaultURIFixup.cpp b/docshell/base/nsDefaultURIFixup.cpp index 6bd9c4a6b99..df3fe28ddc5 100644 --- a/docshell/base/nsDefaultURIFixup.cpp +++ b/docshell/base/nsDefaultURIFixup.cpp @@ -416,7 +416,7 @@ nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword, } keyword.Trim(" "); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); if (!contentChild) { return NS_ERROR_NOT_AVAILABLE; diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 5eba509397c..269ed1b12f6 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -824,7 +824,7 @@ IncreasePrivateDocShellCount() { gNumberOfPrivateDocShells++; if (gNumberOfPrivateDocShells > 1 || - XRE_GetProcessType() != GeckoProcessType_Content) { + !XRE_IsContentProcess()) { return; } @@ -838,7 +838,7 @@ DecreasePrivateDocShellCount() MOZ_ASSERT(gNumberOfPrivateDocShells > 0); gNumberOfPrivateDocShells--; if (!gNumberOfPrivateDocShells) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* cc = dom::ContentChild::GetSingleton(); cc->SendPrivateDocShellsExist(false); return; @@ -5021,7 +5021,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI, mInPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0; bool isStsHost = false; bool isPinnedHost = false; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr sss = do_GetService(NS_SSSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); @@ -9449,7 +9449,7 @@ nsDocShell::CopyFavicon(nsIURI* aOldURI, nsIURI* aNewURI, bool aInPrivateBrowsing) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); if (contentChild) { mozilla::ipc::URIParams oldURI, newURI; @@ -13991,7 +13991,7 @@ nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider, return; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* contentChild = dom::ContentChild::GetSingleton(); if (contentChild) { contentChild->SendNotifyKeywordSearchLoading(aProvider, aKeyword); diff --git a/dom/asmjscache/AsmJSCache.cpp b/dom/asmjscache/AsmJSCache.cpp index 05be1bdebeb..5c0dd3b90a2 100644 --- a/dom/asmjscache/AsmJSCache.cpp +++ b/dom/asmjscache/AsmJSCache.cpp @@ -59,12 +59,6 @@ namespace asmjscache { namespace { -bool -IsMainProcess() -{ - return XRE_GetProcessType() == GeckoProcessType_Default; -} - // Anything smaller should compile fast enough that caching will just add // overhead. static const size_t sMinCachedModuleLength = 10000; @@ -503,7 +497,7 @@ public: mIsApp(false), mEnforcingQuota(true) { - MOZ_ASSERT(IsMainProcess()); + MOZ_ASSERT(XRE_IsParentProcess()); } virtual ~MainProcessRunnable() @@ -1133,7 +1127,7 @@ public: : MainProcessRunnable(aPrincipal, aOpenMode, aWriteParams), mReadParams(aReadParams) { - MOZ_ASSERT(IsMainProcess()); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(!NS_IsMainThread()); MOZ_COUNT_CTOR(SingleProcessRunnable); } @@ -1211,7 +1205,7 @@ public: mOpened(false), mFinished(false) { - MOZ_ASSERT(IsMainProcess()); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); MOZ_COUNT_CTOR(ParentProcessRunnable); } @@ -1388,7 +1382,7 @@ public: mActorDestroyed(false), mState(eInitial) { - MOZ_ASSERT(!IsMainProcess()); + MOZ_ASSERT(!XRE_IsParentProcess()); MOZ_ASSERT(!NS_IsMainThread()); MOZ_COUNT_CTOR(ChildProcessRunnable); } @@ -1584,7 +1578,7 @@ OpenFile(nsIPrincipal* aPrincipal, // parent process to open the file and interact with the QuotaManager. The // child can then map the file into its address space to perform I/O. nsRefPtr file; - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { file = new SingleProcessRunnable(aPrincipal, aOpenMode, aWriteParams, aReadParams); } else { diff --git a/dom/audiochannel/AudioChannelService.cpp b/dom/audiochannel/AudioChannelService.cpp index 48bce2aaacc..87eceb2a8ad 100644 --- a/dom/audiochannel/AudioChannelService.cpp +++ b/dom/audiochannel/AudioChannelService.cpp @@ -70,7 +70,7 @@ AudioChannelService::GetAudioChannelService() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return AudioChannelServiceChild::GetAudioChannelService(); } @@ -84,7 +84,7 @@ AudioChannelService::GetOrCreateAudioChannelService() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return AudioChannelServiceChild::GetOrCreateAudioChannelService(); } @@ -104,7 +104,7 @@ AudioChannelService::GetOrCreateAudioChannelService() void AudioChannelService::Shutdown() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return AudioChannelServiceChild::Shutdown(); } @@ -122,7 +122,7 @@ AudioChannelService::AudioChannelService() , mDisabled(false) , mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { obs->AddObserver(this, "ipc:content-shutdown", false); @@ -180,7 +180,7 @@ AudioChannelService::RegisterType(AudioChannel aChannel, uint64_t aChildID, AudioChannelInternalType type = GetInternalType(aChannel, true); mChannelCounters[type].AppendElement(aChildID); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // We must keep the childIds in order to decide which app is allowed to play // with then telephony channel. @@ -272,7 +272,7 @@ AudioChannelService::UnregisterType(AudioChannel aChannel, // There are two reasons to defer the decrease of telephony channel. // 1. User can have time to remove device from his ear before music resuming. // 2. Give BT SCO to be disconnected before starting to connect A2DP. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { if (aChannel == AudioChannel::Telephony) { UnregisterTelephonyChild(aChildID); @@ -306,7 +306,7 @@ AudioChannelService::UnregisterTypeInternal(AudioChannel aChannel, // In order to avoid race conditions, it's safer to notify any existing // agent any time a new one is registered. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // No hidden content channel is playable if the original playable hidden // process does not need to play audio from background anymore. if (aChannel == AudioChannel::Content && @@ -547,7 +547,7 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel, bool aVisible, uint64_t aChildID) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } @@ -590,7 +590,7 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel, void AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } diff --git a/dom/base/Crypto.cpp b/dom/base/Crypto.cpp index 238c4070c41..6df5448d13a 100644 --- a/dom/base/Crypto.cpp +++ b/dom/base/Crypto.cpp @@ -91,7 +91,7 @@ Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray, uint8_t* data = aArray.Data(); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { InfallibleTArray randomValues; // Tell the parent process to generate random values via PContent ContentChild* cc = ContentChild::GetSingleton(); diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index df7ce6915bf..1f25d7fd232 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -1481,7 +1481,7 @@ Navigator::GetFeature(const nsAString& aName, ErrorResult& aRv) #if defined(XP_LINUX) if (aName.EqualsLiteral("hardware.memory")) { // with seccomp enabled, fopen() should be in a non-sandboxed process - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { uint32_t memLevel = mozilla::hal::GetTotalSystemMemoryLevel(); if (memLevel == 0) { p->MaybeReject(NS_ERROR_NOT_AVAILABLE); @@ -2572,7 +2572,7 @@ Navigator::HasTVSupport(JSContext* aCx, JSObject* aGlobal) bool Navigator::IsE10sEnabled(JSContext* aCx, JSObject* aGlobal) { - return XRE_GetProcessType() == GeckoProcessType_Content; + return XRE_IsContentProcess(); } bool diff --git a/dom/base/nsCCUncollectableMarker.cpp b/dom/base/nsCCUncollectableMarker.cpp index b8056779ac7..f19710641ca 100644 --- a/dom/base/nsCCUncollectableMarker.cpp +++ b/dom/base/nsCCUncollectableMarker.cpp @@ -140,7 +140,7 @@ static void MarkMessageManagers() { // The global message manager only exists in the root process. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } nsCOMPtr strongGlobalMM = diff --git a/dom/base/nsContentPermissionHelper.cpp b/dom/base/nsContentPermissionHelper.cpp index 0abb0e9ebdb..80d4249263e 100644 --- a/dom/base/nsContentPermissionHelper.cpp +++ b/dom/base/nsContentPermissionHelper.cpp @@ -336,7 +336,7 @@ nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, n NS_ENSURE_STATE(aWindow && aWindow->IsCurrentInnerWindow()); // for content process - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsRefPtr req = new RemotePermissionRequest(aRequest, aWindow); diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index b479677b8a2..42313b049b9 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -10603,7 +10603,7 @@ PLDHashOperator UnlockEnumerator(imgIRequest* aKey, nsresult nsDocument::SetImageLockingState(bool aLocked) { - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && !Preferences::GetBool("image.mem.allow_locking_in_content_processes", true)) { return NS_OK; } diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index aacdaf57e4e..a31ca2989be 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -697,7 +697,7 @@ nsFocusManager::WindowRaised(nsIDOMWindow* aWindow) // If this is a parent or single process window, send the activate event. // Events for child process windows will be sent when ParentActivated // is called. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { ActivateOrDeactivate(window, true); } @@ -760,7 +760,7 @@ nsFocusManager::WindowLowered(nsIDOMWindow* aWindow) // If this is a parent or single process window, send the deactivate event. // Events for child process windows will be sent when ParentActivated // is called. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { ActivateOrDeactivate(window, false); } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 83ffb384544..6ae99a8a9cf 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -1601,12 +1601,12 @@ nsFrameLoader::ShouldUseRemoteProcess() // Don't try to launch nested children if we don't have OMTC. // They won't render! - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && !CompositorChild::ChildProcessHasCompositor()) { return false; } - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && !(PR_GetEnv("MOZ_NESTED_OOP_TABS") || Preferences::GetBool("dom.ipc.tabs.nested.enabled", false))) { return false; @@ -2650,7 +2650,7 @@ nsFrameLoader::ResetPermissionManagerStatus() { // The resetting of the permissions status can run only // in the main process. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return; } diff --git a/dom/base/nsFrameMessageManager.cpp b/dom/base/nsFrameMessageManager.cpp index b98bc376d18..25d54af894d 100644 --- a/dom/base/nsFrameMessageManager.cpp +++ b/dom/base/nsFrameMessageManager.cpp @@ -903,7 +903,7 @@ nsFrameMessageManager::Dump(const nsAString& aStr) NS_IMETHODIMP nsFrameMessageManager::PrivateNoteIntentionalCrash() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mozilla::NoteIntentionalCrash("tab"); return NS_OK; } else { @@ -1577,7 +1577,7 @@ MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb, { nsresult rv; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr globalmm = do_GetService("@mozilla.org/globalmessagemanager;1"); if (globalmm) { @@ -1613,7 +1613,7 @@ MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb, nsresult NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult) { - NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default, + NS_ENSURE_TRUE(XRE_IsParentProcess(), NS_ERROR_NOT_AVAILABLE); nsRefPtr mm = new nsFrameMessageManager(nullptr, nullptr, @@ -2151,7 +2151,7 @@ NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult) "Re-creating sChildProcessManager"); MessageManagerCallback* cb; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { cb = new SameChildProcessMessageManagerCallback(); } else { cb = new ChildProcessMessageManagerCallback(); diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 20c7275c15f..389c009950a 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -8987,7 +8987,7 @@ nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument, (aUrl, aArgument, aOptions, aError), aError, nullptr); - if (!IsShowModalDialogEnabled() || XRE_GetProcessType() == GeckoProcessType_Content) { + if (!IsShowModalDialogEnabled() || XRE_IsContentProcess()) { aError.Throw(NS_ERROR_NOT_AVAILABLE); return nullptr; } @@ -10772,7 +10772,7 @@ nsGlobalWindow::ShowSlowScriptDialog() unsigned lineno; bool hasFrame = JS::DescribeScriptedCaller(cx, &filename, &lineno); - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && ProcessHangMonitor::Get()) { ProcessHangMonitor::SlowScriptAction action; nsRefPtr monitor = ProcessHangMonitor::Get(); diff --git a/dom/base/nsObjectLoadingContent.cpp b/dom/base/nsObjectLoadingContent.cpp index 5124a51e0f3..65f069be55a 100644 --- a/dom/base/nsObjectLoadingContent.cpp +++ b/dom/base/nsObjectLoadingContent.cpp @@ -3199,7 +3199,7 @@ nsObjectLoadingContent::ShouldPlay(FallbackType &aReason, bool aIgnoreCurrentTyp sPrefsInitialized = true; } - if (XRE_GetProcessType() == GeckoProcessType_Default && + if (XRE_IsParentProcess() && BrowserTabsRemoteAutostart()) { // Plugins running OOP from the chrome process along with plugins running // OOP from the content process will hang. Let's prevent that situation. diff --git a/dom/base/nsWindowMemoryReporter.cpp b/dom/base/nsWindowMemoryReporter.cpp index 35b7fc35e0e..250958a3ca8 100644 --- a/dom/base/nsWindowMemoryReporter.cpp +++ b/dom/base/nsWindowMemoryReporter.cpp @@ -534,7 +534,7 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb, // Collect window memory usage. nsWindowSizes windowTotalSizes(nullptr); nsCOMPtr addonManager; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Only try to access the service from the main process. addonManager = do_GetService("@mozilla.org/addons/integration;1"); } diff --git a/dom/base/nsXMLHttpRequest.cpp b/dom/base/nsXMLHttpRequest.cpp index c9b3cd52bd7..755dc3bcfcb 100644 --- a/dom/base/nsXMLHttpRequest.cpp +++ b/dom/base/nsXMLHttpRequest.cpp @@ -2946,7 +2946,7 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable& aBody) if (scheme.LowerCaseEqualsLiteral("app") || scheme.LowerCaseEqualsLiteral("jar")) { mIsMappedArrayBuffer = true; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { nsCOMPtr jarChannel = do_QueryInterface(mChannel); // For memory mapping from child process, we need to get file // descriptor of the JAR file opened remotely on the parent proess. diff --git a/dom/bluetooth/BluetoothUtils.cpp b/dom/bluetooth/BluetoothUtils.cpp index ddbe635f1c3..f28f8cdfa7f 100644 --- a/dom/bluetooth/BluetoothUtils.cpp +++ b/dom/bluetooth/BluetoothUtils.cpp @@ -333,10 +333,4 @@ DispatchStatusChangedEvent(const nsAString& aType, #endif } -bool -IsMainProcess() -{ - return XRE_GetProcessType() == GeckoProcessType_Default; -} - END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/BluetoothUtils.h b/dom/bluetooth/BluetoothUtils.h index a8a05ea1046..4f086682646 100644 --- a/dom/bluetooth/BluetoothUtils.h +++ b/dom/bluetooth/BluetoothUtils.h @@ -157,14 +157,6 @@ DispatchStatusChangedEvent(const nsAString& aType, const nsAString& aDeviceAddress, bool aStatus); -/** - * Check whether the caller runs at B2G process. - * - * @return true if the caller runs at B2G process, false otherwise. - */ -bool -IsMainProcess(); - END_BLUETOOTH_NAMESPACE #endif diff --git a/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp b/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp index 337d98c3610..cd3a95d5950 100644 --- a/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp +++ b/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp @@ -784,7 +784,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, return nullptr; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // In-process transfer bs->SendFile(aDeviceAddress, &aBlob, results); } else { diff --git a/dom/bluetooth/bluetooth1/BluetoothService.cpp b/dom/bluetooth/bluetooth1/BluetoothService.cpp index 008f16bf70e..616d750c123 100644 --- a/dom/bluetooth/bluetooth1/BluetoothService.cpp +++ b/dom/bluetooth/bluetooth1/BluetoothService.cpp @@ -98,12 +98,6 @@ StaticRefPtr sBluetoothService; bool sInShutdown = false; bool sToggleInProgress = false; -bool -IsMainProcess() -{ - return XRE_GetProcessType() == GeckoProcessType_Default; -} - void ShutdownTimeExceeded(nsITimer* aTimer, void* aClosure) { @@ -220,7 +214,7 @@ BluetoothService* BluetoothService::Create() { #if defined(MOZ_B2G_BT) - if (!IsMainProcess()) { + if (!XRE_IsParentProcess()) { return BluetoothServiceChildProcess::Create(); } @@ -254,7 +248,7 @@ BluetoothService::Init() } // Only the main process should observe bluetooth settings changes. - if (IsMainProcess() && + if (XRE_IsParentProcess() && NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false))) { BT_WARNING("Failed to add settings change observer!"); return false; diff --git a/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp b/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp index e637615a91a..b0666e0f0d2 100644 --- a/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp +++ b/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp @@ -1298,7 +1298,7 @@ BluetoothAdapter::SendFile(const nsAString& aDeviceAddress, return nullptr; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // In-process transfer bs->SendFile(aDeviceAddress, &aBlob, results); } else { diff --git a/dom/bluetooth/bluetooth2/BluetoothService.cpp b/dom/bluetooth/bluetooth2/BluetoothService.cpp index 32316e9e8c2..8db2d8d871d 100644 --- a/dom/bluetooth/bluetooth2/BluetoothService.cpp +++ b/dom/bluetooth/bluetooth2/BluetoothService.cpp @@ -193,7 +193,7 @@ BluetoothService* BluetoothService::Create() { #if defined(MOZ_B2G_BT) - if (!IsMainProcess()) { + if (!XRE_IsParentProcess()) { return BluetoothServiceChildProcess::Create(); } @@ -227,7 +227,7 @@ BluetoothService::Init() } // Only the main process should observe bluetooth settings changes. - if (IsMainProcess() && + if (XRE_IsParentProcess() && NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false))) { BT_WARNING("Failed to add settings change observer!"); return false; @@ -269,7 +269,7 @@ BluetoothService::RegisterBluetoothSignalHandler( // Distribute pending pairing requests when pairing listener has been added // to signal observer table. - if (IsMainProcess() && + if (XRE_IsParentProcess() && !mPendingPairReqSignals.IsEmpty() && aNodeName.EqualsLiteral(KEY_PAIRING_LISTENER)) { for (uint32_t i = 0; i < mPendingPairReqSignals.Length(); ++i) { diff --git a/dom/bluetooth/bluez/BluetoothHfpManager.cpp b/dom/bluetooth/bluez/BluetoothHfpManager.cpp index 76f25d1eddf..09798bad305 100644 --- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp @@ -443,7 +443,7 @@ bool BluetoothHfpManager::Init() { // The function must run at b2g process since it would access SettingsService. - MOZ_ASSERT(IsMainProcess()); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr obs = services::GetObserverService(); diff --git a/dom/cellbroadcast/CellBroadcast.cpp b/dom/cellbroadcast/CellBroadcast.cpp index c6b5bf4a1cb..c6a2dbe7e1c 100644 --- a/dom/cellbroadcast/CellBroadcast.cpp +++ b/dom/cellbroadcast/CellBroadcast.cpp @@ -152,7 +152,7 @@ NS_CreateCellBroadcastService() { nsCOMPtr service; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { service = new mozilla::dom::cellbroadcast::CellBroadcastIPCService(); #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) } else { diff --git a/dom/datastore/DataStoreService.cpp b/dom/datastore/DataStoreService.cpp index 3bc3f69428b..e675d9664ed 100644 --- a/dom/datastore/DataStoreService.cpp +++ b/dom/datastore/DataStoreService.cpp @@ -51,8 +51,8 @@ #include "nsXULAppAPI.h" #define ASSERT_PARENT_PROCESS() \ - AssertIsInMainProcess(); \ - if (NS_WARN_IF(!IsMainProcess())) { \ + MOZ_ASSERT(XRE_IsParentProcess()); \ + if (NS_WARN_IF(!XRE_IsParentProcess())) { \ return NS_ERROR_FAILURE; \ } @@ -125,20 +125,6 @@ static uint64_t gCounterID = 0; typedef nsClassHashtable HashApp; -bool -IsMainProcess() -{ - static const bool isMainProcess = - XRE_GetProcessType() == GeckoProcessType_Default; - return isMainProcess; -} - -void -AssertIsInMainProcess() -{ - MOZ_ASSERT(IsMainProcess()); -} - void RejectPromise(nsPIDOMWindow* aWindow, Promise* aPromise, nsresult aRv) { @@ -161,8 +147,7 @@ void DeleteDatabase(const nsAString& aName, const nsAString& aManifestURL) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsRefPtr db = new DataStoreDB(aManifestURL, aName); db->Delete(); @@ -174,8 +159,7 @@ DeleteDataStoresAppEnumerator( nsAutoPtr& aInfo, void* aUserData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); auto* appId = static_cast(aUserData); if (*appId != aAppId) { @@ -191,8 +175,7 @@ DeleteDataStoresEnumerator(const nsAString& aName, nsAutoPtr& aApps, void* aUserData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); aApps->Enumerate(DeleteDataStoresAppEnumerator, aUserData); return aApps->Count() ? PL_DHASH_NEXT : PL_DHASH_REMOVE; @@ -215,8 +198,7 @@ ResetPermission(uint32_t aAppId, const nsAString& aOriginURL, const nsAString& aPermission, bool aReadOnly) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsresult rv; nsCOMPtr ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv)); @@ -347,8 +329,7 @@ GetDataStoreInfosEnumerator(const uint32_t& aAppId, DataStoreInfo* aInfo, void* aUserData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); auto* data = static_cast(aUserData); if (aAppId == data->mAppId) { @@ -384,8 +365,7 @@ GetAppManifestURLsEnumerator(const uint32_t& aAppId, DataStoreInfo* aInfo, void* aUserData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); auto* manifestURLs = static_cast(aUserData); nsCOMPtr manifestURL(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID)); @@ -417,8 +397,7 @@ AddPermissionsEnumerator(const uint32_t& aAppId, DataStoreInfo* aInfo, void* userData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); auto* data = static_cast(userData); @@ -457,8 +436,7 @@ AddAccessPermissionsEnumerator(const uint32_t& aAppId, DataStoreInfo* aInfo, void* userData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); auto* data = static_cast(userData); @@ -517,15 +495,13 @@ public: , mName(aName) , mManifestURL(aManifestURL) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); } void Run(const nsAString& aRevisionId) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsRefPtr service = DataStoreService::Get(); MOZ_ASSERT(service); @@ -553,15 +529,13 @@ public: , mName(aName) , mManifestURL(aManifestURL) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); } void Run(DataStoreDB* aDb, RunStatus aStatus) override { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); MOZ_ASSERT(aDb); if (aStatus == Error) { @@ -642,8 +616,7 @@ public: NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) override { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsRefPtr request; request.swap(mRequest); @@ -830,7 +803,7 @@ DataStoreService::Shutdown() MOZ_ASSERT(NS_IsMainThread()); if (gDataStoreService) { - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { obs->RemoveObserver(gDataStoreService, "webapps-clear-data"); @@ -863,7 +836,7 @@ DataStoreService::~DataStoreService() nsresult DataStoreService::Init() { - if (!IsMainProcess()) { + if (!XRE_IsParentProcess()) { return NS_OK; } @@ -973,7 +946,7 @@ DataStoreService::GetDataStores(nsIDOMWindow* aWindow, // If this request comes from the main process, we have access to the // window, so we can skip the ipc communication. - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { uint32_t appId; nsresult rv = principal->GetAppId(&appId); if (NS_FAILED(rv)) { @@ -1132,8 +1105,7 @@ DataStoreService::GetDataStoreInfos(const nsAString& aName, nsIPrincipal* aPrincipal, nsTArray& aStores) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsCOMPtr appsService = do_GetService("@mozilla.org/AppsService;1"); @@ -1242,8 +1214,7 @@ DataStoreService::CheckPermission(nsIPrincipal* aPrincipal, void DataStoreService::DeleteDataStores(uint32_t aAppId) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); mStores.Enumerate(DeleteDataStoresEnumerator, &aAppId); mAccessStores.Enumerate(DeleteDataStoresEnumerator, &aAppId); @@ -1254,8 +1225,7 @@ DataStoreService::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); if (strcmp(aTopic, "webapps-clear-data")) { return NS_OK; @@ -1294,8 +1264,7 @@ DataStoreService::AddPermissions(uint32_t aAppId, const nsAString& aManifestURL, bool aReadOnly) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); // This is the permission name. nsString permission; @@ -1327,8 +1296,7 @@ DataStoreService::AddAccessPermissions(uint32_t aAppId, const nsAString& aName, const nsAString& aManifestURL, bool aReadOnly) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); // When an app wants to have access to a DataStore, the permissions must be // set. @@ -1349,8 +1317,7 @@ DataStoreService::CreateFirstRevisionId(uint32_t aAppId, const nsAString& aName, const nsAString& aManifestURL) { - AssertIsInMainProcess(); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); nsRefPtr db = new DataStoreDB(aManifestURL, aName); @@ -1380,7 +1347,7 @@ DataStoreService::EnableDataStore(uint32_t aAppId, const nsAString& aName, } // Notify the child processes. - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { nsTArray children; ContentParent::GetAll(children); for (uint32_t i = 0; i < children.Length(); i++) { @@ -1447,8 +1414,7 @@ DataStoreService::GetDataStoresFromIPC(const nsAString& aName, nsIPrincipal* aPrincipal, nsTArray* aValue) { - MOZ_ASSERT(IsMainProcess()); - MOZ_ASSERT(NS_IsMainThread()); + MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread()); uint32_t appId; nsresult rv = aPrincipal->GetAppId(&appId); diff --git a/dom/devicestorage/nsDeviceStorage.cpp b/dom/devicestorage/nsDeviceStorage.cpp index 1ba45430d1e..3601344f0bd 100644 --- a/dom/devicestorage/nsDeviceStorage.cpp +++ b/dom/devicestorage/nsDeviceStorage.cpp @@ -561,7 +561,7 @@ FileUpdateDispatcher::Observe(nsISupports* aSubject, return NS_OK; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Child process. Forward the notification to the parent. ContentChild::GetSingleton() ->SendFilePathUpdateNotify(dsf->mStorageType, @@ -692,7 +692,7 @@ DeviceStorageFile::Dump(const char* label) path = NS_LITERAL_STRING("(null)"); } const char* ptStr; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { ptStr = "parent"; } else { ptStr = "child"; @@ -814,7 +814,7 @@ OverrideRootDir::Init() } if (sDirs->overrideRootDir) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Only the parent process can create directories. In testing, because // the preference is updated after startup, its entirely possible that // the preference updated notification will be received by a child @@ -936,7 +936,7 @@ InitDirs() } #endif - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { NS_GetSpecialDirectory("UAppData", getter_AddRefs(sDirs->crashes)); if (sDirs->crashes) { sDirs->crashes->Append(NS_LITERAL_STRING("Crash Reports")); @@ -2058,7 +2058,7 @@ ContinueCursorEvent::~ContinueCursorEvent() {} void ContinueCursorEvent::Continue() { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { DebugOnly rv = NS_DispatchToMainThread(this); MOZ_ASSERT(NS_SUCCEEDED(rv)); return; @@ -2244,7 +2244,7 @@ nsDOMDeviceStorageCursor::Allow(JS::HandleValue aChoices) return NS_DispatchToMainThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(this, mFile); DeviceStorageEnumerationParams params(mFile->mStorageType, @@ -3013,7 +3013,7 @@ public: return NS_DispatchToCurrentThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { DeviceStorageCreateFdParams params; params.type() = mFile->mStorageType; @@ -3053,7 +3053,7 @@ public: return NS_DispatchToCurrentThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { BlobChild* actor = ContentChild::GetSingleton()->GetOrCreateActorForBlob( static_cast(mBlob.get())); @@ -3099,7 +3099,7 @@ public: return NS_DispatchToCurrentThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { BlobChild* actor = ContentChild::GetSingleton()->GetOrCreateActorForBlob( static_cast(mBlob.get())); @@ -3145,7 +3145,7 @@ public: return NS_DispatchToCurrentThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageGetParams params(mFile->mStorageType, @@ -3179,7 +3179,7 @@ public: return NS_DispatchToCurrentThread(r); } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageDeleteParams params(mFile->mStorageType, @@ -3195,7 +3195,7 @@ public: case DEVICE_STORAGE_REQUEST_FREE_SPACE: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageFreeSpaceParams params(mFile->mStorageType, @@ -3210,7 +3210,7 @@ public: case DEVICE_STORAGE_REQUEST_USED_SPACE: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageUsedSpaceParams params(mFile->mStorageType, @@ -3231,7 +3231,7 @@ public: case DEVICE_STORAGE_REQUEST_AVAILABLE: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageAvailableParams params(mFile->mStorageType, @@ -3246,7 +3246,7 @@ public: case DEVICE_STORAGE_REQUEST_STATUS: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageStatusParams params(mFile->mStorageType, @@ -3267,7 +3267,7 @@ public: case DEVICE_STORAGE_REQUEST_FORMAT: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageFormatParams params(mFile->mStorageType, @@ -3282,7 +3282,7 @@ public: case DEVICE_STORAGE_REQUEST_MOUNT: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageMountParams params(mFile->mStorageType, @@ -3297,7 +3297,7 @@ public: case DEVICE_STORAGE_REQUEST_UNMOUNT: { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { PDeviceStorageRequestChild* child = new DeviceStorageRequestChild(mRequest, mFile); DeviceStorageUnmountParams params(mFile->mStorageType, diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 97ce67206d4..09aea74a477 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -597,7 +597,7 @@ EventStateManager::PreHandleEvent(nsPresContext* aPresContext, // window edge) wont update the cursor if the cached value and the current // cursor match. So when the mouse exits a remote frame, clear the cached // widget cursor so a proper update will occur when the mouse re-enters. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ClearCachedWidgetCursor(mCurrentTarget); } diff --git a/dom/events/IMEStateManager.cpp b/dom/events/IMEStateManager.cpp index 430827ef81f..8cfc5f431d3 100644 --- a/dom/events/IMEStateManager.cpp +++ b/dom/events/IMEStateManager.cpp @@ -928,7 +928,7 @@ IMEStateManager::SetIMEState(const IMEState& aState, // XXX I think that we should use nsContentUtils::IsCallerChrome() instead // of the process type. if (aAction.mCause == InputContextAction::CAUSE_UNKNOWN && - XRE_GetProcessType() != GeckoProcessType_Content) { + !XRE_IsContentProcess()) { aAction.mCause = InputContextAction::CAUSE_UNKNOWN_CHROME; } diff --git a/dom/filehandle/FileStreamWrappers.cpp b/dom/filehandle/FileStreamWrappers.cpp index 2b42b076a77..cb01eeef636 100644 --- a/dom/filehandle/FileStreamWrappers.cpp +++ b/dom/filehandle/FileStreamWrappers.cpp @@ -242,7 +242,7 @@ void FileInputStreamWrapper::Serialize(InputStreamParams& aParams, FileDescriptorArray& /* aFDs */) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr thisStream = do_QueryObject(this); diff --git a/dom/filesystem/CreateDirectoryTask.cpp b/dom/filesystem/CreateDirectoryTask.cpp index 9891ed68f47..de3733ea1e4 100644 --- a/dom/filesystem/CreateDirectoryTask.cpp +++ b/dom/filesystem/CreateDirectoryTask.cpp @@ -39,7 +39,7 @@ CreateDirectoryTask::CreateDirectoryTask( FileSystemRequestParent* aParent) : FileSystemTaskBase(aFileSystem, aParam, aParent) { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem); @@ -84,7 +84,7 @@ CreateDirectoryTask::SetSuccessRequestResult(const FileSystemResponseValue& aVal nsresult CreateDirectoryTask::Work() { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!"); diff --git a/dom/filesystem/CreateFileTask.cpp b/dom/filesystem/CreateFileTask.cpp index 7009fba6fad..ece56f2f9d0 100644 --- a/dom/filesystem/CreateFileTask.cpp +++ b/dom/filesystem/CreateFileTask.cpp @@ -39,7 +39,7 @@ CreateFileTask::CreateFileTask(FileSystemBase* aFileSystem, MOZ_ASSERT(aFileSystem); GetOutputBufferSize(); if (aBlobData) { - if (FileSystemUtils::IsParentProcess()) { + if (XRE_IsParentProcess()) { aBlobData->GetInternalStream(getter_AddRefs(mBlobStream), aRv); NS_WARN_IF(aRv.Failed()); } else { @@ -61,7 +61,7 @@ CreateFileTask::CreateFileTask(FileSystemBase* aFileSystem, : FileSystemTaskBase(aFileSystem, aParam, aParent) , mReplace(false) { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem); @@ -168,7 +168,7 @@ CreateFileTask::Work() nsCOMPtr mStream; }; - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!"); @@ -324,7 +324,7 @@ CreateFileTask::GetPermissionAccessType(nsCString& aAccess) const void CreateFileTask::GetOutputBufferSize() const { - if (sOutputBufferSize || !FileSystemUtils::IsParentProcess()) { + if (sOutputBufferSize || !XRE_IsParentProcess()) { return; } sOutputBufferSize = diff --git a/dom/filesystem/DeviceStorageFileSystem.cpp b/dom/filesystem/DeviceStorageFileSystem.cpp index 3f1da032afa..6e254d4d1f0 100644 --- a/dom/filesystem/DeviceStorageFileSystem.cpp +++ b/dom/filesystem/DeviceStorageFileSystem.cpp @@ -47,7 +47,7 @@ DeviceStorageFileSystem::DeviceStorageFileSystem( // Get the local path of the file system root. // Since the child process is not allowed to access the file system, we only // do this from the parent process. - if (!FileSystemUtils::IsParentProcess()) { + if (!XRE_IsParentProcess()) { return; } nsCOMPtr rootFile; @@ -100,7 +100,7 @@ DeviceStorageFileSystem::GetWindow() const already_AddRefed DeviceStorageFileSystem::GetLocalFile(const nsAString& aRealPath) const { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Should be on parent process!"); nsAutoString localPath; FileSystemUtils::NormalizedPathToLocalPath(aRealPath, localPath); @@ -116,7 +116,7 @@ DeviceStorageFileSystem::GetLocalFile(const nsAString& aRealPath) const bool DeviceStorageFileSystem::GetRealPath(BlobImpl* aFile, nsAString& aRealPath) const { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Should be on parent process!"); MOZ_ASSERT(aFile, "aFile Should not be null."); @@ -141,7 +141,7 @@ DeviceStorageFileSystem::GetRootName() const bool DeviceStorageFileSystem::IsSafeFile(nsIFile* aFile) const { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Should be on parent process!"); MOZ_ASSERT(aFile); diff --git a/dom/filesystem/FileSystemTaskBase.cpp b/dom/filesystem/FileSystemTaskBase.cpp index 97b19c3478c..8f52f6b2396 100644 --- a/dom/filesystem/FileSystemTaskBase.cpp +++ b/dom/filesystem/FileSystemTaskBase.cpp @@ -35,7 +35,7 @@ FileSystemTaskBase::FileSystemTaskBase(FileSystemBase* aFileSystem, , mFileSystem(aFileSystem) , mRequestParent(aParent) { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem, "aFileSystem should not be null."); @@ -61,7 +61,7 @@ FileSystemTaskBase::Start() return; } - if (FileSystemUtils::IsParentProcess()) { + if (XRE_IsParentProcess()) { // Run in parent process. // Start worker thread. nsCOMPtr target @@ -121,7 +121,7 @@ FileSystemTaskBase::HandleResult() FileSystemResponseValue FileSystemTaskBase::GetRequestResult() const { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); if (HasError()) { @@ -134,7 +134,7 @@ FileSystemTaskBase::GetRequestResult() const void FileSystemTaskBase::SetRequestResult(const FileSystemResponseValue& aValue) { - MOZ_ASSERT(!FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(!XRE_IsParentProcess(), "Only call from child process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); if (aValue.type() == FileSystemResponseValue::TFileSystemErrorResponse) { @@ -156,7 +156,7 @@ FileSystemTaskBase::Recv__delete__(const FileSystemResponseValue& aValue) BlobParent* FileSystemTaskBase::GetBlobParent(BlobImpl* aFile) const { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFile); diff --git a/dom/filesystem/FileSystemUtils.cpp b/dom/filesystem/FileSystemUtils.cpp index 6161cce7cef..cf175bcaa24 100644 --- a/dom/filesystem/FileSystemUtils.cpp +++ b/dom/filesystem/FileSystemUtils.cpp @@ -65,12 +65,5 @@ FileSystemUtils::IsDescendantPath(const nsAString& aPath, return true; } -// static -bool -FileSystemUtils::IsParentProcess() -{ - return XRE_GetProcessType() == GeckoProcessType_Default; -} - } // namespace dom } // namespace mozilla diff --git a/dom/filesystem/FileSystemUtils.h b/dom/filesystem/FileSystemUtils.h index 1203dfbb2df..abf30c3cf5f 100644 --- a/dom/filesystem/FileSystemUtils.h +++ b/dom/filesystem/FileSystemUtils.h @@ -41,9 +41,6 @@ public: static bool IsDescendantPath(const nsAString& aPath, const nsAString& aDescendantPath); - static bool - IsParentProcess(); - static const char16_t kSeparatorChar = char16_t('/'); }; diff --git a/dom/filesystem/GetFileOrDirectoryTask.cpp b/dom/filesystem/GetFileOrDirectoryTask.cpp index 26150bc698c..fcf96e9901e 100644 --- a/dom/filesystem/GetFileOrDirectoryTask.cpp +++ b/dom/filesystem/GetFileOrDirectoryTask.cpp @@ -47,7 +47,7 @@ GetFileOrDirectoryTask::GetFileOrDirectoryTask( : FileSystemTaskBase(aFileSystem, aParam, aParent) , mIsDirectory(false) { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem); @@ -119,7 +119,7 @@ GetFileOrDirectoryTask::SetSuccessRequestResult(const FileSystemResponseValue& a nsresult GetFileOrDirectoryTask::Work() { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!"); diff --git a/dom/filesystem/RemoveTask.cpp b/dom/filesystem/RemoveTask.cpp index 4ab6ebe89df..78a66ce2b58 100644 --- a/dom/filesystem/RemoveTask.cpp +++ b/dom/filesystem/RemoveTask.cpp @@ -49,7 +49,7 @@ RemoveTask::RemoveTask(FileSystemBase* aFileSystem, , mRecursive(false) , mReturnValue(false) { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!"); MOZ_ASSERT(aFileSystem); @@ -123,7 +123,7 @@ RemoveTask::SetSuccessRequestResult(const FileSystemResponseValue& aValue) nsresult RemoveTask::Work() { - MOZ_ASSERT(FileSystemUtils::IsParentProcess(), + MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!"); diff --git a/dom/fmradio/FMRadioService.cpp b/dom/fmradio/FMRadioService.cpp index f161047b926..072c5304844 100644 --- a/dom/fmradio/FMRadioService.cpp +++ b/dom/fmradio/FMRadioService.cpp @@ -42,7 +42,7 @@ BEGIN_FMRADIO_NAMESPACE IFMRadioService* IFMRadioService::Singleton() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return FMRadioChild::Singleton(); } else { return FMRadioService::Singleton(); @@ -1243,7 +1243,7 @@ FMRadioService::UpdateFrequency() FMRadioService* FMRadioService::Singleton() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); if (!sFMRadioService) { diff --git a/dom/fmradio/ipc/FMRadioChild.cpp b/dom/fmradio/ipc/FMRadioChild.cpp index 240c2e7e82c..729504cd124 100644 --- a/dom/fmradio/ipc/FMRadioChild.cpp +++ b/dom/fmradio/ipc/FMRadioChild.cpp @@ -338,7 +338,7 @@ FMRadioChild::EnableAudio(bool aAudioEnabled) FMRadioChild* FMRadioChild::Singleton() { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); + MOZ_ASSERT(!XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); if (!sFMRadioChild) { diff --git a/dom/gamepad/GamepadFunctions.cpp b/dom/gamepad/GamepadFunctions.cpp index 2a643cf6195..c2e6289207c 100644 --- a/dom/gamepad/GamepadFunctions.cpp +++ b/dom/gamepad/GamepadFunctions.cpp @@ -24,7 +24,7 @@ void NotifyGamepadChange(const T& aInfo) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); GamepadChangeEvent e(aInfo); nsTArray t; ContentParent::GetAll(t); @@ -44,7 +44,7 @@ AddGamepad(const char* aID, uint32_t aNumButtons, uint32_t aNumAxes) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); int index = gGamepadIndex; gGamepadIndex++; @@ -59,7 +59,7 @@ void RemoveGamepad(uint32_t aIndex) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); GamepadRemoved a(aIndex); NotifyGamepadChange(a); } @@ -69,7 +69,7 @@ NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed, double aValue) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); GamepadButtonInformation a(aIndex, aButton, aPressed, aValue); NotifyGamepadChange(a); } @@ -79,7 +79,7 @@ NewButtonEvent(uint32_t aIndex, uint32_t aButton, bool aPressed) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // When only a digital button is available the value will be synthesized. NewButtonEvent(aIndex, aButton, aPressed, aPressed ? 1.0L : 0.0L); } @@ -89,7 +89,7 @@ NewAxisMoveEvent(uint32_t aIndex, uint32_t aAxis, double aValue) { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); GamepadAxisInformation a(aIndex, aAxis, aValue); NotifyGamepadChange(a); } @@ -98,7 +98,7 @@ void ResetGamepadIndexes() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); gGamepadIndex = 0; } diff --git a/dom/gamepad/GamepadMonitoring.cpp b/dom/gamepad/GamepadMonitoring.cpp index 05667dcd81c..795a9d0916b 100644 --- a/dom/gamepad/GamepadMonitoring.cpp +++ b/dom/gamepad/GamepadMonitoring.cpp @@ -17,7 +17,7 @@ void MaybeStopGamepadMonitoring() { MOZ_ASSERT(NS_IsMainThread()); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsTArray t; ContentParent::GetAll(t); for(uint32_t i = 0; i < t.Length(); ++i) { diff --git a/dom/gamepad/GamepadService.cpp b/dom/gamepad/GamepadService.cpp index b6fee91e6ae..f42362c458f 100644 --- a/dom/gamepad/GamepadService.cpp +++ b/dom/gamepad/GamepadService.cpp @@ -85,7 +85,7 @@ GamepadService::BeginShutdown() mTimer->Cancel(); } if (mStarted) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { MaybeStopGamepadMonitoring(); } else { ContentChild::GetSingleton()->SendGamepadListenerRemoved(); @@ -115,7 +115,7 @@ GamepadService::AddListener(nsGlobalWindow* aWindow) } if (!mStarted && mEnabled) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { StartGamepadMonitoring(); } else { ContentChild::GetSingleton()->SendGamepadListenerAdded(); @@ -500,7 +500,7 @@ GamepadService::TimeoutHandler(nsITimer* aTimer, void* aClosure) } if (self->mListeners.Length() == 0) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { MaybeStopGamepadMonitoring(); } else { ContentChild::GetSingleton()->SendGamepadListenerRemoved(); diff --git a/dom/geolocation/nsGeolocation.cpp b/dom/geolocation/nsGeolocation.cpp index ef3e2887890..af8c24c3cfd 100644 --- a/dom/geolocation/nsGeolocation.cpp +++ b/dom/geolocation/nsGeolocation.cpp @@ -564,7 +564,7 @@ already_AddRefed nsGeolocationRequest::AdjustedLocation(nsIDOMGeoPosition *aPosition) { nsCOMPtr pos = aPosition; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { GPSLOG("child process just copying position"); return pos.forget(); } @@ -758,7 +758,7 @@ nsresult nsGeolocationService::Init() return NS_ERROR_FAILURE; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { sGeoInitPending = false; return NS_OK; } @@ -1013,7 +1013,7 @@ nsGeolocationService::StartDevice(nsIPrincipal *aPrincipal) // inactivivity SetDisconnectTimer(); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); cpc->SendAddGeolocationListener(IPC::Principal(aPrincipal), HighAccuracyRequested()); @@ -1076,7 +1076,7 @@ nsGeolocationService::UpdateAccuracy(bool aForceHigh) { bool highRequired = aForceHigh || HighAccuracyRequested(); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); if (cpc->IsAlive()) { cpc->SendSetGeolocationHigherAccuracy(highRequired); @@ -1103,7 +1103,7 @@ nsGeolocationService::StopDevice() mDisconnectTimer = nullptr; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); cpc->SendRemoveGeolocationListener(); return; // bail early diff --git a/dom/geolocation/nsGeolocationSettings.cpp b/dom/geolocation/nsGeolocationSettings.cpp index f89e8fa1c17..f8a0ac19a27 100644 --- a/dom/geolocation/nsGeolocationSettings.cpp +++ b/dom/geolocation/nsGeolocationSettings.cpp @@ -49,7 +49,7 @@ already_AddRefed nsGeolocationSettings::GetGeolocationSettings() { // this singleton is only needed in the parent process... - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return nullptr; } diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 5cf728d282a..c641a5e82f7 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -746,7 +746,7 @@ UploadLastDir::FetchDirectoryAndDisplayPicker(nsIDocument* aDoc, new UploadLastDir::ContentPrefCallback(aFilePicker, aFpCallback); #ifdef MOZ_B2G - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR); return NS_OK; } @@ -777,7 +777,7 @@ UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir) } #ifdef MOZ_B2G - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return NS_OK; } #endif @@ -2105,7 +2105,7 @@ HTMLInputElement::MozSetFileArray(const Sequence>& aFiles) void HTMLInputElement::MozSetFileNameArray(const Sequence< nsString >& aFileNames, ErrorResult& aRv) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); return; } diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp index 410b99e168a..650be5d6435 100644 --- a/dom/html/nsGenericHTMLFrameElement.cpp +++ b/dom/html/nsGenericHTMLFrameElement.cpp @@ -596,7 +596,7 @@ nsGenericHTMLFrameElement::GetAppManifestURL(nsAString& aOut) // Only allow content process to embed an app when nested content // process is enabled. - if (XRE_GetProcessType() != GeckoProcessType_Default && + if (!XRE_IsParentProcess() && !(GetBoolAttr(nsGkAtoms::Remote) && NestedEnabled())){ NS_WARNING("Can't embed-apps. Embed-apps is restricted to in-proc apps " "or content processes with nested pref enabled, see bug 1097479"); diff --git a/dom/icc/IccManager.cpp b/dom/icc/IccManager.cpp index e5cf28d712a..9696ea26709 100644 --- a/dom/icc/IccManager.cpp +++ b/dom/icc/IccManager.cpp @@ -143,7 +143,7 @@ NS_CreateIccService() { nsCOMPtr service; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { service = new mozilla::dom::icc::IccIPCService(); #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) } else { diff --git a/dom/indexedDB/ActorsChild.cpp b/dom/indexedDB/ActorsChild.cpp index a62b24314a2..ce485f11bfa 100644 --- a/dom/indexedDB/ActorsChild.cpp +++ b/dom/indexedDB/ActorsChild.cpp @@ -818,7 +818,7 @@ public: : PermissionRequestBase(aElement, aPrincipal) , mChallenge(aChallenge) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aChallenge); } @@ -844,7 +844,7 @@ public: WorkerPermissionChallenge* aChallenge) : mChallenge(aChallenge) { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); + MOZ_ASSERT(!XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(aChallenge); } @@ -950,7 +950,7 @@ private: return true; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr ownerElement = do_QueryInterface(window->GetChromeEventHandler()); if (NS_WARN_IF(!ownerElement)) { @@ -1399,7 +1399,7 @@ BackgroundFactoryRequestChild::RecvPermissionChallenge( return false; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr window = mFactory->GetParentObject(); MOZ_ASSERT(window); diff --git a/dom/indexedDB/FileSnapshot.cpp b/dom/indexedDB/FileSnapshot.cpp index 765b3ba62e7..4c09c904154 100644 --- a/dom/indexedDB/FileSnapshot.cpp +++ b/dom/indexedDB/FileSnapshot.cpp @@ -82,7 +82,7 @@ BlobImplSnapshot::~BlobImplSnapshot() void BlobImplSnapshot::AssertSanity() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); } diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index d267523794a..904e84b501a 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -252,7 +252,7 @@ IndexedDatabaseManager::GetOrCreate() } if (!gDBManager) { - sIsMainProcess = XRE_GetProcessType() == GeckoProcessType_Default; + sIsMainProcess = XRE_IsParentProcess(); if (!sLoggingModule) { sLoggingModule = PR_NewLogModule("IndexedDB"); @@ -598,7 +598,7 @@ IndexedDatabaseManager::IsMainProcess() { NS_ASSERTION(gDBManager, "IsMainProcess() called before indexedDB has been initialized!"); - NS_ASSERTION((XRE_GetProcessType() == GeckoProcessType_Default) == + NS_ASSERTION((XRE_IsParentProcess()) == sIsMainProcess, "XRE_GetProcessType changed its tune!"); return sIsMainProcess; } diff --git a/dom/indexedDB/PermissionRequestBase.cpp b/dom/indexedDB/PermissionRequestBase.cpp index e04538680e4..8a7579d45f9 100644 --- a/dom/indexedDB/PermissionRequestBase.cpp +++ b/dom/indexedDB/PermissionRequestBase.cpp @@ -43,7 +43,7 @@ const uint32_t kPermissionDefault = nsIPermissionManager::UNKNOWN_ACTION; void AssertSanity() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); } diff --git a/dom/ipc/Blob.cpp b/dom/ipc/Blob.cpp index 804466f24ca..939cc53b6a6 100644 --- a/dom/ipc/Blob.cpp +++ b/dom/ipc/Blob.cpp @@ -3250,7 +3250,7 @@ BlobChild::AssertIsOnOwningThread() const void BlobChild::Startup(const FriendKey& /* aKey */) { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); + MOZ_ASSERT(!XRE_IsParentProcess()); CommonStartup(); } @@ -3773,7 +3773,7 @@ BlobParent::AssertIsOnOwningThread() const void BlobParent::Startup(const FriendKey& /* aKey */) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); CommonStartup(); diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index b1202ab6e3a..db1c9e157ff 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -2831,7 +2831,7 @@ uint64_t NextWindowID() { uint64_t processID = 0; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); processID = cc->GetID(); } diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index ec7cce5fdf6..8de0821bbfe 100755 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -779,7 +779,7 @@ ContentParent::StartUp() // child process sCanLaunchSubprocesses = true; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } @@ -1153,7 +1153,7 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext, } ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement); - bool isInContentProcess = (XRE_GetProcessType() != GeckoProcessType_Default); + bool isInContentProcess = !XRE_IsParentProcess(); TabId tabId; nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement); @@ -1812,7 +1812,7 @@ ContentParent::OnChannelError() void ContentParent::OnBeginSyncTransaction() { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr console(do_GetService(NS_CONSOLESERVICE_CONTRACTID)); JSContext *cx = nsContentUtils::GetCurrentJSContext(); if (!sDisableUnsafeCPOWWarnings) { @@ -4876,7 +4876,7 @@ ContentParent::AllocateTabId(const TabId& aOpenerTabId, const ContentParentId& aCpId) { TabId tabId; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { ContentProcessManager *cpm = ContentProcessManager::GetSingleton(); tabId = cpm->AllocateTabId(aOpenerTabId, aContext, aCpId); } @@ -4893,7 +4893,7 @@ ContentParent::AllocateTabId(const TabId& aOpenerTabId, ContentParent::DeallocateTabId(const TabId& aTabId, const ContentParentId& aCpId) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { ContentProcessManager::GetSingleton()->DeallocateTabId(aCpId, aTabId); } @@ -5092,7 +5092,7 @@ ContentParent::DeallocPContentPermissionRequestParent(PContentPermissionRequestP bool ContentParent::RecvGetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration* aConfig) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); return GetBrowserConfiguration(aURI, *aConfig);; } @@ -5100,7 +5100,7 @@ ContentParent::RecvGetBrowserConfiguration(const nsCString& aURI, BrowserConfigu /*static*/ bool ContentParent::GetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration& aConfig) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsRefPtr swr = ServiceWorkerRegistrar::Get(); MOZ_ASSERT(swr); diff --git a/dom/ipc/ContentProcessManager.cpp b/dom/ipc/ContentProcessManager.cpp index e69d5fb782d..51c3588c085 100644 --- a/dom/ipc/ContentProcessManager.cpp +++ b/dom/ipc/ContentProcessManager.cpp @@ -32,7 +32,7 @@ ContentProcessManager::sSingleton; /* static */ ContentProcessManager* ContentProcessManager::GetSingleton() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (!sSingleton) { sSingleton = new ContentProcessManager(); diff --git a/dom/ipc/ProcessHangMonitor.cpp b/dom/ipc/ProcessHangMonitor.cpp index 74c2e450e8d..949443b34a5 100644 --- a/dom/ipc/ProcessHangMonitor.cpp +++ b/dom/ipc/ProcessHangMonitor.cpp @@ -887,7 +887,7 @@ ProcessHangMonitor::ProcessHangMonitor() MOZ_COUNT_CTOR(ProcessHangMonitor); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsCOMPtr obs = mozilla::services::GetObserverService(); obs->AddObserver(this, "xpcom-shutdown", false); } diff --git a/dom/ipc/ProcessPriorityManager.cpp b/dom/ipc/ProcessPriorityManager.cpp index 1950b9927b8..ff2fe1a5cff 100644 --- a/dom/ipc/ProcessPriorityManager.cpp +++ b/dom/ipc/ProcessPriorityManager.cpp @@ -384,7 +384,7 @@ ProcessPriorityManagerImpl::StaticInit() } // The process priority manager is main-process only. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { sInitialized = true; return; } @@ -427,7 +427,7 @@ ProcessPriorityManagerImpl::ProcessPriorityManagerImpl() , mBackgroundLRUPool(PROCESS_PRIORITY_BACKGROUND) , mBackgroundPerceivableLRUPool(PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); RegisterWakeLockObserver(this); } @@ -660,7 +660,7 @@ ParticularProcessPriorityManager::ParticularProcessPriorityManager( , mIsActivityOpener(false) , mFrozen(aFrozen) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); LOGP("Creating ParticularProcessPriorityManager."); } @@ -826,7 +826,7 @@ ParticularProcessPriorityManager::OnRemoteBrowserFrameShown(nsISupports* aSubjec TabParent* tp = TabParent::GetFrom(fl); NS_ENSURE_TRUE_VOID(tp); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (tp->Manager() != mContentParent) { return; } @@ -850,7 +850,7 @@ ParticularProcessPriorityManager::OnTabParentDestroyed(nsISupports* aSubject) nsCOMPtr tp = do_QueryInterface(aSubject); NS_ENSURE_TRUE_VOID(tp); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (TabParent::GetFrom(tp)->Manager() != mContentParent) { return; } @@ -873,7 +873,7 @@ ParticularProcessPriorityManager::OnFrameloaderVisibleChanged(nsISupports* aSubj return; } - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (tp->Manager() != mContentParent) { return; } @@ -1213,7 +1213,7 @@ NS_IMPL_ISUPPORTS(ProcessPriorityManagerChild, ProcessPriorityManagerChild::ProcessPriorityManagerChild() { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mCachedPriority = PROCESS_PRIORITY_MASTER; } else { mCachedPriority = PROCESS_PRIORITY_UNKNOWN; @@ -1225,7 +1225,7 @@ ProcessPriorityManagerChild::Init() { // The process priority should only be changed in child processes; don't even // bother listening for changes if we're in the main process. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { nsCOMPtr os = services::GetObserverService(); NS_ENSURE_TRUE_VOID(os); os->AddObserver(this, "ipc:process-priority-changed", /* weak = */ false); diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 1603da8c2fa..c242a79d5db 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -447,7 +447,7 @@ TabParent::Destroy() } mIsDestroyed = true; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { Manager()->AsContentParent()->NotifyTabDestroying(this); } @@ -465,7 +465,7 @@ TabParent::Destroy() bool TabParent::Recv__delete__() { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { Manager()->AsContentParent()->NotifyTabDestroyed(this, mMarkedDestroying); ContentParent::DeallocateTabId(mTabId, Manager()->AsContentParent()->ChildID()); diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 7ec4e4f1908..0a9025f8d8a 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1449,7 +1449,7 @@ MediaManager::NotifyRecordingStatusChange(nsPIDOMWindow* aWindow, // Forward recording events to parent process. // The events are gathered in chrome process and used for recording indicator - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { unused << dom::ContentChild::GetSingleton()->SendRecordingDeviceEvents(aMsg, requestURL, diff --git a/dom/media/gmp/GMPService.cpp b/dom/media/gmp/GMPService.cpp index 2457623dc3b..2bf19f539f0 100644 --- a/dom/media/gmp/GMPService.cpp +++ b/dom/media/gmp/GMPService.cpp @@ -109,7 +109,7 @@ private: MOZ_ASSERT(NS_IsMainThread()); if (!sSingletonService) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsRefPtr service = new GeckoMediaPluginServiceParent(); service->Init(); diff --git a/dom/media/gmp/GMPServiceChild.cpp b/dom/media/gmp/GMPServiceChild.cpp index bd98bb93acd..cb3f5d31d23 100644 --- a/dom/media/gmp/GMPServiceChild.cpp +++ b/dom/media/gmp/GMPServiceChild.cpp @@ -33,7 +33,7 @@ namespace gmp { already_AddRefed GeckoMediaPluginServiceChild::GetSingleton() { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); + MOZ_ASSERT(!XRE_IsParentProcess()); nsRefPtr service( GeckoMediaPluginService::GetGeckoMediaPluginService()); #ifdef DEBUG diff --git a/dom/media/gmp/GMPServiceParent.cpp b/dom/media/gmp/GMPServiceParent.cpp index 9e1111b84ab..e54cff333da 100644 --- a/dom/media/gmp/GMPServiceParent.cpp +++ b/dom/media/gmp/GMPServiceParent.cpp @@ -60,7 +60,7 @@ static const uint32_t NodeIdSaltLength = 32; already_AddRefed GeckoMediaPluginServiceParent::GetSingleton() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsRefPtr service( GeckoMediaPluginServiceParent::GetGeckoMediaPluginService()); #ifdef DEBUG @@ -144,7 +144,7 @@ GeckoMediaPluginServiceParent::InitStorage() MOZ_ASSERT(NS_IsMainThread()); // GMP storage should be used in the chrome process only. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return NS_OK; } diff --git a/dom/media/webspeech/synth/nsSpeechTask.cpp b/dom/media/webspeech/synth/nsSpeechTask.cpp index 4d408e945b0..39237dc1e93 100644 --- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -146,7 +146,7 @@ NS_IMETHODIMP nsSpeechTask::Setup(nsISpeechTaskCallback* aCallback, uint32_t aChannels, uint32_t aRate, uint8_t argc) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); LOG(LogLevel::Debug, ("nsSpeechTask::Setup")); @@ -195,7 +195,7 @@ NS_IMETHODIMP nsSpeechTask::SendAudio(JS::Handle aData, JS::Handle aLandmarks, JSContext* aCx) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); NS_ENSURE_TRUE(mStream, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_FALSE(mStream->IsDestroyed(), NS_ERROR_NOT_AVAILABLE); @@ -237,7 +237,7 @@ nsSpeechTask::SendAudio(JS::Handle aData, JS::Handle aLand NS_IMETHODIMP nsSpeechTask::SendAudioNative(int16_t* aData, uint32_t aDataLen) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); NS_ENSURE_TRUE(mStream, NS_ERROR_NOT_AVAILABLE); NS_ENSURE_FALSE(mStream->IsDestroyed(), NS_ERROR_NOT_AVAILABLE); @@ -481,7 +481,7 @@ nsSpeechTask::DispatchMarkImpl(const nsAString& aName, void nsSpeechTask::Pause() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (mCallback) { DebugOnly rv = mCallback->OnPause(); @@ -497,7 +497,7 @@ nsSpeechTask::Pause() void nsSpeechTask::Resume() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (mCallback) { DebugOnly rv = mCallback->OnResume(); @@ -513,7 +513,7 @@ nsSpeechTask::Resume() void nsSpeechTask::Cancel() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); LOG(LogLevel::Debug, ("nsSpeechTask::Cancel")); diff --git a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp index 4cea67bd8fd..d3af0551bc4 100644 --- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp +++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp @@ -100,7 +100,7 @@ NS_IMPL_ISUPPORTS(nsSynthVoiceRegistry, nsISynthVoiceRegistry) nsSynthVoiceRegistry::nsSynthVoiceRegistry() : mSpeechSynthChild(nullptr) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mSpeechSynthChild = new SpeechSynthesisChild(); ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor(mSpeechSynthChild); @@ -165,7 +165,7 @@ void nsSynthVoiceRegistry::Shutdown() { LOG(LogLevel::Debug, ("[%s] nsSynthVoiceRegistry::Shutdown()", - (XRE_GetProcessType() == GeckoProcessType_Content) ? "Content" : "Default")); + (XRE_IsContentProcess()) ? "Content" : "Default")); gSynthVoiceRegistry = nullptr; } @@ -236,7 +236,7 @@ nsSynthVoiceRegistry::AddVoice(nsISpeechService* aService, NS_ConvertUTF16toUTF8(aLang).get(), aLocalService ? "true" : "false")); - NS_ENSURE_FALSE(XRE_GetProcessType() == GeckoProcessType_Content, + NS_ENSURE_FALSE(XRE_IsContentProcess(), NS_ERROR_NOT_AVAILABLE); return AddVoiceImpl(aService, aUri, aName, aLang, @@ -250,7 +250,7 @@ nsSynthVoiceRegistry::RemoveVoice(nsISpeechService* aService, LOG(LogLevel::Debug, ("nsSynthVoiceRegistry::RemoveVoice uri='%s' (%s)", NS_ConvertUTF16toUTF8(aUri).get(), - (XRE_GetProcessType() == GeckoProcessType_Content) ? "child" : "parent")); + (XRE_IsContentProcess()) ? "child" : "parent")); bool found = false; VoiceData* retval = mUriVoiceMap.GetWeak(aUri, &found); @@ -289,7 +289,7 @@ nsSynthVoiceRegistry::SetDefaultVoice(const nsAString& aUri, mDefaultVoices.AppendElement(retval); } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsTArray ssplist; GetAllSpeechSynthActors(ssplist); @@ -521,7 +521,7 @@ nsSynthVoiceRegistry::SpeakUtterance(SpeechSynthesisUtterance& aUtterance, } nsRefPtr task; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { task = new SpeechTaskChild(&aUtterance); SpeechSynthesisRequestChild* actor = new SpeechSynthesisRequestChild(static_cast(task.get())); diff --git a/dom/media/webspeech/synth/pico/nsPicoService.cpp b/dom/media/webspeech/synth/pico/nsPicoService.cpp index 718cfd1edea..2ad75718702 100644 --- a/dom/media/webspeech/synth/pico/nsPicoService.cpp +++ b/dom/media/webspeech/synth/pico/nsPicoService.cpp @@ -723,7 +723,7 @@ nsPicoService* nsPicoService::GetInstance() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { MOZ_ASSERT(false, "nsPicoService can only be started on main gecko process"); return nullptr; } diff --git a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp index a997cc11175..33e231eae61 100644 --- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp +++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp @@ -326,7 +326,7 @@ nsFakeSynthServices* nsFakeSynthServices::GetInstance() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { MOZ_ASSERT(false, "nsFakeSynthServices can only be started on main gecko process"); return nullptr; } diff --git a/dom/mobileconnection/MobileConnectionArray.cpp b/dom/mobileconnection/MobileConnectionArray.cpp index 6377e6a54a5..598232130cd 100644 --- a/dom/mobileconnection/MobileConnectionArray.cpp +++ b/dom/mobileconnection/MobileConnectionArray.cpp @@ -101,7 +101,7 @@ NS_CreateMobileConnectionService() { nsCOMPtr service; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { service = new mozilla::dom::mobileconnection::MobileConnectionIPCService(); } else { #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) diff --git a/dom/mobilemessage/MobileMessageManager.cpp b/dom/mobilemessage/MobileMessageManager.cpp index c869fd833b0..da7d67a4232 100644 --- a/dom/mobilemessage/MobileMessageManager.cpp +++ b/dom/mobilemessage/MobileMessageManager.cpp @@ -845,7 +845,7 @@ NS_CreateSmsService() { nsCOMPtr smsService; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { smsService = SmsIPCService::GetSingleton(); } else { #ifdef MOZ_WIDGET_ANDROID @@ -862,7 +862,7 @@ already_AddRefed NS_CreateMobileMessageDatabaseService() { nsCOMPtr mobileMessageDBService; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mobileMessageDBService = SmsIPCService::GetSingleton(); } else { #ifdef MOZ_WIDGET_ANDROID @@ -881,7 +881,7 @@ NS_CreateMmsService() { nsCOMPtr mmsService; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mmsService = SmsIPCService::GetSingleton(); } else { #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) diff --git a/dom/network/UDPSocket.cpp b/dom/network/UDPSocket.cpp index 1b4a1f1943d..8b538a36533 100644 --- a/dom/network/UDPSocket.cpp +++ b/dom/network/UDPSocket.cpp @@ -558,7 +558,7 @@ UDPSocket::Init(const nsString& aLocalAddress, } nsresult rv; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { rv = mSocket->InitRemote(mSocket->mLocalAddress, localPort); } else { rv = mSocket->InitLocal(mSocket->mLocalAddress, localPort); diff --git a/dom/nfc/gonk/NfcService.cpp b/dom/nfc/gonk/NfcService.cpp index 68c69508b7d..9f1df9f1170 100644 --- a/dom/nfc/gonk/NfcService.cpp +++ b/dom/nfc/gonk/NfcService.cpp @@ -312,7 +312,7 @@ NfcService::~NfcService() already_AddRefed NfcService::FactoryCreate() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index 771a5a7e881..25f3d573b6d 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -249,7 +249,7 @@ nsNPAPIPlugin::PluginCrashed(const nsAString& pluginDumpID, bool nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return true; } @@ -404,7 +404,7 @@ GetNewPluginLibrary(nsPluginTag *aPluginTag) return nullptr; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return PluginModuleContentParent::LoadModule(aPluginTag->mId); } diff --git a/dom/plugins/base/nsPluginHost.cpp b/dom/plugins/base/nsPluginHost.cpp index f08eaee8542..540dfbdc8a9 100644 --- a/dom/plugins/base/nsPluginHost.cpp +++ b/dom/plugins/base/nsPluginHost.cpp @@ -253,7 +253,7 @@ nsPluginHost::nsPluginHost() // good plugin list the first time it requests it. Normally we'd just // init this to 1, but due to the unique nature of our ctor we need to do // this manually. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { IncrementChromeEpoch(); } @@ -1271,7 +1271,7 @@ nsresult nsPluginHost::EnsurePluginLoaded(nsPluginTag* aPluginTag) nsresult nsPluginHost::GetPluginForContentProcess(uint32_t aPluginId, nsNPAPIPlugin** aPlugin) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // If plugins haven't been scanned yet, do so now LoadPlugins(); @@ -1336,7 +1336,7 @@ protected: void nsPluginHost::NotifyContentModuleDestroyed(uint32_t aPluginId) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // This is called in response to a message from the plugin. Don't unload the // plugin until the message handler is off the stack. @@ -1842,7 +1842,7 @@ nsresult nsPluginHost::ScanPluginsDirectory(nsIFile *pluginsDir, bool aCreatePluginList, bool *aPluginsChanged) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); NS_ENSURE_ARG_POINTER(aPluginsChanged); nsresult rv; @@ -2049,7 +2049,7 @@ nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator *dirEnum, bool aCreatePluginList, bool *aPluginsChanged) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); bool hasMore; while (NS_SUCCEEDED(dirEnum->HasMoreElements(&hasMore)) && hasMore) { @@ -2078,28 +2078,28 @@ nsresult nsPluginHost::ScanPluginsDirectoryList(nsISimpleEnumerator *dirEnum, void nsPluginHost::IncrementChromeEpoch() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); mPluginEpoch++; } uint32_t nsPluginHost::ChromeEpoch() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); return mPluginEpoch; } uint32_t nsPluginHost::ChromeEpochForContent() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); + MOZ_ASSERT(XRE_IsContentProcess()); return mPluginEpoch; } void nsPluginHost::SetChromeEpochForContent(uint32_t aEpoch) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); + MOZ_ASSERT(XRE_IsContentProcess()); mPluginEpoch = aEpoch; } @@ -2129,7 +2129,7 @@ WatchRegKey(uint32_t aRoot, nsCOMPtr& aKey) nsresult nsPluginHost::LoadPlugins() { #ifdef ANDROID - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return NS_OK; } #endif @@ -2153,7 +2153,7 @@ nsresult nsPluginHost::LoadPlugins() // only if plugins have changed will we notify plugin-change observers if (pluginschanged) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { IncrementChromeEpoch(); } @@ -2169,7 +2169,7 @@ nsresult nsPluginHost::LoadPlugins() nsresult nsPluginHost::FindPluginsInContent(bool aCreatePluginList, bool* aPluginsChanged) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); + MOZ_ASSERT(XRE_IsContentProcess()); dom::ContentChild* cp = dom::ContentChild::GetSingleton(); nsTArray plugins; @@ -2225,7 +2225,7 @@ nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChange *aPluginsChanged = false; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return FindPluginsInContent(aCreatePluginList, aPluginsChanged); } @@ -2392,7 +2392,7 @@ mozilla::plugins::FindPluginsForContent(uint32_t aPluginEpoch, nsTArray* aPlugins, uint32_t* aNewPluginEpoch) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsRefPtr host = nsPluginHost::GetInst(); host->FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch); @@ -2404,7 +2404,7 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch, nsTArray* aPlugins, uint32_t* aNewPluginEpoch) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // Load plugins so that the epoch is correct. LoadPlugins(); @@ -2444,7 +2444,7 @@ nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch, void nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); ReadPluginInfo(); WritePluginInfo(); @@ -2530,7 +2530,7 @@ nsPluginHost::RegisterWithCategoryManager(nsCString &aMimeType, nsresult nsPluginHost::WritePluginInfo() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsresult rv = NS_OK; nsCOMPtr directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv)); @@ -2675,7 +2675,7 @@ nsPluginHost::WritePluginInfo() nsresult nsPluginHost::ReadPluginInfo() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); const long PLUGIN_REG_MIMETYPES_ARRAY_SIZE = 12; const long PLUGIN_REG_MAX_MIMETYPES = 1000; diff --git a/dom/plugins/base/nsPluginInstanceOwner.cpp b/dom/plugins/base/nsPluginInstanceOwner.cpp index 07261e20710..3b748e4d584 100644 --- a/dom/plugins/base/nsPluginInstanceOwner.cpp +++ b/dom/plugins/base/nsPluginInstanceOwner.cpp @@ -652,7 +652,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value) // we only attempt to get the nearest window if this really is a "windowless" plugin so as not // to change any behaviour for the much more common windowed plugins, // though why this method would even be being called for a windowed plugin escapes me. - if (XRE_GetProcessType() != GeckoProcessType_Content && + if (!XRE_IsContentProcess() && mPluginWindow && mPluginWindow->type == NPWindowTypeDrawable) { // it turns out that flash also uses this window for determining focus, and is currently // unable to show a caret correctly if we return the enclosing window. Therefore for @@ -2840,7 +2840,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void) parentWidget = nsContentUtils::WidgetForDocument(doc); #ifndef XP_MACOSX // If we're running in the content process, we need a remote widget created in chrome. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsCOMPtr window = doc->GetWindow(); if (window) { nsCOMPtr topWindow; @@ -2962,7 +2962,7 @@ void nsPluginInstanceOwner::FixUpPluginWindow(int32_t inPaintState) mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top; mPluginWindow->clipRect.right = mPluginWindow->clipRect.left; } - else if (XRE_GetProcessType() != GeckoProcessType_Default) + else if (!XRE_IsParentProcess()) { // For e10s we only support async windowless plugin. This means that // we're always going to allocate a full window for the plugin to draw @@ -3156,7 +3156,7 @@ nsPluginInstanceOwner::UpdateDocumentActiveState(bool aIsActive) // to be forwarded over after the active state is updated. If we // don't hide plugin widgets in hidden tabs, the native child window // in chrome will remain visible after a tab switch. - if (mWidget && XRE_GetProcessType() == GeckoProcessType_Content) { + if (mWidget && XRE_IsContentProcess()) { mWidget->Show(aIsActive); mWidget->Enable(aIsActive); } diff --git a/dom/plugins/base/nsPluginNativeWindowGtk.cpp b/dom/plugins/base/nsPluginNativeWindowGtk.cpp index 24f2385a409..32eb3f4abea 100644 --- a/dom/plugins/base/nsPluginNativeWindowGtk.cpp +++ b/dom/plugins/base/nsPluginNativeWindowGtk.cpp @@ -72,7 +72,7 @@ nsresult nsPluginNativeWindowGtk::CallSetWindow(nsRefPtr { if (aPluginInstance) { if (type == NPWindowTypeWindow && - XRE_GetProcessType() == GeckoProcessType_Content) { + XRE_IsContentProcess()) { // In this case, most of the initialization code here has already happened // in the chrome process. The window we have in content is the XID of the // socket widget we need to hand to plugins. diff --git a/dom/plugins/base/nsPluginNativeWindowWin.cpp b/dom/plugins/base/nsPluginNativeWindowWin.cpp index 500650a4a8a..95c439a679e 100644 --- a/dom/plugins/base/nsPluginNativeWindowWin.cpp +++ b/dom/plugins/base/nsPluginNativeWindowWin.cpp @@ -617,7 +617,7 @@ nsresult nsPluginNativeWindowWin::CallSetWindow(nsRefPtr // With e10s we execute in the content process and as such we don't // have access to native widgets. CallSetWindow and skip native widget // subclassing. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { nsPluginNativeWindow::CallSetWindow(aPluginInstance); return NS_OK; } diff --git a/dom/plugins/base/nsPluginTags.cpp b/dom/plugins/base/nsPluginTags.cpp index 11c42c40201..061042d40ba 100644 --- a/dom/plugins/base/nsPluginTags.cpp +++ b/dom/plugins/base/nsPluginTags.cpp @@ -651,7 +651,7 @@ nsPluginTag::GetBlocklistState(uint32_t *aResult) return NS_OK; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { *aResult = nsIBlocklistService::STATE_BLOCKED; dom::ContentChild* cp = dom::ContentChild::GetSingleton(); if (!cp->SendGetBlocklistState(mId, aResult)) { diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 040398aeb9c..cec5ec1908f 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -1856,7 +1856,7 @@ PluginInstanceParent::SubclassPluginWindow(HWND aWnd) return; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { if (!aWnd) { NS_WARNING("PluginInstanceParent::SubclassPluginWindow unexpected null window"); return; @@ -1886,7 +1886,7 @@ PluginInstanceParent::SubclassPluginWindow(HWND aWnd) void PluginInstanceParent::UnsubclassPluginWindow() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { if (mPluginHWND) { // Remove 'this' from the plugin list safely nsAutoPtr tmp; diff --git a/dom/plugins/ipc/PluginModuleParent.cpp b/dom/plugins/ipc/PluginModuleParent.cpp index 207898b7bd1..b56d7e1c4cb 100755 --- a/dom/plugins/ipc/PluginModuleParent.cpp +++ b/dom/plugins/ipc/PluginModuleParent.cpp @@ -352,7 +352,7 @@ bool PluginModuleMapping::sIsLoadModuleOnStack = false; void mozilla::plugins::TerminatePlugin(uint32_t aPluginId, const nsString& aBrowserDumpId) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsRefPtr host = nsPluginHost::GetInst(); nsPluginTag* pluginTag = host->PluginWithId(aPluginId); @@ -370,7 +370,7 @@ PluginModuleContentParent::LoadModule(uint32_t aPluginId) PluginModuleMapping::NotifyLoadingModule loadingModule; nsAutoPtr mapping(new PluginModuleMapping(aPluginId)); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); + MOZ_ASSERT(XRE_IsContentProcess()); /* * We send a LoadPlugin message to the chrome process using an intr diff --git a/dom/promise/PromiseDebugging.cpp b/dom/promise/PromiseDebugging.cpp index b1f5aef030a..b1ce5bba64f 100644 --- a/dom/promise/PromiseDebugging.cpp +++ b/dom/promise/PromiseDebugging.cpp @@ -96,7 +96,7 @@ PromiseDebugging::Init() // Generate a prefix for identifiers: "PromiseDebugging.$processid." sIDPrefix = NS_LITERAL_STRING("PromiseDebugging."); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { sIDPrefix.AppendInt(ContentChild::GetSingleton()->GetID()); sIDPrefix.Append('.'); } else { diff --git a/dom/quota/QuotaManager.cpp b/dom/quota/QuotaManager.cpp index 2f8c71bc0e3..471c8d9feda 100644 --- a/dom/quota/QuotaManager.cpp +++ b/dom/quota/QuotaManager.cpp @@ -756,11 +756,6 @@ struct MOZ_STACK_CLASS InactiveOriginsInfo nsTArray& origins; }; -bool -IsMainProcess() -{ - return XRE_GetProcessType() == GeckoProcessType_Default; -} void SanitizeOriginString(nsCString& aOrigin) @@ -1370,7 +1365,7 @@ nsresult QuotaManager::Init() { nsresult rv; - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { nsCOMPtr baseDir; rv = NS_GetSpecialDirectory(NS_APP_INDEXEDDB_PARENT_DIR, getter_AddRefs(baseDir)); @@ -2791,7 +2786,7 @@ QuotaManager::GetUsageForURI(nsIURI* aURI, NS_ENSURE_ARG_POINTER(aCallback); // This only works from the main process. - NS_ENSURE_TRUE(IsMainProcess(), NS_ERROR_NOT_AVAILABLE); + NS_ENSURE_TRUE(XRE_IsParentProcess(), NS_ERROR_NOT_AVAILABLE); if (!aOptionalArgCount) { aAppId = nsIScriptSecurityManager::NO_APP_ID; @@ -2879,7 +2874,7 @@ QuotaManager::ClearStoragesForURI(nsIURI* aURI, } // This only works from the main process. - NS_ENSURE_TRUE(IsMainProcess(), NS_ERROR_NOT_AVAILABLE); + NS_ENSURE_TRUE(XRE_IsParentProcess(), NS_ERROR_NOT_AVAILABLE); if (!aOptionalArgCount) { aAppId = nsIScriptSecurityManager::NO_APP_ID; @@ -2982,7 +2977,7 @@ QuotaManager::Observe(nsISupports* aSubject, NS_ERROR("Shutdown more than once?!"); } - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { // Kick off the shutdown timer. if (NS_FAILED(mShutdownTimer->Init(this, DEFAULT_SHUTDOWN_TIMER_MS, nsITimer::TYPE_ONE_SHOT))) { @@ -3021,7 +3016,7 @@ QuotaManager::Observe(nsISupports* aSubject, } if (!strcmp(aTopic, NS_TIMER_CALLBACK_TOPIC)) { - NS_ASSERTION(IsMainProcess(), "Should only happen in the main process!"); + NS_ASSERTION(XRE_IsParentProcess(), "Should only happen in the main process!"); NS_WARNING("Some storage operations are taking longer than expected " "during shutdown and will be aborted!"); @@ -3215,7 +3210,7 @@ QuotaManager::ClearStoragesForApp(uint32_t aAppId, bool aBrowserOnly) NS_ASSERTION(aAppId != kUnknownAppId, "Bad appId!"); // This only works from the main process. - NS_ENSURE_TRUE(IsMainProcess(), NS_ERROR_NOT_AVAILABLE); + NS_ENSURE_TRUE(XRE_IsParentProcess(), NS_ERROR_NOT_AVAILABLE); nsAutoCString pattern; GetOriginPatternStringMaybeIgnoreBrowser(aAppId, aBrowserOnly, pattern); diff --git a/dom/speakermanager/SpeakerManagerService.cpp b/dom/speakermanager/SpeakerManagerService.cpp index d2abc036303..27d6ecb0b4d 100644 --- a/dom/speakermanager/SpeakerManagerService.cpp +++ b/dom/speakermanager/SpeakerManagerService.cpp @@ -30,7 +30,7 @@ SpeakerManagerService::GetOrCreateSpeakerManagerService() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return SpeakerManagerServiceChild::GetOrCreateSpeakerManagerService(); } @@ -52,7 +52,7 @@ SpeakerManagerService::GetSpeakerManagerService() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return SpeakerManagerServiceChild::GetSpeakerManagerService(); } @@ -62,7 +62,7 @@ SpeakerManagerService::GetSpeakerManagerService() void SpeakerManagerService::Shutdown() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return SpeakerManagerServiceChild::Shutdown(); } @@ -188,7 +188,7 @@ SpeakerManagerService::SpeakerManagerService() mVisible(false) { MOZ_COUNT_CTOR(SpeakerManagerService); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { obs->AddObserver(this, "ipc:content-shutdown", false); diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index e68063403da..82f7bd41188 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -761,7 +761,7 @@ DOMStorageCache::StartDatabase() return sDatabase; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsAutoPtr db(new DOMStorageDBThread()); nsresult rv = db->Init(); @@ -806,7 +806,7 @@ DOMStorageCache::StopDatabase() sDatabaseDown = true; nsresult rv = sDatabase->Shutdown(); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { delete sDatabase; } else { DOMStorageDBChild* child = static_cast(sDatabase); diff --git a/dom/storage/DOMStorageManager.cpp b/dom/storage/DOMStorageManager.cpp index c0f19fc21eb..59980cf067e 100644 --- a/dom/storage/DOMStorageManager.cpp +++ b/dom/storage/DOMStorageManager.cpp @@ -592,7 +592,7 @@ DOMStorageManager::Observe(const char* aTopic, const nsACString& aScopePrefix) } if (!strcmp(aTopic, "test-flushed")) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { nsCOMPtr obs = mozilla::services::GetObserverService(); if (obs) { obs->NotifyObservers(nullptr, "domstorage-test-flushed", nullptr); @@ -615,7 +615,7 @@ DOMLocalStorageManager::DOMLocalStorageManager() NS_ASSERTION(!sSelf, "Somebody is trying to do_CreateInstance(\"@mozilla/dom/localStorage-manager;1\""); sSelf = this; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Do this only on the child process. The thread IPC bridge // is also used to communicate chrome observer notifications. // Note: must be called after we set sSelf @@ -648,7 +648,7 @@ DOMLocalStorageManager::Ensure() DOMSessionStorageManager::DOMSessionStorageManager() : DOMStorageManager(SessionStorage) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Do this only on the child process. The thread IPC bridge // is also used to communicate chrome observer notifications. DOMStorageCache::StartDatabase(); diff --git a/dom/storage/DOMStorageObserver.cpp b/dom/storage/DOMStorageObserver.cpp index 73dfb660058..51806c97a8a 100644 --- a/dom/storage/DOMStorageObserver.cpp +++ b/dom/storage/DOMStorageObserver.cpp @@ -75,7 +75,7 @@ DOMStorageObserver::Init() #ifdef DOM_STORAGE_TESTS // Testing obs->AddObserver(sSelf, "domstorage-test-flush-force", true); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Only to forward to child process. obs->AddObserver(sSelf, "domstorage-test-flushed", true); } diff --git a/dom/system/gonk/AudioManager.cpp b/dom/system/gonk/AudioManager.cpp index e6ffe5d1899..3b639089f85 100644 --- a/dom/system/gonk/AudioManager.cpp +++ b/dom/system/gonk/AudioManager.cpp @@ -555,7 +555,7 @@ already_AddRefed AudioManager::GetInstance() { // Avoid createing AudioManager from content process. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { MOZ_CRASH("Non-chrome processes should not get here."); } diff --git a/dom/system/gonk/AutoMounter.cpp b/dom/system/gonk/AutoMounter.cpp index 488e676a94a..1a7db223e39 100644 --- a/dom/system/gonk/AutoMounter.cpp +++ b/dom/system/gonk/AutoMounter.cpp @@ -1298,7 +1298,7 @@ ShutdownAutoMounterIOThread() static void SetAutoMounterModeIOThread(const int32_t& aMode) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); MOZ_ASSERT(sAutoMounter); @@ -1308,7 +1308,7 @@ SetAutoMounterModeIOThread(const int32_t& aMode) static void SetAutoMounterSharingModeIOThread(const nsCString& aVolumeName, const bool& aAllowSharing) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); MOZ_ASSERT(sAutoMounter); @@ -1318,7 +1318,7 @@ SetAutoMounterSharingModeIOThread(const nsCString& aVolumeName, const bool& aAll static void AutoMounterFormatVolumeIOThread(const nsCString& aVolumeName) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); MOZ_ASSERT(sAutoMounter); @@ -1328,7 +1328,7 @@ AutoMounterFormatVolumeIOThread(const nsCString& aVolumeName) static void AutoMounterMountVolumeIOThread(const nsCString& aVolumeName) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); MOZ_ASSERT(sAutoMounter); @@ -1338,7 +1338,7 @@ AutoMounterMountVolumeIOThread(const nsCString& aVolumeName) static void AutoMounterUnmountVolumeIOThread(const nsCString& aVolumeName) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); MOZ_ASSERT(sAutoMounter); diff --git a/dom/system/gonk/NetworkWorker.cpp b/dom/system/gonk/NetworkWorker.cpp index ed67d3182c6..37af6757442 100644 --- a/dom/system/gonk/NetworkWorker.cpp +++ b/dom/system/gonk/NetworkWorker.cpp @@ -134,7 +134,7 @@ NetworkWorker::~NetworkWorker() already_AddRefed NetworkWorker::FactoryCreate() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/dom/system/gonk/SystemWorkerManager.cpp b/dom/system/gonk/SystemWorkerManager.cpp index edf8fb6dad2..1a67d0e9fd0 100644 --- a/dom/system/gonk/SystemWorkerManager.cpp +++ b/dom/system/gonk/SystemWorkerManager.cpp @@ -72,7 +72,7 @@ SystemWorkerManager::~SystemWorkerManager() nsresult SystemWorkerManager::Init() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return NS_ERROR_NOT_AVAILABLE; } diff --git a/dom/system/gonk/Volume.cpp b/dom/system/gonk/Volume.cpp index fce564d403e..772c16b0997 100644 --- a/dom/system/gonk/Volume.cpp +++ b/dom/system/gonk/Volume.cpp @@ -233,7 +233,7 @@ Volume::SetConfig(const nsCString& aConfigName, const nsCString& aConfigValue) void Volume::SetMediaPresent(bool aMediaPresent) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); // mMediaPresent is slightly redunant to the state, however @@ -308,7 +308,7 @@ Volume::SetUnmountRequested(bool aUnmountRequested) void Volume::SetState(Volume::STATE aNewState) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); if (aNewState == mState) { return; @@ -380,7 +380,7 @@ Volume::SetState(Volume::STATE aNewState) void Volume::SetMountPoint(const nsCSubstring& aMountPoint) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); if (mMountPoint.Equals(aMountPoint)) { @@ -393,7 +393,7 @@ Volume::SetMountPoint(const nsCSubstring& aMountPoint) void Volume::StartMount(VolumeResponseCallback* aCallback) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); StartCommand(new VolumeActionCommand(this, "mount", "", aCallback)); @@ -402,7 +402,7 @@ Volume::StartMount(VolumeResponseCallback* aCallback) void Volume::StartUnmount(VolumeResponseCallback* aCallback) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); StartCommand(new VolumeActionCommand(this, "unmount", "force", aCallback)); @@ -411,7 +411,7 @@ Volume::StartUnmount(VolumeResponseCallback* aCallback) void Volume::StartFormat(VolumeResponseCallback* aCallback) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); StartCommand(new VolumeActionCommand(this, "format", "", aCallback)); @@ -420,7 +420,7 @@ Volume::StartFormat(VolumeResponseCallback* aCallback) void Volume::StartShare(VolumeResponseCallback* aCallback) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); StartCommand(new VolumeActionCommand(this, "share", "ums", aCallback)); @@ -429,7 +429,7 @@ Volume::StartShare(VolumeResponseCallback* aCallback) void Volume::StartUnshare(VolumeResponseCallback* aCallback) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); StartCommand(new VolumeActionCommand(this, "unshare", "ums", aCallback)); @@ -438,7 +438,7 @@ Volume::StartUnshare(VolumeResponseCallback* aCallback) void Volume::StartCommand(VolumeCommand* aCommand) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); VolumeManager::PostCommand(aCommand); @@ -448,7 +448,7 @@ Volume::StartCommand(VolumeCommand* aCommand) void Volume::RegisterVolumeObserver(Volume::EventObserver* aObserver, const char* aName) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); sEventObserverList.AddObserver(aObserver); @@ -468,7 +468,7 @@ Volume::RegisterVolumeObserver(Volume::EventObserver* aObserver, const char* aNa void Volume::UnregisterVolumeObserver(Volume::EventObserver* aObserver, const char* aName) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); sEventObserverList.RemoveObserver(aObserver); @@ -483,7 +483,7 @@ Volume::UpdateMountLock(const nsACString& aVolumeName, const int32_t& aMountGeneration, const bool& aMountLocked) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); RefPtr vol = VolumeManager::FindVolumeByName(aVolumeName); @@ -500,7 +500,7 @@ Volume::UpdateMountLock(const nsACString& aVolumeName, void Volume::HandleVoldResponse(int aResponseCode, nsCWhitespaceTokenizer& aTokenizer) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); // The volume name will have already been parsed, and the tokenizer will point diff --git a/dom/system/gonk/nsVolume.cpp b/dom/system/gonk/nsVolume.cpp index 41de770be92..138e2236c8c 100644 --- a/dom/system/gonk/nsVolume.cpp +++ b/dom/system/gonk/nsVolume.cpp @@ -246,7 +246,7 @@ NS_IMETHODIMP nsVolume::GetIsHotSwappable(bool *aIsHotSwappable) NS_IMETHODIMP nsVolume::Format() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); XRE_GetIOMessageLoop()->PostTask( FROM_HERE, @@ -258,7 +258,7 @@ NS_IMETHODIMP nsVolume::Format() /* static */ void nsVolume::FormatVolumeIOThread(const nsCString& aVolume) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); if (VolumeManager::State() != VolumeManager::VOLUMES_READY) { @@ -270,7 +270,7 @@ void nsVolume::FormatVolumeIOThread(const nsCString& aVolume) NS_IMETHODIMP nsVolume::Mount() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); XRE_GetIOMessageLoop()->PostTask( FROM_HERE, @@ -282,7 +282,7 @@ NS_IMETHODIMP nsVolume::Mount() /* static */ void nsVolume::MountVolumeIOThread(const nsCString& aVolume) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); if (VolumeManager::State() != VolumeManager::VOLUMES_READY) { @@ -294,7 +294,7 @@ void nsVolume::MountVolumeIOThread(const nsCString& aVolume) NS_IMETHODIMP nsVolume::Unmount() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); XRE_GetIOMessageLoop()->PostTask( FROM_HERE, @@ -306,7 +306,7 @@ NS_IMETHODIMP nsVolume::Unmount() /* static */ void nsVolume::UnmountVolumeIOThread(const nsCString& aVolume) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop()); if (VolumeManager::State() != VolumeManager::VOLUMES_READY) { @@ -364,7 +364,7 @@ void nsVolume::Set(nsIVolume* aVolume) mMountGeneration = volMountGeneration; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Child processes just track the state, not maintain it. aVolume->GetIsMountLocked(&mMountLocked); return; @@ -386,7 +386,7 @@ void nsVolume::Set(nsIVolume* aVolume) void nsVolume::UpdateMountLock(const nsAString& aMountLockState) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); // There are 3 states, unlocked, locked-background, and locked-foreground @@ -397,7 +397,7 @@ nsVolume::UpdateMountLock(const nsAString& aMountLockState) void nsVolume::UpdateMountLock(bool aMountLocked) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); if (aMountLocked == mMountLocked) { @@ -447,7 +447,7 @@ nsVolume::SetState(int32_t aState) { static int32_t sMountGeneration = 0; - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); MOZ_ASSERT(IsFake()); diff --git a/dom/system/gonk/nsVolumeService.cpp b/dom/system/gonk/nsVolumeService.cpp index a5a17471f76..033a97d1756 100644 --- a/dom/system/gonk/nsVolumeService.cpp +++ b/dom/system/gonk/nsVolumeService.cpp @@ -68,7 +68,7 @@ nsVolumeService::Shutdown() if (!sSingleton) { return; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { sSingleton = nullptr; return; } @@ -92,7 +92,7 @@ nsVolumeService::nsVolumeService() { sSingleton = this; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // VolumeServiceIOThread and the WakeLock listener should only run in the // parent, so we return early. return; @@ -271,7 +271,7 @@ nsVolumeService::GetVolumeNames(nsIArray** aVolNames) void nsVolumeService::GetVolumesForIPC(nsTArray* aResult) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); MonitorAutoLock autoLock(mArrayMonitor); @@ -299,7 +299,7 @@ nsVolumeService::GetVolumesForIPC(nsTArray* aResult) void nsVolumeService::RecvVolumesFromParent(const nsTArray& aVolumes) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // We are the parent. Therefore our volumes are already correct. return; } @@ -340,7 +340,7 @@ void nsVolumeService::CheckMountLock(const nsAString& aMountLockName, const nsAString& aMountLockState) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(NS_IsMainThread()); nsRefPtr vol = FindVolumeByMountLockName(aMountLockName); @@ -438,7 +438,7 @@ nsVolumeService::UpdateVolume(nsIVolume* aVolume, bool aNotifyObservers) NS_IMETHODIMP nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsRefPtr vol = new nsVolume(name, path, nsIVolume::STATE_INIT, -1 /* mountGeneration */, true /* isMediaPresent */, @@ -461,7 +461,7 @@ nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path) NS_IMETHODIMP nsVolumeService::SetFakeVolumeState(const nsAString& name, int32_t state) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsRefPtr vol; { MonitorAutoLock autoLock(mArrayMonitor); @@ -489,7 +489,7 @@ nsVolumeService::SetFakeVolumeState(const nsAString& name, int32_t state) NS_IMETHODIMP nsVolumeService::RemoveFakeVolume(const nsAString& name) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { SetFakeVolumeState(name, nsIVolume::STATE_NOMEDIA); RemoveVolumeByName(name); return NS_OK; @@ -512,7 +512,7 @@ nsVolumeService::RemoveVolumeByName(const nsAString& aName) } mVolumeArray.RemoveElement(vol); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr obs = GetObserverService(); if (!obs) { return; diff --git a/dom/telephony/Telephony.cpp b/dom/telephony/Telephony.cpp index 6f23e52a098..3f457eab6e0 100644 --- a/dom/telephony/Telephony.cpp +++ b/dom/telephony/Telephony.cpp @@ -720,7 +720,7 @@ NS_CreateTelephonyService() { nsCOMPtr service; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { service = new mozilla::dom::telephony::TelephonyIPCService(); } else { #if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL) diff --git a/dom/voicemail/Voicemail.cpp b/dom/voicemail/Voicemail.cpp index 41097f1e0a5..c9d729a4d85 100644 --- a/dom/voicemail/Voicemail.cpp +++ b/dom/voicemail/Voicemail.cpp @@ -250,7 +250,7 @@ NS_CreateVoicemailService() { nsCOMPtr service; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { service = new mozilla::dom::voicemail::VoicemailIPCService(); } else { #if defined(MOZ_B2G_RIL) diff --git a/dom/wifi/WifiCertService.cpp b/dom/wifi/WifiCertService.cpp index 745e72ea450..80b61296b59 100644 --- a/dom/wifi/WifiCertService.cpp +++ b/dom/wifi/WifiCertService.cpp @@ -443,7 +443,7 @@ WifiCertService::~WifiCertService() already_AddRefed WifiCertService::FactoryCreate() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/dom/wifi/WifiProxyService.cpp b/dom/wifi/WifiProxyService.cpp index 3257abedeea..63e36d90cef 100644 --- a/dom/wifi/WifiProxyService.cpp +++ b/dom/wifi/WifiProxyService.cpp @@ -150,7 +150,7 @@ WifiProxyService::~WifiProxyService() already_AddRefed WifiProxyService::FactoryCreate() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/dom/workers/ServiceWorkerManager.cpp b/dom/workers/ServiceWorkerManager.cpp index 222f1e61958..ec1a48801c4 100644 --- a/dom/workers/ServiceWorkerManager.cpp +++ b/dom/workers/ServiceWorkerManager.cpp @@ -402,7 +402,7 @@ ServiceWorkerManager::Init() MOZ_ASSERT(NS_SUCCEEDED(rv)); } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsRefPtr swr = ServiceWorkerRegistrar::Get(); MOZ_ASSERT(swr); @@ -4543,7 +4543,7 @@ void ServiceWorkerManager::PropagateRemoveAll() { AssertIsOnMainThread(); - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (!mActor) { nsRefPtr runnable = new PropagateRemoveAllRunnable(); @@ -4600,21 +4600,21 @@ ServiceWorkerManager::Observe(nsISupports* aSubject, const char16_t* aData) { if (strcmp(aTopic, PURGE_SESSION_HISTORY) == 0) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); RemoveAll(); PropagateRemoveAll(); return NS_OK; } if (strcmp(aTopic, PURGE_DOMAIN_DATA) == 0) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsAutoString domain(aData); RemoveAndPropagate(NS_ConvertUTF16toUTF8(domain)); return NS_OK; } if (strcmp(aTopic, WEBAPPS_CLEAR_DATA) == 0) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsCOMPtr params = do_QueryInterface(aSubject); if (NS_WARN_IF(!params)) { @@ -4654,7 +4654,7 @@ ServiceWorkerManager::Observe(nsISupports* aSubject, if (obs) { obs->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { obs->RemoveObserver(this, PURGE_SESSION_HISTORY); obs->RemoveObserver(this, PURGE_DOMAIN_DATA); obs->RemoveObserver(this, WEBAPPS_CLEAR_DATA); diff --git a/dom/workers/ServiceWorkerPeriodicUpdater.cpp b/dom/workers/ServiceWorkerPeriodicUpdater.cpp index fa22a261138..8fea986a809 100644 --- a/dom/workers/ServiceWorkerPeriodicUpdater.cpp +++ b/dom/workers/ServiceWorkerPeriodicUpdater.cpp @@ -28,7 +28,7 @@ ServiceWorkerPeriodicUpdater::sPeriodicUpdatesEnabled = true; already_AddRefed ServiceWorkerPeriodicUpdater::GetSingleton() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); if (!sInstance) { sInstance = new ServiceWorkerPeriodicUpdater(); diff --git a/dom/workers/ServiceWorkerRegistrar.cpp b/dom/workers/ServiceWorkerRegistrar.cpp index 24ff4d7f8f4..ff4639485e7 100644 --- a/dom/workers/ServiceWorkerRegistrar.cpp +++ b/dom/workers/ServiceWorkerRegistrar.cpp @@ -48,7 +48,7 @@ ServiceWorkerRegistrar::Initialize() { MOZ_ASSERT(!gServiceWorkerRegistrar); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } @@ -70,7 +70,7 @@ ServiceWorkerRegistrar::Initialize() /* static */ already_AddRefed ServiceWorkerRegistrar::Get() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); MOZ_ASSERT(gServiceWorkerRegistrar); nsRefPtr service = gServiceWorkerRegistrar.get(); diff --git a/dom/workers/WorkerPrivate.cpp b/dom/workers/WorkerPrivate.cpp index 43eac9e7b54..715ae2984b9 100644 --- a/dom/workers/WorkerPrivate.cpp +++ b/dom/workers/WorkerPrivate.cpp @@ -2699,7 +2699,7 @@ private: mAlreadyMappedToAddon = true; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Only try to access the service from the main process. return; } diff --git a/embedding/browser/nsWebBrowser.cpp b/embedding/browser/nsWebBrowser.cpp index 33ed9fdd988..298d24704dd 100644 --- a/embedding/browser/nsWebBrowser.cpp +++ b/embedding/browser/nsWebBrowser.cpp @@ -1238,7 +1238,7 @@ nsWebBrowser::Create() } mDocShellAsNav->SetSessionHistory(mInitInfo->sessionHistory); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Hook up global history. Do not fail if we can't - just warn. rv = EnableGlobalHistory(mShouldEnableHistory); NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "EnableGlobalHistory() failed"); diff --git a/embedding/components/windowwatcher/nsWindowWatcher.cpp b/embedding/components/windowwatcher/nsWindowWatcher.cpp index 02e410cb6dd..2674d57caec 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp @@ -480,7 +480,7 @@ nsWindowWatcher::OpenWindowInternal(nsIDOMWindow* aParent, } MOZ_ASSERT_IF(openedFromRemoteTab, - XRE_GetProcessType() == GeckoProcessType_Default); + XRE_IsParentProcess()); NS_ENSURE_ARG_POINTER(aResult); *aResult = 0; diff --git a/extensions/cookie/nsPermissionManager.cpp b/extensions/cookie/nsPermissionManager.cpp index c0d26ab74ab..32ae6ef1ece 100644 --- a/extensions/cookie/nsPermissionManager.cpp +++ b/extensions/cookie/nsPermissionManager.cpp @@ -48,7 +48,7 @@ using mozilla::unused; // ha! static bool IsChildProcess() { - return XRE_GetProcessType() == GeckoProcessType_Content; + return XRE_IsContentProcess(); } /** diff --git a/extensions/spellcheck/src/mozSpellChecker.cpp b/extensions/spellcheck/src/mozSpellChecker.cpp index 1da91189474..adc34f2898a 100644 --- a/extensions/spellcheck/src/mozSpellChecker.cpp +++ b/extensions/spellcheck/src/mozSpellChecker.cpp @@ -49,7 +49,7 @@ mozSpellChecker::~mozSpellChecker() mPersonalDictionary = nullptr; if (mEngine) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content); + MOZ_ASSERT(XRE_IsContentProcess()); mEngine->Send__delete__(mEngine); MOZ_ASSERT(!mEngine); } @@ -59,7 +59,7 @@ nsresult mozSpellChecker::Init() { mSpellCheckingEngine = nullptr; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mozilla::dom::ContentChild* contentChild = mozilla::dom::ContentChild::GetSingleton(); MOZ_ASSERT(contentChild); mEngine = new RemoteSpellcheckEngineChild(this); @@ -130,7 +130,7 @@ mozSpellChecker::CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray nsresult result; bool correct; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsString wordwrapped = nsString(aWord); bool rv; if (aSuggestions) { @@ -309,7 +309,7 @@ mozSpellChecker::GetPersonalDictionary(nsTArray *aWordList) NS_IMETHODIMP mozSpellChecker::GetDictionaryList(nsTArray *aDictionaryList) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild *child = ContentChild::GetSingleton(); child->GetAvailableDictionaries(*aDictionaryList); return NS_OK; @@ -357,7 +357,7 @@ mozSpellChecker::GetDictionaryList(nsTArray *aDictionaryList) NS_IMETHODIMP mozSpellChecker::GetCurrentDictionary(nsAString &aDictionary) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { aDictionary = mCurrentDictionary; return NS_OK; } @@ -376,7 +376,7 @@ mozSpellChecker::GetCurrentDictionary(nsAString &aDictionary) NS_IMETHODIMP mozSpellChecker::SetCurrentDictionary(const nsAString &aDictionary) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsString wrappedDict = nsString(aDictionary); bool isSuccess; mEngine->SendSetDictionary(wrappedDict, &isSuccess); @@ -536,7 +536,7 @@ mozSpellChecker::GetCurrentBlockIndex(nsITextServicesDocument *aDoc, int32_t *ou nsresult mozSpellChecker::GetEngineList(nsCOMArray* aSpellCheckingEngines) { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Content); + MOZ_ASSERT(!XRE_IsContentProcess()); nsresult rv; bool hasMoreEngines; diff --git a/gfx/gl/GLScreenBuffer.cpp b/gfx/gl/GLScreenBuffer.cpp index 6fed08bfc09..6cd9b0a8787 100755 --- a/gfx/gl/GLScreenBuffer.cpp +++ b/gfx/gl/GLScreenBuffer.cpp @@ -40,7 +40,6 @@ GLScreenBuffer::Create(GLContext* gl, return Move(ret); } - layers::TextureFlags flags = layers::TextureFlags::ORIGIN_BOTTOM_LEFT; if (!caps.premultAlpha) { flags |= layers::TextureFlags::NON_PREMULTIPLIED; diff --git a/gfx/layers/client/ClientCanvasLayer.cpp b/gfx/layers/client/ClientCanvasLayer.cpp index 29ce8084804..69f9e36e998 100644 --- a/gfx/layers/client/ClientCanvasLayer.cpp +++ b/gfx/layers/client/ClientCanvasLayer.cpp @@ -88,8 +88,7 @@ ClientCanvasLayer::Initialize(const Data& aData) factory = MakeUnique(mGLContext, caps, forwarder, mFlags); #else if (mGLContext->GetContextType() == GLContextType::EGL) { - bool isCrossProcess = (XRE_GetProcessType() != GeckoProcessType_Default); - if (!isCrossProcess) { + if (XRE_IsParentProcess()) { factory = SurfaceFactory_EGLImage::Create(mGLContext, caps, forwarder, mFlags); } diff --git a/gfx/layers/client/ClientLayerManager.cpp b/gfx/layers/client/ClientLayerManager.cpp index 7e94c5cb2e7..e3093ef6eff 100644 --- a/gfx/layers/client/ClientLayerManager.cpp +++ b/gfx/layers/client/ClientLayerManager.cpp @@ -221,7 +221,7 @@ ClientLayerManager::BeginTransactionWithTarget(gfxContext* aTarget) // If we have a non-default target, we need to let our shadow manager draw // to it. This will happen at the end of the transaction. - if (aTarget && XRE_GetProcessType() == GeckoProcessType_Default) { + if (aTarget && XRE_IsParentProcess()) { mShadowTarget = aTarget; } else { NS_ASSERTION(!aTarget, @@ -370,7 +370,7 @@ ClientLayerManager::GetRemoteRenderer() CompositorChild* ClientLayerManager::GetCompositorChild() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return CompositorChild::Get(); } return GetRemoteRenderer(); diff --git a/gfx/layers/ipc/CompositorChild.cpp b/gfx/layers/ipc/CompositorChild.cpp index dfd3a00bbcf..62d705ace5c 100644 --- a/gfx/layers/ipc/CompositorChild.cpp +++ b/gfx/layers/ipc/CompositorChild.cpp @@ -162,7 +162,7 @@ CompositorChild::OpenSameProcess(CompositorParent* aParent) CompositorChild::Get() { // This is only expected to be used in child processes. - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default); + MOZ_ASSERT(!XRE_IsParentProcess()); return sCompositor; } diff --git a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp index 61f15bb5a7e..33530ff36d7 100644 --- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp +++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp @@ -148,7 +148,7 @@ ParamTraits::Read(const Message* aMsg, aResult->mRef.mOwner = owner; aResult->mRef.mKey = index; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // If we are in chrome process, we can just get GraphicBuffer directly from // SharedBufferManagerParent. aResult->mGraphicBuffer = SharedBufferManagerParent::GetGraphicBuffer(aResult->mRef); @@ -215,7 +215,7 @@ GetGraphicBufferFrom(MaybeMagicGrallocBufferHandle aHandle) { if (aHandle.type() != MaybeMagicGrallocBufferHandle::TMagicGrallocBufferHandle) { if (aHandle.type() == MaybeMagicGrallocBufferHandle::TGrallocBufferRef) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { return SharedBufferManagerParent::GetGraphicBuffer(aHandle.get_GrallocBufferRef()); } return SharedBufferManagerChild::GetSingleton()->GetGraphicBuffer(aHandle.get_GrallocBufferRef().mKey); diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp index 4e75bc8eab0..ac90edd6940 100644 --- a/gfx/layers/opengl/TextureClientOGL.cpp +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -29,7 +29,7 @@ EGLImageTextureClient::EGLImageTextureClient(ISurfaceAllocator* aAllocator, , mSize(aSize) , mIsLocked(false) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT(XRE_IsParentProcess(), "Can't pass an `EGLImage` between processes."); AddFlags(TextureFlags::DEALLOCATE_CLIENT); @@ -85,7 +85,7 @@ SurfaceTextureClient::SurfaceTextureClient(ISurfaceAllocator* aAllocator, , mSize(aSize) , mIsLocked(false) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT(XRE_IsParentProcess(), "Can't pass pointers between processes."); // Our data is always owned externally. diff --git a/gfx/thebes/gfxAndroidPlatform.cpp b/gfx/thebes/gfxAndroidPlatform.cpp index bf889c0f2e8..8b242b48a09 100644 --- a/gfx/thebes/gfxAndroidPlatform.cpp +++ b/gfx/thebes/gfxAndroidPlatform.cpp @@ -392,7 +392,7 @@ gfxAndroidPlatform::RequiresLinearZoom() // On B2G, we need linear zoom for the browser, but otherwise prefer // the improved glyph spacing that results from respecting the device // pixel resolution for glyph layout (see bug 816614). - return XRE_GetProcessType() == GeckoProcessType_Content && + return XRE_IsContentProcess() && ContentChild::GetSingleton()->IsForBrowser(); #endif diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp index 0447455927e..394fb180658 100644 --- a/gfx/thebes/gfxFT2FontList.cpp +++ b/gfx/thebes/gfxFT2FontList.cpp @@ -635,7 +635,7 @@ public: nullptr }; - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT(XRE_IsParentProcess(), "StartupCacheFontNameCache should only be used in chrome " "process"); mCache = mozilla::scache::StartupCache::GetSingleton(); @@ -1148,7 +1148,7 @@ gfxFT2FontList::FindFonts() mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Content process: ask the Chrome process to give us the list InfallibleTArray fonts; mozilla::dom::ContentChild::GetSingleton()->SendReadFontList(&fonts); diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index a570bbe7f65..03b954a1a84 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -714,7 +714,7 @@ gfxPlatform::InitLayersIPC() AsyncTransactionTrackersHolder::Initialize(); - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) { mozilla::layers::CompositorParent::StartUp(); #ifndef MOZ_WIDGET_GONK @@ -736,7 +736,7 @@ gfxPlatform::ShutdownLayersIPC() } sLayersIPCIsUp = false; - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) { // This must happen after the shutdown of media and widgets, which // are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification. @@ -1070,7 +1070,7 @@ gfxPlatform::ComputeTileSize() { // The tile size should be picked in the parent processes // and sent to the child processes over IPDL GetTileSize. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { NS_RUNTIMEABORT("wrong process."); } diff --git a/gfx/thebes/gfxWindowsPlatform.cpp b/gfx/thebes/gfxWindowsPlatform.cpp index ecbef313dce..fd96dce28cb 100644 --- a/gfx/thebes/gfxWindowsPlatform.cpp +++ b/gfx/thebes/gfxWindowsPlatform.cpp @@ -655,7 +655,7 @@ gfxWindowsPlatform::CreateDevice(nsRefPtr &adapter1, mD2DDevice = cairo_d2d_create_device_from_d3d10device(device); // Setup a pref for future launch optimizaitons when in main process. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { Preferences::SetInt(kFeatureLevelPref, featureLevelIndex); } } diff --git a/image/decoders/icon/android/nsIconChannel.cpp b/image/decoders/icon/android/nsIconChannel.cpp index cd2e979fb76..1543e6721d9 100644 --- a/image/decoders/icon/android/nsIconChannel.cpp +++ b/image/decoders/icon/android/nsIconChannel.cpp @@ -80,7 +80,7 @@ moz_icon_to_channel(nsIURI* aURI, const nsACString& aFileExt, *(out++) = height; nsresult rv; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { rv = GetIconForExtension(aFileExt, aIconSize, out); } else { rv = CallRemoteGetIconForExtension(aFileExt, aIconSize, out); diff --git a/ipc/glue/BackgroundImpl.cpp b/ipc/glue/BackgroundImpl.cpp index 10db4325826..298cafe1353 100644 --- a/ipc/glue/BackgroundImpl.cpp +++ b/ipc/glue/BackgroundImpl.cpp @@ -51,7 +51,7 @@ #define CRASH_IN_CHILD_PROCESS(_msg) \ do { \ - if (IsMainProcess()) { \ + if (XRE_IsParentProcess()) { \ MOZ_ASSERT(false, _msg); \ } else { \ MOZ_CRASH(_msg); \ @@ -69,32 +69,17 @@ namespace { // Utility Functions // ----------------------------------------------------------------------------- -bool -IsMainProcess() -{ - static const bool isMainProcess = - XRE_GetProcessType() == GeckoProcessType_Default; - return isMainProcess; -} - -#ifdef DEBUG -bool -IsChildProcess() -{ - return !IsMainProcess(); -} -#endif void AssertIsInMainProcess() { - MOZ_ASSERT(IsMainProcess()); + MOZ_ASSERT(XRE_IsParentProcess()); } void AssertIsInChildProcess() { - MOZ_ASSERT(IsChildProcess()); + MOZ_ASSERT(!XRE_IsParentProcess()); } void @@ -2057,7 +2042,7 @@ ChildImpl::OpenProtocolOnMainThread(nsIEventTarget* aEventTarget) "shutdown has started!"); } - if (IsMainProcess()) { + if (XRE_IsParentProcess()) { nsRefPtr parentCallback = new ParentCreateCallback(aEventTarget); diff --git a/ipc/glue/BackgroundParentImpl.cpp b/ipc/glue/BackgroundParentImpl.cpp index 8956ab5d509..6125453cbf2 100644 --- a/ipc/glue/BackgroundParentImpl.cpp +++ b/ipc/glue/BackgroundParentImpl.cpp @@ -48,7 +48,7 @@ namespace { void AssertIsInMainProcess() { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); } void diff --git a/ipc/glue/InputStreamUtils.cpp b/ipc/glue/InputStreamUtils.cpp index aa815d5748e..cd999be042c 100644 --- a/ipc/glue/InputStreamUtils.cpp +++ b/ipc/glue/InputStreamUtils.cpp @@ -106,7 +106,7 @@ DeserializeInputStream(const InputStreamParams& aParams, // When the input stream already exists in this process, all we need to do // is retrieve the original instead of sending any data over the wire. case InputStreamParams::TRemoteInputStreamParams: { - if (NS_WARN_IF(XRE_GetProcessType() != GeckoProcessType_Default)) { + if (NS_WARN_IF(!XRE_IsParentProcess())) { return nullptr; } diff --git a/ipc/glue/ScopedXREEmbed.cpp b/ipc/glue/ScopedXREEmbed.cpp index 342decf42b3..cf1753f2c88 100644 --- a/ipc/glue/ScopedXREEmbed.cpp +++ b/ipc/glue/ScopedXREEmbed.cpp @@ -67,7 +67,7 @@ ScopedXREEmbed::Start() NS_ENSURE_TRUE_VOID(localFile); #ifdef OS_MACOSX - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { // We're an XPCOM-using subprocess. Walk out of // [subprocess].app/Contents/MacOS to the real GRE dir. rv = localFile->GetParent(getter_AddRefs(parent)); diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp index 0eeb3341d2c..abb422cade2 100644 --- a/js/xpconnect/loader/mozJSComponentLoader.cpp +++ b/js/xpconnect/loader/mozJSComponentLoader.cpp @@ -583,7 +583,7 @@ mozJSComponentLoader::PrepareObjectForLocation(JSContext* aCx, if (testFile) { *aRealFile = true; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr locationHolder; rv = xpc->WrapNative(aCx, obj, aComponentFile, NS_GET_IID(nsIFile), diff --git a/js/xpconnect/src/XPCJSRuntime.cpp b/js/xpconnect/src/XPCJSRuntime.cpp index 38ad4fea291..1b87c084eb6 100644 --- a/js/xpconnect/src/XPCJSRuntime.cpp +++ b/js/xpconnect/src/XPCJSRuntime.cpp @@ -1361,7 +1361,7 @@ XPCJSRuntime::InterruptCallback(JSContext* cx) if (!nsContentUtils::IsInitialized()) return true; - bool contentProcess = XRE_GetProcessType() == GeckoProcessType_Content; + bool contentProcess = XRE_IsContentProcess(); // This is at least the second interrupt callback we've received since // returning to the event loop. See how long it's been, and what the limit @@ -2570,7 +2570,7 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats, size_t* rtTotalOut) { nsCOMPtr am; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Only try to access the service from the main process. am = do_GetService("@mozilla.org/addons/integration;1"); } @@ -2826,7 +2826,7 @@ JSReporter::CollectReports(WindowPaths* windowPaths, // stats seems like a bad idea. nsCOMPtr addonManager; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Only try to access the service from the main process. addonManager = do_GetService("@mozilla.org/addons/integration;1"); } diff --git a/js/xpconnect/src/XPCWrappedNativeInfo.cpp b/js/xpconnect/src/XPCWrappedNativeInfo.cpp index 0ee6778b0a6..cc96ed89c3f 100644 --- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp +++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp @@ -236,7 +236,7 @@ XPCNativeInterface::NewInstance(nsIInterfaceInfo* aInfo) bool mainProcessScriptableOnly; if (NS_FAILED(aInfo->IsMainProcessScriptableOnly(&mainProcessScriptableOnly))) return nullptr; - if (mainProcessScriptableOnly && XRE_GetProcessType() != GeckoProcessType_Default) { + if (mainProcessScriptableOnly && !XRE_IsParentProcess()) { nsCOMPtr console(do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (console) { char* intfNameChars; diff --git a/js/xpconnect/wrappers/AccessCheck.cpp b/js/xpconnect/wrappers/AccessCheck.cpp index cad16f9ce86..c1c2e90d2f4 100644 --- a/js/xpconnect/wrappers/AccessCheck.cpp +++ b/js/xpconnect/wrappers/AccessCheck.cpp @@ -228,7 +228,7 @@ AccessCheck::checkPassToPrivilegedCode(JSContext* cx, HandleObject wrapper, Hand // pass any objects at all to CPOWs. if (mozilla::jsipc::IsWrappedCPOW(obj) && js::GetObjectCompartment(wrapper) == js::GetObjectCompartment(xpc::UnprivilegedJunkScope()) && - XRE_GetProcessType() == GeckoProcessType_Default) + XRE_IsParentProcess()) { return true; } diff --git a/js/xpconnect/wrappers/WrapperFactory.cpp b/js/xpconnect/wrappers/WrapperFactory.cpp index c7717578ede..7d1e38efc0a 100644 --- a/js/xpconnect/wrappers/WrapperFactory.cpp +++ b/js/xpconnect/wrappers/WrapperFactory.cpp @@ -427,7 +427,7 @@ WrapperFactory::Rewrap(JSContext* cx, HandleObject existing, HandleObject obj) // here, but only in the content process. if ((IdentifyStandardInstance(obj) == JSProto_Function || (jsipc::IsCPOW(obj) && JS::IsCallable(obj) && - XRE_GetProcessType() == GeckoProcessType_Content))) + XRE_IsContentProcess()))) { wrapper = &FilteringWrapper::singleton; } diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 478554a8fe5..06adc6e8cbf 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1645,7 +1645,7 @@ already_AddRefed nsDisplayList::PaintRoot(nsDisplayListBuilder* aB // updates, so calculate that now before we call EndTransaction. if (rootPresContext && aBuilder->WillComputePluginGeometry() && - XRE_GetProcessType() == GeckoProcessType_Content) { + XRE_IsContentProcess()) { rootPresContext->ComputePluginGeometryUpdates(aBuilder->RootReferenceFrame(), aBuilder, this); rootPresContext->CollectPluginGeometryUpdates(layerManager); } diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index f24fc6bb498..3bf5cb24d65 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -3402,7 +3402,7 @@ nsLayoutUtils::PaintFrame(nsRenderingContext* aRenderingContext, nsIFrame* aFram // except requesting composition. Geometry updates were calculated and // shipped to the chrome process in nsDisplayList when the layer // transaction completed. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { rootPresContext->ComputePluginGeometryUpdates(aFrame, &builder, &list); // We're not going to get a WillPaintWindow event here if we didn't do // widget invalidation, so just apply the plugin geometry update here diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index b6f5fefaedb..04406f03e3d 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2860,7 +2860,7 @@ nsPresContext::IsCrossProcessRootContentDocument() return false; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { return true; } @@ -2996,7 +2996,7 @@ nsRootPresContext::ComputePluginGeometryUpdates(nsIFrame* aFrame, // This is not happening during a paint event. ApplyPluginGeometryUpdates(); #else - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { InitApplyPluginGeometryTimer(); } #endif diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 1e6c18e58db..b20ecc38438 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -4676,7 +4676,7 @@ PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags, // taking snapshots. if (layerManager && (!layerManager->AsClientLayerManager() || - XRE_GetProcessType() == GeckoProcessType_Default)) { + XRE_IsParentProcess())) { flags |= nsLayoutUtils::PAINT_WIDGET_LAYERS; } } @@ -5249,7 +5249,7 @@ void PresShell::UpdateCanvasBackground() if (!FrameConstructor()->GetRootElementFrame()) { mCanvasBackgroundColor = GetDefaultBackgroundColorToDraw(); } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { if (TabChild* tabChild = TabChild::GetFrom(this)) { tabChild->SetBackgroundColor(mCanvasBackgroundColor); } @@ -5954,7 +5954,7 @@ public: } ~AutoUpdateHitRegion() { - if (XRE_GetProcessType() != GeckoProcessType_Content || + if (!XRE_IsContentProcess() || !mFrame || !mShell) { return; } @@ -10788,7 +10788,7 @@ nsIPresShell::RecomputeFontSizeInflationEnabled() mFontSizeInflationEnabled = false; return; } - } else if (XRE_GetProcessType() == GeckoProcessType_Default) { + } else if (XRE_IsParentProcess()) { // We're in the master process. Cancel inflation if it's been // explicitly disabled. if (FontSizeInflationDisabledInMasterProcess()) { diff --git a/layout/base/nsStyleSheetService.cpp b/layout/base/nsStyleSheetService.cpp index a09405ba554..4bbdb40ab2e 100644 --- a/layout/base/nsStyleSheetService.cpp +++ b/layout/base/nsStyleSheetService.cpp @@ -101,7 +101,7 @@ nsStyleSheetService::Init() // SVGDocument::EnsureNonSVGUserAgentStyleSheetsLoaded should be updated too. // Child processes get their style sheets from the ContentParent. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return NS_OK; } @@ -156,7 +156,7 @@ nsStyleSheetService::LoadAndRegisterSheet(nsIURI *aSheetURI, serv->NotifyObservers(sheets[sheets.Count() - 1], message, nullptr); } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsTArray children; dom::ContentParent::GetAll(children); @@ -265,7 +265,7 @@ nsStyleSheetService::UnregisterSheet(nsIURI *aSheetURI, uint32_t aSheetType) if (serv) serv->NotifyObservers(sheet, message, nullptr); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsTArray children; dom::ContentParent::GetAll(children); diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 703c82d1c21..aedad8ac004 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1791,7 +1791,7 @@ nsListControlFrame::GetIndexFromDOMEvent(nsIDOMEvent* aMouseEvent, static bool FireShowDropDownEvent(nsIContent* aContent) { - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && Preferences::GetBool("browser.tabs.remote.desktopbehavior", false)) { nsContentUtils::DispatchChromeEvent(aContent->OwnerDoc(), aContent, NS_LITERAL_STRING("mozshowdropdown"), true, diff --git a/layout/generic/nsPluginFrame.cpp b/layout/generic/nsPluginFrame.cpp index 05599ba8db0..490bf22d053 100644 --- a/layout/generic/nsPluginFrame.cpp +++ b/layout/generic/nsPluginFrame.cpp @@ -416,7 +416,7 @@ nsPluginFrame::GetWidgetConfiguration(nsTArray* aConfi configuration->mBounds = mNextConfigurationBounds; configuration->mClipRegion = mNextConfigurationClipRegion; #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { configuration->mWindowID = (uintptr_t)mWidget->GetNativeData(NS_NATIVE_PLUGIN_PORT); configuration->mVisible = mWidget->IsVisible(); } @@ -768,7 +768,7 @@ mozilla::LayoutDeviceIntPoint nsPluginFrame::GetRemoteTabChromeOffset() { LayoutDeviceIntPoint offset; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsCOMPtr window = do_QueryInterface(GetContent()->OwnerDoc()->GetWindow()); if (window) { nsCOMPtr topWindow; diff --git a/layout/ipc/RenderFrameParent.cpp b/layout/ipc/RenderFrameParent.cpp index 17976d91016..ecbc7234994 100644 --- a/layout/ipc/RenderFrameParent.cpp +++ b/layout/ipc/RenderFrameParent.cpp @@ -311,7 +311,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, *aTextureFactoryIdentifier = TextureFactoryIdentifier(); } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Our remote frame will push layers updates to the compositor, // and we'll keep an indirect reference to that tree. *aId = mLayersId = CompositorParent::AllocateLayerTreeId(); @@ -324,7 +324,7 @@ RenderFrameParent::RenderFrameParent(nsFrameLoader* aFrameLoader, mContentController = new RemoteContentController(this); CompositorParent::SetControllerForLayerTree(mLayersId, mContentController); } - } else if (XRE_GetProcessType() == GeckoProcessType_Content) { + } else if (XRE_IsContentProcess()) { ContentChild::GetSingleton()->SendAllocateLayerTreeId(aId); mLayersId = *aId; CompositorChild::Get()->SendNotifyChildCreated(mLayersId); @@ -430,7 +430,7 @@ void RenderFrameParent::ActorDestroy(ActorDestroyReason why) { if (mLayersId != 0) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId); } else { CompositorParent::DeallocateLayerTreeId(mLayersId); diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp index a01befcd662..c1cee85bc18 100644 --- a/media/mtransport/nr_socket_prsock.cpp +++ b/media/mtransport/nr_socket_prsock.cpp @@ -1461,7 +1461,7 @@ int nr_socket_local_create(void *obj, nr_transport_addr *addr, nr_socket **sockp RefPtr sock; // create IPC bridge for content process - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { sock = new NrSocket(); } else { sock = new NrSocketIpc(); diff --git a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp index c1baeddbed3..847f4d4f5f9 100644 --- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp +++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp @@ -147,7 +147,7 @@ void ConfigWebRtcLog(uint32_t trace_mask, nsCString &aLogFile, nsCString &aAECLo } } #if !defined(MOZILLA_EXTERNAL_LINKAGE) - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // Capture the final choices for the trace settings. mozilla::Preferences::SetCString("media.webrtc.debug.log_file", aLogFile); mozilla::Preferences::SetCString("media.webrtc.debug.aec_log_dir", aAECLogDir); diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp index d3dae374f64..08e0b873141 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp @@ -326,7 +326,7 @@ nsresult PeerConnectionCtx::Initialize() { mTelemetryTimer->InitWithFuncCallback(EverySecondTelemetryCallback_m, this, 1000, nsITimer::TYPE_REPEATING_PRECISE_CAN_SKIP); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { WebrtcGlobalChild::Create(); } #endif // MOZILLA_INTERNAL_API diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 8075d3c340a..bae4fe6b536 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -262,7 +262,7 @@ static nsresult InitNSSInContent() { NS_ENSURE_TRUE(NS_IsMainThread(), NS_ERROR_NOT_SAME_THREAD); - if (XRE_GetProcessType() != GeckoProcessType_Content) { + if (!XRE_IsContentProcess()) { MOZ_ASSERT_UNREACHABLE("Must be called in content process"); return NS_ERROR_FAILURE; } @@ -595,7 +595,7 @@ PeerConnectionImpl::AddIceServer(const RTCIceServer &aServer, // Bug 1039655 - TURN TCP is not e10s ready if ((transport == kNrIceTransportTcp) && - (XRE_GetProcessType() != GeckoProcessType_Default)) { + (!XRE_IsParentProcess())) { continue; } @@ -643,7 +643,7 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, // Initialize NSS if we are in content process. For chrome process, NSS should already // been initialized. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // This code interferes with the C++ unit test startup code. nsCOMPtr nssDummy = do_GetService("@mozilla.org/psm;1", &res); NS_ENSURE_SUCCESS(res, res); diff --git a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp index cbae53243c3..28e36576165 100644 --- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp +++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp @@ -261,7 +261,7 @@ OnStatsReport_m(WebrtcGlobalChild* aThisChild, } // This is the last stats report to be collected. (Must be the gecko process). - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); StatsRequest* request = StatsRequest::Get(aRequestId); @@ -332,7 +332,7 @@ static void OnGetLogging_m(WebrtcGlobalChild* aThisChild, } // This is the last log to be collected. (Must be the gecko process). - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); LogRequest* request = LogRequest::Get(aRequestId); @@ -443,7 +443,7 @@ WebrtcGlobalInformation::GetAllStats( return; } - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // CallbackObject does not support threadsafe refcounting, and must be // destroyed on main. @@ -534,7 +534,7 @@ WebrtcGlobalInformation::GetLogging( return; } - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // CallbackObject does not support threadsafe refcounting, and must be // destroyed on main. diff --git a/modules/libjar/nsJARProtocolHandler.cpp b/modules/libjar/nsJARProtocolHandler.cpp index eb789ee6eff..971c577bbb1 100644 --- a/modules/libjar/nsJARProtocolHandler.cpp +++ b/modules/libjar/nsJARProtocolHandler.cpp @@ -32,7 +32,7 @@ static NS_DEFINE_CID(kZipReaderCacheCID, NS_ZIPREADERCACHE_CID); nsJARProtocolHandler *gJarHandler = nullptr; nsJARProtocolHandler::nsJARProtocolHandler() -: mIsMainProcess(XRE_GetProcessType() == GeckoProcessType_Default) +: mIsMainProcess(XRE_IsParentProcess()) { MOZ_ASSERT(NS_IsMainThread()); } diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 118eeb64b4e..c419985d562 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -50,7 +50,7 @@ #ifdef DEBUG #define ENSURE_MAIN_PROCESS(message, pref) do { \ - if (MOZ_UNLIKELY(XRE_GetProcessType() != GeckoProcessType_Default)) { \ + if (MOZ_UNLIKELY(!XRE_IsParentProcess())) { \ nsPrintfCString msg("ENSURE_MAIN_PROCESS failed. %s %s", message, pref); \ NS_WARNING(msg.get()); \ return NS_ERROR_NOT_AVAILABLE; \ @@ -58,7 +58,7 @@ } while (0); #else #define ENSURE_MAIN_PROCESS(message, pref) \ - if (MOZ_UNLIKELY(XRE_GetProcessType() != GeckoProcessType_Default)) { \ + if (MOZ_UNLIKELY(!XRE_IsParentProcess())) { \ return NS_ERROR_NOT_AVAILABLE; \ } #endif @@ -529,7 +529,7 @@ Preferences::Init() NS_ENSURE_SUCCESS(rv, rv); using mozilla::dom::ContentChild; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { InfallibleTArray prefs; ContentChild::GetSingleton()->SendReadPrefsArray(&prefs); @@ -580,7 +580,7 @@ NS_IMETHODIMP Preferences::Observe(nsISupports *aSubject, const char *aTopic, const char16_t *someData) { - if (XRE_GetProcessType() == GeckoProcessType_Content) + if (XRE_IsContentProcess()) return NS_ERROR_NOT_AVAILABLE; nsresult rv = NS_OK; @@ -605,7 +605,7 @@ Preferences::Observe(nsISupports *aSubject, const char *aTopic, NS_IMETHODIMP Preferences::ReadUserPrefs(nsIFile *aFile) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("cannot load prefs from content process"); return NS_ERROR_NOT_AVAILABLE; } @@ -635,7 +635,7 @@ Preferences::ReadUserPrefs(nsIFile *aFile) NS_IMETHODIMP Preferences::ResetPrefs() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("cannot reset prefs from content process"); return NS_ERROR_NOT_AVAILABLE; } @@ -651,7 +651,7 @@ Preferences::ResetPrefs() NS_IMETHODIMP Preferences::ResetUserPrefs() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("cannot reset user prefs from content process"); return NS_ERROR_NOT_AVAILABLE; } @@ -663,7 +663,7 @@ Preferences::ResetUserPrefs() NS_IMETHODIMP Preferences::SavePrefFile(nsIFile *aFile) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("cannot save pref file from content process"); return NS_ERROR_NOT_AVAILABLE; } diff --git a/modules/libpref/nsPrefBranch.cpp b/modules/libpref/nsPrefBranch.cpp index a14f68cf617..c72b328bcc7 100644 --- a/modules/libpref/nsPrefBranch.cpp +++ b/modules/libpref/nsPrefBranch.cpp @@ -62,7 +62,7 @@ using mozilla::dom::ContentChild; static ContentChild* GetContentChild() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); if (!cpc) { NS_RUNTIMEABORT("Content Protocol is NULL! We're going to crash!"); diff --git a/netwerk/base/nsBaseChannel.cpp b/netwerk/base/nsBaseChannel.cpp index 7baffeedf73..c1f5afe3376 100644 --- a/netwerk/base/nsBaseChannel.cpp +++ b/netwerk/base/nsBaseChannel.cpp @@ -279,7 +279,7 @@ nsBaseChannel::ClassifyURI() { // For channels created in the child process, delegate to the parent to // classify URIs. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } diff --git a/netwerk/base/nsChannelClassifier.cpp b/netwerk/base/nsChannelClassifier.cpp index 8830accd000..98edfdf7a86 100644 --- a/netwerk/base/nsChannelClassifier.cpp +++ b/netwerk/base/nsChannelClassifier.cpp @@ -59,7 +59,7 @@ nsChannelClassifier::ShouldEnableTrackingProtection(nsIChannel *aChannel, bool *result) { // Should only be called in the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); NS_ENSURE_ARG(result); *result = false; @@ -256,7 +256,7 @@ nsresult nsChannelClassifier::StartInternal() { // Should only be called in the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // Don't bother to run the classifier on a load that has already failed. // (this might happen after a redirect) @@ -369,7 +369,7 @@ void nsChannelClassifier::MarkEntryClassified(nsresult status) { // Should only be called in the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); // Don't cache tracking classifications because we support allowlisting. if (status == NS_ERROR_TRACKING_URI || mIsAllowListed) { @@ -401,7 +401,7 @@ bool nsChannelClassifier::HasBeenClassified(nsIChannel *aChannel) { // Should only be called in the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsCOMPtr cachingChannel = do_QueryInterface(aChannel); @@ -499,7 +499,7 @@ NS_IMETHODIMP nsChannelClassifier::OnClassifyComplete(nsresult aErrorCode) { // Should only be called in the parent process. - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); LOG(("nsChannelClassifier[%p]:OnClassifyComplete %d", this, aErrorCode)); if (mSuspendedChannel) { diff --git a/netwerk/base/nsFileStreams.cpp b/netwerk/base/nsFileStreams.cpp index 6dfbd481788..0f8107fd144 100644 --- a/netwerk/base/nsFileStreams.cpp +++ b/netwerk/base/nsFileStreams.cpp @@ -622,7 +622,7 @@ nsFileInputStream::Deserialize(const InputStreamParams& aParams, mBehaviorFlags = params.behaviorFlags(); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // A child process shouldn't close when it reads the end because it will // not be able to reopen the file later. mBehaviorFlags &= ~nsIFileInputStream::CLOSE_ON_EOF; diff --git a/netwerk/base/nsIOService.cpp b/netwerk/base/nsIOService.cpp index 692b4c97a21..4a570829b76 100644 --- a/netwerk/base/nsIOService.cpp +++ b/netwerk/base/nsIOService.cpp @@ -282,7 +282,7 @@ nsIOService::InitializeNetworkLinkService() } // go into managed mode if we can, and chrome process - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) { mNetworkLinkService = do_GetService(NS_NETWORK_LINK_SERVICE_CONTRACTID, &rv); } @@ -908,7 +908,7 @@ nsIOService::SetOffline(bool offline) NS_ASSERTION(observerService, "The observer service should not be null"); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { if (observerService) { (void)observerService->NotifyObservers(nullptr, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC, offline ? @@ -997,7 +997,7 @@ nsIOService::SetConnectivity(bool aConnectivity) { // This should only be called from ContentChild to pass the connectivity // value from the chrome process to the content process. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { return NS_ERROR_NOT_AVAILABLE; } return SetConnectivityInternal(aConnectivity); @@ -1019,7 +1019,7 @@ nsIOService::SetConnectivityInternal(bool aConnectivity) return NS_OK; } // This notification sends the connectivity to the child processes - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { observerService->NotifyObservers(nullptr, NS_IPC_IOSERVICE_SET_CONNECTIVITY_TOPIC, aConnectivity ? MOZ_UTF16("true") : diff --git a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp index ac1c3151949..f6c1d6185b8 100644 --- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp +++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp @@ -26,7 +26,7 @@ StartService() property_set("ctl.start", "mdnsd"); } -void +inline void StopService() { char value[PROPERTY_VALUE_MAX] = { '\0' }; diff --git a/netwerk/ipc/NeckoCommon.h b/netwerk/ipc/NeckoCommon.h index 81ff7c4f16d..8875f0f3054 100644 --- a/netwerk/ipc/NeckoCommon.h +++ b/netwerk/ipc/NeckoCommon.h @@ -94,7 +94,7 @@ IsNeckoChild() // TODO: Remove eventually when no longer supported (bug 571126) const char * e = PR_GetEnv("NECKO_SEPARATE_STACKS"); if (!e) - amChild = (XRE_GetProcessType() == GeckoProcessType_Content); + amChild = XRE_IsContentProcess(); didCheck = true; } return amChild; diff --git a/netwerk/ipc/NeckoParent.cpp b/netwerk/ipc/NeckoParent.cpp index 428fb7d19bb..469b120d807 100644 --- a/netwerk/ipc/NeckoParent.cpp +++ b/netwerk/ipc/NeckoParent.cpp @@ -799,7 +799,7 @@ NeckoParent::NestedFrameAuthPrompt::AsyncPromptAuth( nsIAuthInformation* aInfo, nsICancelable**) { static uint64_t callbackId = 0; - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default); + MOZ_ASSERT(XRE_IsParentProcess()); nsCOMPtr uri; nsresult rv = aChannel->GetURI(getter_AddRefs(uri)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/netwerk/protocol/app/AppProtocolHandler.cpp b/netwerk/protocol/app/AppProtocolHandler.cpp index 750b4153dbf..86499150994 100644 --- a/netwerk/protocol/app/AppProtocolHandler.cpp +++ b/netwerk/protocol/app/AppProtocolHandler.cpp @@ -446,7 +446,7 @@ AppProtocolHandler::NewChannel2(nsIURI* aUri, } bool noRemote = (appInfo->mIsCoreApp || - XRE_GetProcessType() == GeckoProcessType_Default); + XRE_IsParentProcess()); // In-parent and CoreApps can directly access files, so use jar:file:// nsAutoCString jarSpec(noRemote ? "jar:file://" diff --git a/netwerk/protocol/data/nsDataHandler.cpp b/netwerk/protocol/data/nsDataHandler.cpp index 02b3623617c..3318d8a1413 100644 --- a/netwerk/protocol/data/nsDataHandler.cpp +++ b/netwerk/protocol/data/nsDataHandler.cpp @@ -110,7 +110,7 @@ nsDataHandler::NewChannel2(nsIURI* uri, { NS_ENSURE_ARG_POINTER(uri); nsDataChannel* channel; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { channel = new nsDataChannel(uri); } else { channel = new mozilla::net::DataChannelChild(uri); diff --git a/netwerk/protocol/device/AndroidCaptureProvider.cpp b/netwerk/protocol/device/AndroidCaptureProvider.cpp index cb7ab76b658..7bd6846b4b3 100644 --- a/netwerk/protocol/device/AndroidCaptureProvider.cpp +++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp @@ -38,7 +38,7 @@ AndroidCameraInputStream::~AndroidCameraInputStream() { NS_IMETHODIMP AndroidCameraInputStream::Init(nsACString& aContentType, nsCaptureParams* aParams) { - if (XRE_GetProcessType() != GeckoProcessType_Default) + if (!XRE_IsParentProcess()) return NS_ERROR_NOT_IMPLEMENTED; mContentType = aContentType; diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index cd85b7381ff..d4b38181452 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -1538,7 +1538,7 @@ HttpBaseChannel::RedirectTo(nsIURI *newURI) NS_IMETHODIMP HttpBaseChannel::ContinueBeginConnect() { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default, + MOZ_ASSERT(!XRE_IsParentProcess(), "The parent overrides this"); MOZ_ASSERT(false, "This method must be overridden"); return NS_ERROR_NOT_IMPLEMENTED; @@ -2192,7 +2192,7 @@ HttpBaseChannel::AddCookiesToRequest() } bool useCookieService = - (XRE_GetProcessType() == GeckoProcessType_Default); + (XRE_IsParentProcess()); nsXPIDLCString cookie; if (useCookieService) { nsICookieService *cs = gHttpHandler->GetCookieService(); diff --git a/netwerk/protocol/http/HttpChannelParent.cpp b/netwerk/protocol/http/HttpChannelParent.cpp index c942b985c37..17281bd17cc 100644 --- a/netwerk/protocol/http/HttpChannelParent.cpp +++ b/netwerk/protocol/http/HttpChannelParent.cpp @@ -227,7 +227,7 @@ HttpChannelParent::GetInterface(const nsIID& aIID, void **result) } // Only support nsIAuthPromptProvider in Content process - if (XRE_GetProcessType() == GeckoProcessType_Default && + if (XRE_IsParentProcess() && aIID.Equals(NS_GET_IID(nsIAuthPromptProvider))) { *result = nullptr; return NS_OK; diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index f233dd5f21f..6d535430794 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -947,7 +947,7 @@ nsHtml5StreamParser::OnStartRequest(nsIRequest* aRequest, nsISupports* aContext) if (NS_FAILED(rv)) { // for now skip warning if we're on child process, since we don't support // off-main thread delivery there yet. This will change with bug 1015466 - if (XRE_GetProcessType() != GeckoProcessType_Content) { + if (!XRE_IsContentProcess()) { NS_WARNING("Failed to retarget HTML data delivery to the parser thread."); } } diff --git a/security/manager/ssl/PSMContentListener.cpp b/security/manager/ssl/PSMContentListener.cpp index ddbd8d852fe..77a909b62a9 100644 --- a/security/manager/ssl/PSMContentListener.cpp +++ b/security/manager/ssl/PSMContentListener.cpp @@ -402,7 +402,7 @@ PSMContentListener::DoContent(const nsACString& aContentType, } if (type != UNKNOWN_TYPE) { nsCOMPtr downloader; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { downloader = new PSMContentStreamListener(type); } else { downloader = static_cast( diff --git a/security/manager/ssl/TransportSecurityInfo.cpp b/security/manager/ssl/TransportSecurityInfo.cpp index e9eb55108ee..1a275ff1c25 100644 --- a/security/manager/ssl/TransportSecurityInfo.cpp +++ b/security/manager/ssl/TransportSecurityInfo.cpp @@ -239,7 +239,7 @@ TransportSecurityInfo::formatErrorMessage(MutexAutoLock const & proofOfLock, return NS_OK; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return NS_ERROR_UNEXPECTED; } diff --git a/security/manager/ssl/nsNSSComponent.cpp b/security/manager/ssl/nsNSSComponent.cpp index 4625002a946..56ae9c6e671 100644 --- a/security/manager/ssl/nsNSSComponent.cpp +++ b/security/manager/ssl/nsNSSComponent.cpp @@ -70,7 +70,7 @@ bool nsPSMInitPanic::isPanic = false; bool EnsureNSSInitializedChromeOrContent() { nsresult rv; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCOMPtr nss = do_GetService(PSM_COMPONENT_CONTRACTID, &rv); if (NS_FAILED(rv)) { return false; diff --git a/security/manager/ssl/nsSiteSecurityService.cpp b/security/manager/ssl/nsSiteSecurityService.cpp index 309e62bd53f..7737cda5695 100644 --- a/security/manager/ssl/nsSiteSecurityService.cpp +++ b/security/manager/ssl/nsSiteSecurityService.cpp @@ -228,7 +228,7 @@ nsresult nsSiteSecurityService::Init() { // Child processes are not allowed direct access to this. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { MOZ_CRASH("Child process: no direct access to nsSiteSecurityService"); } diff --git a/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h b/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h index 8599cfd9e6b..5ce5689bde6 100644 --- a/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h +++ b/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h @@ -123,7 +123,7 @@ InitLoggingIfRequired() #if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_STACKWALKING) // We can only log the stack trace on process types where we know that the // sandbox won't prevent it. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { Preferences::AddUintVarCache(&sStackTraceDepth, "security.sandbox.windows.log.stackTraceDepth"); } diff --git a/startupcache/StartupCache.cpp b/startupcache/StartupCache.cpp index a9fa3d9a202..c95f6d6d956 100644 --- a/startupcache/StartupCache.cpp +++ b/startupcache/StartupCache.cpp @@ -87,7 +87,7 @@ StartupCache* StartupCache::GetSingleton() { if (!gStartupCache) { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } #ifdef MOZ_DISABLE_STARTUPCACHE diff --git a/storage/VacuumManager.cpp b/storage/VacuumManager.cpp index 590e6ecb20f..dfd3428c12d 100644 --- a/storage/VacuumManager.cpp +++ b/storage/VacuumManager.cpp @@ -315,7 +315,7 @@ VacuumManager * VacuumManager::getSingleton() { //Don't allocate it in the child Process. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/toolkit/components/alerts/nsAlertsService.cpp b/toolkit/components/alerts/nsAlertsService.cpp index f494b0cf166..354d4cdbd5d 100644 --- a/toolkit/components/alerts/nsAlertsService.cpp +++ b/toolkit/components/alerts/nsAlertsService.cpp @@ -72,7 +72,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl nsIPrincipal * aPrincipal, bool aInPrivateBrowsing) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); if (aAlertListener) @@ -128,7 +128,7 @@ NS_IMETHODIMP nsAlertsService::ShowAlertNotification(const nsAString & aImageUrl NS_IMETHODIMP nsAlertsService::CloseAlert(const nsAString& aAlertName, nsIPrincipal* aPrincipal) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cpc = ContentChild::GetSingleton(); cpc->SendCloseAlert(nsAutoString(aAlertName), IPC::Principal(aPrincipal)); return NS_OK; diff --git a/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp b/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp index 6f0a8a7066c..cb2b090e281 100644 --- a/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp +++ b/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp @@ -37,7 +37,7 @@ DiskSpaceWatcher::~DiskSpaceWatcher() already_AddRefed DiskSpaceWatcher::FactoryCreate() { - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return nullptr; } diff --git a/toolkit/components/places/Database.cpp b/toolkit/components/places/Database.cpp index b5ea3a3154b..ac04e9516bc 100644 --- a/toolkit/components/places/Database.cpp +++ b/toolkit/components/places/Database.cpp @@ -581,7 +581,7 @@ Database::Database() , mClosed(false) , mConnectionShutdown(new DatabaseShutdown(this)) { - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Content, + MOZ_ASSERT(!XRE_IsContentProcess(), "Cannot instantiate Places in the content process"); // Attempting to create two instances of the service? MOZ_ASSERT(!gDatabase); diff --git a/toolkit/components/places/History.cpp b/toolkit/components/places/History.cpp index f042f259118..e84342a9e05 100644 --- a/toolkit/components/places/History.cpp +++ b/toolkit/components/places/History.cpp @@ -479,7 +479,7 @@ public: // If we are a content process, always remote the request to the // parent process. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { URIParams uri; SerializeURI(aURI, uri); @@ -1999,7 +1999,7 @@ History::NotifyVisited(nsIURI* aURI) nsAutoScriptBlocker scriptBlocker; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsTArray cplist; ContentParent::GetAll(cplist); @@ -2434,7 +2434,7 @@ History::VisitURI(nsIURI* aURI, return NS_OK; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { URIParams uri; SerializeURI(aURI, uri); @@ -2551,7 +2551,7 @@ History::RegisterVisitedCallback(nsIURI* aURI, Link* aLink) { NS_ASSERTION(aURI, "Must pass a non-null URI!"); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_PRECONDITION(aLink, "Must pass a non-null Link!"); } @@ -2586,7 +2586,7 @@ History::RegisterVisitedCallback(nsIURI* aURI, // ContentParent::RecvStartVisitedQuery. All of our code after this point // assumes aLink is non-nullptr, so we have to return now. else if (!aLink) { - NS_ASSERTION(XRE_GetProcessType() == GeckoProcessType_Default, + NS_ASSERTION(XRE_IsParentProcess(), "We should only ever get a null Link in the default process!"); return NS_OK; } @@ -2641,7 +2641,7 @@ History::SetURITitle(nsIURI* aURI, const nsAString& aTitle) return NS_OK; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { URIParams uri; SerializeURI(aURI, uri); @@ -2700,7 +2700,7 @@ History::AddDownload(nsIURI* aSource, nsIURI* aReferrer, return NS_OK; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("Cannot add downloads to history from content process!"); return NS_ERROR_NOT_AVAILABLE; } @@ -2756,7 +2756,7 @@ History::RemoveAllDownloads() return NS_OK; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_ERROR("Cannot remove downloads to history from content process!"); return NS_ERROR_NOT_AVAILABLE; } diff --git a/toolkit/components/satchel/nsFormFillController.cpp b/toolkit/components/satchel/nsFormFillController.cpp index 69757ae2f0f..bd492956864 100644 --- a/toolkit/components/satchel/nsFormFillController.cpp +++ b/toolkit/components/satchel/nsFormFillController.cpp @@ -739,7 +739,7 @@ void nsFormFillController::RevalidateDataList() return; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { nsCOMPtr controller(do_QueryInterface(mLastListener)); if (!controller) { return; diff --git a/toolkit/components/telemetry/Telemetry.cpp b/toolkit/components/telemetry/Telemetry.cpp index 259b8a80d2d..88b654d935f 100644 --- a/toolkit/components/telemetry/Telemetry.cpp +++ b/toolkit/components/telemetry/Telemetry.cpp @@ -1848,10 +1848,8 @@ TelemetryImpl::AsyncFetchTelemetryData(nsIFetchTelemetryDataCallback *aCallback) TelemetryImpl::TelemetryImpl(): mHistogramMap(Telemetry::HistogramCount), -mCanRecordBase(XRE_GetProcessType() == GeckoProcessType_Default || - XRE_GetProcessType() == GeckoProcessType_Content), -mCanRecordExtended(XRE_GetProcessType() == GeckoProcessType_Default || - XRE_GetProcessType() == GeckoProcessType_Content), +mCanRecordBase(XRE_IsParentProcess() || XRE_IsContentProcess()), +mCanRecordExtended(XRE_IsParentProcess() || XRE_IsContentProcess()), mHashMutex("Telemetry::mHashMutex"), mHangReportsMutex("Telemetry::mHangReportsMutex"), mThreadHangStatsMutex("Telemetry::mThreadHangStatsMutex"), diff --git a/toolkit/crashreporter/nsExceptionHandler.cpp b/toolkit/crashreporter/nsExceptionHandler.cpp index 827240da46f..bf1b5cf659f 100644 --- a/toolkit/crashreporter/nsExceptionHandler.cpp +++ b/toolkit/crashreporter/nsExceptionHandler.cpp @@ -1774,7 +1774,7 @@ nsresult AnnotateCrashReport(const nsACString& key, const nsACString& data) if (NS_FAILED(rv)) return rv; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { if (!NS_IsMainThread()) { NS_ERROR("Cannot call AnnotateCrashReport in child processes from non-main thread."); return NS_ERROR_FAILURE; @@ -1829,7 +1829,7 @@ nsresult AppendAppNotesToCrashReport(const nsACString& data) if (DoFindInReadable(data, NS_LITERAL_CSTRING("\0"))) return NS_ERROR_INVALID_ARG; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { if (!NS_IsMainThread()) { NS_ERROR("Cannot call AnnotateCrashReport in child processes from non-main thread."); return NS_ERROR_FAILURE; diff --git a/toolkit/mozapps/extensions/AddonPathService.cpp b/toolkit/mozapps/extensions/AddonPathService.cpp index 3681de016be..adc44e2bc50 100644 --- a/toolkit/mozapps/extensions/AddonPathService.cpp +++ b/toolkit/mozapps/extensions/AddonPathService.cpp @@ -193,7 +193,7 @@ ResolveURI(nsIURI* aURI, nsAString& out) JSAddonId* MapURIToAddonID(nsIURI* aURI) { - if (!NS_IsMainThread() || XRE_GetProcessType() != GeckoProcessType_Default) { + if (!NS_IsMainThread() || !XRE_IsParentProcess()) { return nullptr; } diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 03b8945d127..d1d63396aed 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -798,7 +798,7 @@ NS_INTERFACE_MAP_BEGIN(nsXULAppInfo) NS_INTERFACE_MAP_ENTRY(nsIFinishDumpingCallback) #endif NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsIXULAppInfo, gAppData || - XRE_GetProcessType() == GeckoProcessType_Content) + XRE_IsContentProcess()) NS_INTERFACE_MAP_END NS_IMETHODIMP_(MozExternalRefCountType) @@ -816,7 +816,7 @@ nsXULAppInfo::Release() NS_IMETHODIMP nsXULAppInfo::GetVendor(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().vendor; return NS_OK; @@ -829,7 +829,7 @@ nsXULAppInfo::GetVendor(nsACString& aResult) NS_IMETHODIMP nsXULAppInfo::GetName(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().name; return NS_OK; @@ -842,7 +842,7 @@ nsXULAppInfo::GetName(nsACString& aResult) NS_IMETHODIMP nsXULAppInfo::GetID(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().ID; return NS_OK; @@ -855,7 +855,7 @@ nsXULAppInfo::GetID(nsACString& aResult) NS_IMETHODIMP nsXULAppInfo::GetVersion(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().version; return NS_OK; @@ -876,7 +876,7 @@ nsXULAppInfo::GetPlatformVersion(nsACString& aResult) NS_IMETHODIMP nsXULAppInfo::GetAppBuildID(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().buildID; return NS_OK; @@ -897,7 +897,7 @@ nsXULAppInfo::GetPlatformBuildID(nsACString& aResult) NS_IMETHODIMP nsXULAppInfo::GetUAName(nsACString& aResult) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { ContentChild* cc = ContentChild::GetSingleton(); aResult = cc->GetAppInfo().UAName; return NS_OK; @@ -1059,7 +1059,7 @@ nsXULAppInfo::GetIs64Bit(bool* aResult) NS_IMETHODIMP nsXULAppInfo::EnsureContentProcess() { - if (XRE_GetProcessType() != GeckoProcessType_Default) + if (!XRE_IsParentProcess()) return NS_ERROR_NOT_AVAILABLE; nsRefPtr unused = ContentParent::GetNewOrUsedBrowserProcess(); @@ -4535,6 +4535,12 @@ XRE_IsParentProcess() return XRE_GetProcessType() == GeckoProcessType_Default; } +bool +XRE_IsContentProcess() +{ + return XRE_GetProcessType() == GeckoProcessType_Content; +} + #ifdef E10S_TESTING_ONLY static void LogE10sBlockedReason(const char *reason) { diff --git a/toolkit/xre/nsSigHandlers.cpp b/toolkit/xre/nsSigHandlers.cpp index 56fa380c91d..9d5d28ff005 100644 --- a/toolkit/xre/nsSigHandlers.cpp +++ b/toolkit/xre/nsSigHandlers.cpp @@ -259,7 +259,7 @@ void InstallSignalHandlers(const char *ProgramName) sigaction(SIGFPE, &sa, &osa); #endif - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { /* * If the user is debugging a Gecko parent process in gdb and hits ^C to * suspend, a SIGINT signal will be sent to the child. We ignore this signal diff --git a/tools/profiler/ProfileEntry.cpp b/tools/profiler/ProfileEntry.cpp index 1204a29ab43..bc7892cff31 100644 --- a/tools/profiler/ProfileEntry.cpp +++ b/tools/profiler/ProfileEntry.cpp @@ -1013,7 +1013,7 @@ void ThreadProfile::StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, doubl if (XRE_GetProcessType() == GeckoProcessType_Plugin) { // TODO Add the proper plugin name aWriter.StringProperty("name", "Plugin"); - } else if (XRE_GetProcessType() == GeckoProcessType_Content) { + } else if (XRE_IsContentProcess()) { // This isn't going to really help once we have multiple content // processes, but it'll do for now. aWriter.StringProperty("name", "Content"); diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index cd4831b49a3..7fd0e7090a4 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -685,7 +685,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte nsIInterfaceRequestor *aWindowContext, nsIStreamListener ** aStreamListener) { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return DoContentContentProcessHelper(aMimeContentType, aRequest, aContentContext, aForceSave, aWindowContext, aStreamListener); } @@ -941,7 +941,7 @@ nsExternalHelperAppService::LoadURI(nsIURI *aURI, { NS_ENSURE_ARG_POINTER(aURI); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { URIParams uri; SerializeURI(aURI, uri); @@ -1245,7 +1245,7 @@ nsExternalAppHandler::~nsExternalAppHandler() void nsExternalAppHandler::DidDivertRequest(nsIRequest *request) { - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content, "in child process"); + MOZ_ASSERT(XRE_IsContentProcess(), "in child process"); // Remove our request from the child loadGroup RetargetLoadNotifications(request); MaybeCloseWindow(); @@ -1599,7 +1599,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo // At this point, the child process has done everything it can usefully do // for OnStartRequest. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return NS_OK; } @@ -1838,7 +1838,7 @@ void nsExternalAppHandler::SendStatusChange(ErrorType type, nsresult rv, nsIRequ mDialogProgressListener->OnStatusChange(nullptr, (type == kReadError) ? aRequest : nullptr, rv, msgText); } else if (mTransfer) { mTransfer->OnStatusChange(nullptr, (type == kReadError) ? aRequest : nullptr, rv, msgText); - } else if (XRE_GetProcessType() == GeckoProcessType_Default) { + } else if (XRE_IsParentProcess()) { // We don't have a listener. Simply show the alert ourselves. nsresult qiRv; nsCOMPtr prompter(do_GetInterface(GetDialogParent(), &qiRv)); diff --git a/widget/GfxInfoBase.cpp b/widget/GfxInfoBase.cpp index a42627c9eaa..cf3e28b9570 100644 --- a/widget/GfxInfoBase.cpp +++ b/widget/GfxInfoBase.cpp @@ -682,7 +682,7 @@ GfxInfoBase::GetFeatureStatus(int32_t aFeature, int32_t* aStatus) if (GetPrefValueForFeature(aFeature, *aStatus)) return NS_OK; - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { // Delegate to the parent process. mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); bool success; diff --git a/widget/PuppetWidget.cpp b/widget/PuppetWidget.cpp index 22afe9fbd55..efdfb0beb2c 100644 --- a/widget/PuppetWidget.cpp +++ b/widget/PuppetWidget.cpp @@ -988,7 +988,7 @@ PuppetWidget::MemoryPressureObserver::Observe(nsISupports* aSubject, if (strcmp("memory-pressure", aTopic) == 0) { if (!mWidget->mVisible && mWidget->mLayerManager && - XRE_GetProcessType() == GeckoProcessType_Content) { + XRE_IsContentProcess()) { mWidget->mLayerManager->ClearCachedResources(); } } @@ -1009,7 +1009,7 @@ bool PuppetWidget::NeedsPaint() { // e10s popups are handled by the parent process, so never should be painted here - if (XRE_GetProcessType() == GeckoProcessType_Content && + if (XRE_IsContentProcess() && Preferences::GetBool("browser.tabs.remote.desktopbehavior", false) && mWindowType == eWindowType_popup) { NS_WARNING("Trying to paint an e10s popup in the child process!"); diff --git a/widget/android/nsAppShell.cpp b/widget/android/nsAppShell.cpp index 325f38ebfc1..0fe1dbaf2a2 100644 --- a/widget/android/nsAppShell.cpp +++ b/widget/android/nsAppShell.cpp @@ -133,7 +133,7 @@ nsAppShell::nsAppShell() { gAppShell = this; - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return; } diff --git a/widget/android/nsLookAndFeel.cpp b/widget/android/nsLookAndFeel.cpp index 6e361c6a99e..908a77e87ca 100644 --- a/widget/android/nsLookAndFeel.cpp +++ b/widget/android/nsLookAndFeel.cpp @@ -87,7 +87,7 @@ nsLookAndFeel::NativeGetColor(ColorID aID, nscolor &aColor) nsresult rv = NS_OK; if (!mInitializedSystemColors) { - if (XRE_GetProcessType() == GeckoProcessType_Default) + if (XRE_IsParentProcess()) rv = GetSystemColors(); else rv = CallRemoteGetSystemColors(); @@ -469,7 +469,7 @@ bool nsLookAndFeel::GetEchoPasswordImpl() { if (!mInitializedShowPassword) { - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mShowPassword = widget::GeckoAppShell::GetShowPasswordSetting(); } else { ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword); diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index e3c7d7f4744..1225ab05e81 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -785,7 +785,7 @@ nsWindow::OnGlobalAndroidEvent(AndroidGeckoEvent *ae) gAndroidScreenBounds.width = newScreenWidth; gAndroidScreenBounds.height = newScreenHeight; - if (XRE_GetProcessType() != GeckoProcessType_Default && + if (!XRE_IsParentProcess() && !Preferences::GetBool("browser.tabs.remote.desktopbehavior", false)) { break; } @@ -931,7 +931,7 @@ nsWindow::InitEvent(WidgetGUIEvent& event, nsIntPoint* aPoint) gfxIntSize nsWindow::GetAndroidScreenBounds() { - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { return ContentChild::GetSingleton()->GetScreenSize(); } return gAndroidScreenBounds; diff --git a/widget/cocoa/nsLookAndFeel.mm b/widget/cocoa/nsLookAndFeel.mm index bac6106d68f..c4bceb53fe6 100644 --- a/widget/cocoa/nsLookAndFeel.mm +++ b/widget/cocoa/nsLookAndFeel.mm @@ -690,7 +690,7 @@ nsLookAndFeel::RefreshImpl() // We should only clear the cache if we're in the main browser process. // Otherwise, we should wait for the parent to inform us of new values // to cache via LookAndFeel::SetIntCache. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mUseOverlayScrollbarsCached = false; mAllowOverlayScrollbarsOverlapCached = false; } diff --git a/widget/gonk/nsAppShell.cpp b/widget/gonk/nsAppShell.cpp index 19ef7f8adf5..d2c878e2cb4 100644 --- a/widget/gonk/nsAppShell.cpp +++ b/widget/gonk/nsAppShell.cpp @@ -884,7 +884,7 @@ nsAppShell::Init() InitGonkMemoryPressureMonitoring(); - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { printf("*****************************************************************\n"); printf("***\n"); printf("*** This is stdout. Most of the useful output will be in logcat.\n"); diff --git a/widget/gonk/nsClipboard.cpp b/widget/gonk/nsClipboard.cpp index 2aae6df49bf..6b8f820fbe7 100644 --- a/widget/gonk/nsClipboard.cpp +++ b/widget/gonk/nsClipboard.cpp @@ -31,7 +31,7 @@ nsClipboard::SetData(nsITransferable *aTransferable, return NS_ERROR_NOT_IMPLEMENTED; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Re-direct to the clipboard proxy. nsRefPtr clipboardProxy = new nsClipboardProxy(); return clipboardProxy->SetData(aTransferable, anOwner, aWhichClipboard); @@ -64,7 +64,7 @@ nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard) return NS_ERROR_NOT_IMPLEMENTED; } - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // Re-direct to the clipboard proxy. nsRefPtr clipboardProxy = new nsClipboardProxy(); return clipboardProxy->GetData(aTransferable, aWhichClipboard); @@ -104,7 +104,7 @@ nsClipboard::EmptyClipboard(int32_t aWhichClipboard) if (aWhichClipboard != kGlobalClipboard) { return NS_ERROR_NOT_IMPLEMENTED; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mClipboard.Truncate(0); } else { ContentChild::GetSingleton()->SendEmptyClipboard(aWhichClipboard); @@ -122,7 +122,7 @@ nsClipboard::HasDataMatchingFlavors(const char **aFlavorList, if (aWhichClipboard != kGlobalClipboard) { return NS_ERROR_NOT_IMPLEMENTED; } - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { *aHasType = !mClipboard.IsEmpty(); } else { nsRefPtr clipboardProxy = new nsClipboardProxy(); diff --git a/widget/gonk/nsWidgetFactory.cpp b/widget/gonk/nsWidgetFactory.cpp index e11c918226f..ddd116f5662 100644 --- a/widget/gonk/nsWidgetFactory.cpp +++ b/widget/gonk/nsWidgetFactory.cpp @@ -72,7 +72,7 @@ NS_DEFINE_NAMED_CID(NS_CLIPBOARDHELPER_CID); static nsresult ScreenManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult) { - return (XRE_GetProcessType() == GeckoProcessType_Default) ? + return (XRE_IsParentProcess()) ? nsScreenManagerGonkConstructor(aOuter, aIID, aResult) : PuppetScreenManagerConstructor(aOuter, aIID, aResult); } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index 1e8355a2101..af153140a8c 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -2315,7 +2315,7 @@ public: static bool UsePuppetWidgets() { - return XRE_GetProcessType() == GeckoProcessType_Content; + return XRE_IsContentProcess(); } /** diff --git a/widget/nsIdleService.cpp b/widget/nsIdleService.cpp index 9f97f5c75f0..ae9b77cbefc 100644 --- a/widget/nsIdleService.cpp +++ b/widget/nsIdleService.cpp @@ -398,7 +398,7 @@ nsIdleService::nsIdleService() : mCurrentlySetToTimeoutAt(TimeStamp()), sLog = PR_NewLogModule("idleService"); MOZ_ASSERT(!gIdleService); gIdleService = this; - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mDailyIdle = new nsIdleServiceDaily(this); mDailyIdle->Init(); } @@ -425,7 +425,7 @@ nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS) // high either - no more than ~136 years. NS_ENSURE_ARG_RANGE(aIdleTimeInS, 1, (UINT32_MAX / 10) - 1); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* cpc = dom::ContentChild::GetSingleton(); cpc->AddIdleObserver(aObserver, aIdleTimeInS); return NS_OK; @@ -484,7 +484,7 @@ nsIdleService::RemoveIdleObserver(nsIObserver* aObserver, uint32_t aTimeInS) NS_ENSURE_ARG_POINTER(aObserver); NS_ENSURE_ARG(aTimeInS); - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { dom::ContentChild* cpc = dom::ContentChild::GetSingleton(); cpc->RemoveIdleObserver(aObserver, aTimeInS); return NS_OK; diff --git a/widget/nsXPLookAndFeel.cpp b/widget/nsXPLookAndFeel.cpp index d4f9ff9363f..43b83e73011 100644 --- a/widget/nsXPLookAndFeel.cpp +++ b/widget/nsXPLookAndFeel.cpp @@ -456,7 +456,7 @@ nsXPLookAndFeel::Init() sUseNativeColors = val; } - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton(); diff --git a/widget/windows/AudioSession.cpp b/widget/windows/AudioSession.cpp index 52f12d4256b..c69e5756956 100644 --- a/widget/windows/AudioSession.cpp +++ b/widget/windows/AudioSession.cpp @@ -193,10 +193,10 @@ AudioSession::Start() mState = FAILED; // XXXkhuey implement this for content processes - if (XRE_GetProcessType() == GeckoProcessType_Content) + if (XRE_IsContentProcess()) return NS_ERROR_FAILURE; - MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default, + MOZ_ASSERT(XRE_IsParentProcess(), "Should only get here in a chrome process!"); nsCOMPtr bundleService = @@ -315,7 +315,7 @@ AudioSession::Stop() nsRefPtr kungFuDeathGrip; kungFuDeathGrip.swap(sService); - if (XRE_GetProcessType() != GeckoProcessType_Content) + if (!XRE_IsContentProcess()) StopInternal(); // At this point kungFuDeathGrip should be the only reference to AudioSession @@ -362,7 +362,7 @@ AudioSession::SetSessionData(const nsID& aID, { MOZ_ASSERT(mState == UNINITIALIZED, "State invariants violated"); - MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default, + MOZ_ASSERT(!XRE_IsParentProcess(), "Should never get here in a chrome process!"); mState = CLONED; diff --git a/widget/windows/nsNativeThemeWin.cpp b/widget/windows/nsNativeThemeWin.cpp index b400b7e6199..df444bcb90e 100644 --- a/widget/windows/nsNativeThemeWin.cpp +++ b/widget/windows/nsNativeThemeWin.cpp @@ -66,7 +66,7 @@ GetTopLevelWindowActiveState(nsIFrame *aFrame) // Used by window frame and button box rendering. We can end up in here in // the content process when rendering one of these moz styles freely in a // page. Bail in this case, there is no applicable window focus state. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return mozilla::widget::themeconst::FS_INACTIVE; } // Get the widget. nsIFrame's GetNearestWidget walks up the view chain diff --git a/xpcom/base/nsDebugImpl.cpp b/xpcom/base/nsDebugImpl.cpp index 7d05954a344..c7d8fc87f35 100644 --- a/xpcom/base/nsDebugImpl.cpp +++ b/xpcom/base/nsDebugImpl.cpp @@ -406,7 +406,7 @@ NS_DebugBreak(uint32_t aSeverity, const char* aStr, const char* aExpr, // Updating crash annotations in the child causes us to do IPC. This can // really cause trouble if we're asserting from within IPC code. So we // have to do without the annotations in that case. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { nsCString note("xpcom_runtime_abort("); note += buf.buffer; note += ")"; diff --git a/xpcom/base/nsDumpUtils.cpp b/xpcom/base/nsDumpUtils.cpp index d463d705ee5..0007e8c3a8e 100644 --- a/xpcom/base/nsDumpUtils.cpp +++ b/xpcom/base/nsDumpUtils.cpp @@ -262,7 +262,7 @@ FifoWatcher::MaybeCreate() { MOZ_ASSERT(NS_IsMainThread()); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { // We want this to be main-process only, since two processes can't listen // to the same fifo. return false; diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index ec0be76d0d2..90561825fdd 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -484,7 +484,7 @@ public: // of the form "$PROCESS_NAME (pid $PID)", or just "(pid $PID)" if we // don't have a process name. If we're the main process, we let // $PROCESS_NAME be "Main Process". - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { // We're the main process. process.AssignLiteral("Main Process"); } else if (ContentChild* cc = ContentChild::GetSingleton()) { diff --git a/xpcom/base/nsTraceRefcnt.cpp b/xpcom/base/nsTraceRefcnt.cpp index f99e4af37b9..02a7e793961 100644 --- a/xpcom/base/nsTraceRefcnt.cpp +++ b/xpcom/base/nsTraceRefcnt.cpp @@ -642,7 +642,7 @@ InitLog(const char* aEnvVar, const char* aMsg, FILE** aResult) } else { FILE* stream; nsAutoCString fname(value); - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { bool hasLogExtension = fname.RFind(".log", true, -1, 4) == kNotFound ? false : true; if (hasLogExtension) { diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index e22afc5a250..3258c6ad60b 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -535,7 +535,7 @@ NS_InitXPCOM2(nsIServiceManager** aResult, sMessageLoop->set_hang_timeouts(128, 8192); } - if (XRE_GetProcessType() == GeckoProcessType_Default && + if (XRE_IsParentProcess() && !BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) { UniquePtr ioThread = MakeUnique(BrowserProcessSubThread::IO); @@ -733,7 +733,7 @@ NS_InitXPCOM2(nsIServiceManager** aResult, // We only want the SystemMemoryReporter running in one process, because it // profiles the entire system. The main process is the obvious place for // it. - if (XRE_GetProcessType() == GeckoProcessType_Default) { + if (XRE_IsParentProcess()) { mozilla::SystemMemoryReporter::Init(); } @@ -964,7 +964,7 @@ ShutdownXPCOM(nsIServiceManager* aServMgr) // On Windows XP debug, there are intermittent failures in // dom/media/tests/mochitest/test_peerConnection_basicH264Video.html // if we don't exit early in a child process. See bug 1073310. - if (XRE_GetProcessType() == GeckoProcessType_Content && !IsVistaOrLater()) { + if (XRE_IsContentProcess() && !IsVistaOrLater()) { NS_WARNING("Exiting child process early!"); exit(0); } @@ -1048,7 +1048,7 @@ ShutdownXPCOM(nsIServiceManager* aServMgr) // checking working on Linux. // On debug B2G, the child process crashes very late. Instead, just // give up so at least we exit cleanly. See bug 1071866. - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { NS_WARNING("Exiting child process early!"); exit(0); } diff --git a/xpcom/build/nsXULAppAPI.h b/xpcom/build/nsXULAppAPI.h index 8f2e50652c1..8b3c1be3637 100644 --- a/xpcom/build/nsXULAppAPI.h +++ b/xpcom/build/nsXULAppAPI.h @@ -407,6 +407,9 @@ XRE_API(GeckoProcessType, XRE_API(bool, XRE_IsParentProcess, ()) +XRE_API(bool, + XRE_IsContentProcess, ()) + typedef void (*MainFunction)(void* aData); XRE_API(nsresult, diff --git a/xpcom/components/ManifestParser.cpp b/xpcom/components/ManifestParser.cpp index 2341fa11b0a..55b8bb77e20 100644 --- a/xpcom/components/ManifestParser.cpp +++ b/xpcom/components/ManifestParser.cpp @@ -589,7 +589,7 @@ ParseManifest(NSLocationType aType, FileLocation& aFile, char* aBuf, } #endif - if (XRE_GetProcessType() == GeckoProcessType_Content) { + if (XRE_IsContentProcess()) { process = kContent; } else { process = kMain; diff --git a/xpcom/io/nsAnonymousTemporaryFile.cpp b/xpcom/io/nsAnonymousTemporaryFile.cpp index 76d395cd550..332d5a8f871 100644 --- a/xpcom/io/nsAnonymousTemporaryFile.cpp +++ b/xpcom/io/nsAnonymousTemporaryFile.cpp @@ -303,7 +303,7 @@ CreateAnonTempFileRemover() // is a shutdown observer. We only create the temp file remover if we're running // in the main process; there's no point in doing the temp file removal multiple // times per startup. - if (XRE_GetProcessType() != GeckoProcessType_Default) { + if (!XRE_IsParentProcess()) { return NS_OK; } nsRefPtr tempRemover = new nsAnonTempFileRemover(); diff --git a/xpcom/libxpcomrt/XPCOMRTStubs.cpp b/xpcom/libxpcomrt/XPCOMRTStubs.cpp index 09edcd7ad76..9b8dab6dfa2 100644 --- a/xpcom/libxpcomrt/XPCOMRTStubs.cpp +++ b/xpcom/libxpcomrt/XPCOMRTStubs.cpp @@ -14,6 +14,18 @@ XRE_GetProcessType() return GeckoProcessType_Default; } +bool +XRE_IsParentProcess() +{ + return XRE_GetProcessType() == GeckoProcessType_Default; +} + +bool +XRE_IsContentProcess() +{ + return XRE_GetProcessType() == GeckoProcessType_Content; +} + #define PRINT_CALLED fprintf(stderr, "!!! ERROR: function %s defined in file %s should not be called, needs to be correctly implemented.\n", __FUNCTION__, __FILE__) class nsAString; diff --git a/xpcom/threads/nsThread.cpp b/xpcom/threads/nsThread.cpp index acfd6cd3eba..58b67be14b8 100644 --- a/xpcom/threads/nsThread.cpp +++ b/xpcom/threads/nsThread.cpp @@ -702,7 +702,7 @@ public: static bool EventLatencyIsImportant() { - return NS_IsMainThread() && XRE_GetProcessType() == GeckoProcessType_Default; + return NS_IsMainThread() && XRE_IsParentProcess(); } };