--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1260,17 +1260,17 @@ nsAccessibilityService::Init()
for (uint32_t i = 0; i < ArrayLength(sMarkupMapList); i++)
mMarkupMaps.Put(*sMarkupMapList[i].tag, &sMarkupMapList[i]);
#ifdef A11Y_LOG
logging::CheckEnv();
#endif
- if (XRE_GetProcessType() == GeckoProcessType_Default)
+ if (XRE_IsParentProcess())
gApplicationAccessible = new ApplicationAccessibleWrap();
else
gApplicationAccessible = new ApplicationAccessible();
NS_ADDREF(gApplicationAccessible); // will release in Shutdown()
#ifdef MOZ_CRASHREPORTER
CrashReporter::
@@ -1281,17 +1281,17 @@ nsAccessibilityService::Init()
#ifdef XP_WIN
sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >;
sPluginTimers = new nsTArray<nsCOMPtr<nsITimer> >;
#endif
gIsShutdown = false;
// Now its safe to start platform accessibility.
- if (XRE_GetProcessType() == GeckoProcessType_Default)
+ if (XRE_IsParentProcess())
PlatformInit();
return true;
}
void
nsAccessibilityService::Shutdown()
{
@@ -1324,17 +1324,17 @@ nsAccessibilityService::Shutdown()
// accessibility service as shutdown to prevent calls of its methods.
// Don't null accessibility service static member at this point to be safe
// if someone will try to operate with it.
NS_ASSERTION(!gIsShutdown, "Accessibility was shutdown already");
gIsShutdown = true;
- if (XRE_GetProcessType() == GeckoProcessType_Default)
+ if (XRE_IsParentProcess())
PlatformShutdown();
gApplicationAccessible->Shutdown();
NS_RELEASE(gApplicationAccessible);
gApplicationAccessible = nullptr;
NS_IF_RELEASE(gXPCApplicationAccessible);
gXPCApplicationAccessible = nullptr;
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -277,17 +277,17 @@ GetAccService()
* Return true if we're in a content process and not B2G.
*/
inline bool
IPCAccessibilityActive()
{
#ifdef MOZ_B2G
return false;
#else
- return XRE_GetProcessType() == GeckoProcessType_Content &&
+ return XRE_IsContentProcess() &&
mozilla::Preferences::GetBool("accessibility.ipc_architecture.enabled", true);
#endif
}
/**
* Map nsIAccessibleEvents constants to strings. Used by
* nsIAccessibleRetrieval::getStringEventType() method.
*/
--- a/accessible/base/nsCoreUtils.cpp
+++ b/accessible/base/nsCoreUtils.cpp
@@ -420,17 +420,17 @@ bool
nsCoreUtils::IsTabDocument(nsIDocument* aDocumentNode)
{
nsCOMPtr<nsIDocShellTreeItem> treeItem(aDocumentNode->GetDocShell());
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
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.
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem));
return parentTreeItem == rootTreeItem;
}
--- a/accessible/windows/msaa/nsWinUtils.cpp
+++ b/accessible/windows/msaa/nsWinUtils.cpp
@@ -59,17 +59,17 @@ nsWinUtils::MaybeStartWindowEmulation()
{
// Register window class that'll be used for document accessibles associated
// with tabs.
if (IPCAccessibilityActive())
return false;
if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
Compatibility::IsDolphin() ||
- XRE_GetProcessType() == GeckoProcessType_Content) {
+ XRE_IsContentProcess()) {
RegisterNativeWindow(kClassNameTabContent);
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(2);
return true;
}
return false;
}
--- a/caps/DomainPolicy.cpp
+++ b/caps/DomainPolicy.cpp
@@ -17,17 +17,17 @@ using namespace ipc;
using namespace dom;
NS_IMPL_ISUPPORTS(DomainPolicy, nsIDomainPolicy)
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<ContentParent*> parents;
ContentParent::GetAll(parents);
if (!parents.Length()) {
return NS_OK;
}
@@ -40,17 +40,17 @@ BroadcastDomainSetChange(DomainSetType a
return NS_OK;
}
DomainPolicy::DomainPolicy() : mBlacklist(new DomainSet(BLACKLIST))
, mSuperBlacklist(new DomainSet(SUPER_BLACKLIST))
, mWhitelist(new DomainSet(WHITELIST))
, mSuperWhitelist(new DomainSet(SUPER_WHITELIST))
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
BroadcastDomainSetChange(NO_TYPE, ACTIVATE_POLICY);
}
}
DomainPolicy::~DomainPolicy()
{
// The SSM holds a strong ref to the DomainPolicy until Deactivate() is
// invoked, so we should never hit the destructor until that happens.
@@ -107,17 +107,17 @@ DomainPolicy::Deactivate()
mWhitelist = nullptr;
mSuperWhitelist = nullptr;
// Inform the SSM.
nsScriptSecurityManager* ssm = nsScriptSecurityManager::GetScriptSecurityManager();
if (ssm) {
ssm->DeactivateDomainPolicy();
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
BroadcastDomainSetChange(NO_TYPE, DEACTIVATE_POLICY);
}
return NS_OK;
}
void
DomainPolicy::CloneDomainPolicy(DomainPolicyClone* aClone)
{
@@ -165,39 +165,39 @@ GetCanonicalClone(nsIURI* aURI)
NS_IMPL_ISUPPORTS(DomainSet, nsIDomainSet)
NS_IMETHODIMP
DomainSet::Add(nsIURI* aDomain)
{
nsCOMPtr<nsIURI> 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;
}
NS_IMETHODIMP
DomainSet::Remove(nsIURI* aDomain)
{
nsCOMPtr<nsIURI> 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;
}
NS_IMETHODIMP
DomainSet::Clear()
{
mHashTable.Clear();
- if (XRE_GetProcessType() == GeckoProcessType_Default)
+ if (XRE_IsParentProcess())
return BroadcastDomainSetChange(mType, CLEAR_DOMAINS);
return NS_OK;
}
NS_IMETHODIMP
DomainSet::Contains(nsIURI* aDomain, bool* aContains)
{
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1278,17 +1278,17 @@ nsScriptSecurityManager::~nsScriptSecuri
{
Preferences::RemoveObservers(this, kObservedPrefs);
if (mDomainPolicy) {
mDomainPolicy->Deactivate();
}
// 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);
}
void
nsScriptSecurityManager::Shutdown()
{
if (sRuntime) {
JS_SetSecurityCallbacks(sRuntime, nullptr);
@@ -1495,17 +1495,17 @@ nsScriptSecurityManager::GetDomainPolicy
{
*aRv = !!mDomainPolicy;
return NS_OK;
}
NS_IMETHODIMP
nsScriptSecurityManager::ActivateDomainPolicy(nsIDomainPolicy** aRv)
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return NS_ERROR_SERVICE_NOT_AVAILABLE;
}
return ActivateDomainPolicyInternal(aRv);
}
NS_IMETHODIMP
nsScriptSecurityManager::ActivateDomainPolicyInternal(nsIDomainPolicy** aRv)
--- a/docshell/base/nsDefaultURIFixup.cpp
+++ b/docshell/base/nsDefaultURIFixup.cpp
@@ -411,17 +411,17 @@ nsDefaultURIFixup::KeywordToURI(const ns
// Strip leading "?" and leading/trailing spaces from aKeyword
nsAutoCString keyword(aKeyword);
if (StringBeginsWith(keyword, NS_LITERAL_CSTRING("?"))) {
keyword.Cut(0, 1);
}
keyword.Trim(" ");
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
if (!contentChild) {
return NS_ERROR_NOT_AVAILABLE;
}
ipc::OptionalInputStreamParams postData;
ipc::OptionalURIParams uri;
nsAutoString providerName;
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -819,31 +819,31 @@ ConvertLoadTypeToNavigationType(uint32_t
static nsISHEntry* GetRootSHEntry(nsISHEntry* aEntry);
static void
IncreasePrivateDocShellCount()
{
gNumberOfPrivateDocShells++;
if (gNumberOfPrivateDocShells > 1 ||
- XRE_GetProcessType() != GeckoProcessType_Content) {
+ !XRE_IsContentProcess()) {
return;
}
mozilla::dom::ContentChild* cc = mozilla::dom::ContentChild::GetSingleton();
cc->SendPrivateDocShellsExist(true);
}
static void
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;
}
nsCOMPtr<nsIObserverService> obsvc = services::GetObserverService();
if (obsvc) {
obsvc->NotifyObservers(nullptr, "last-pb-context-exited", nullptr);
@@ -5016,17 +5016,17 @@ nsDocShell::DisplayLoadError(nsresult aE
// If this is an HTTP Strict Transport Security host or a pinned host
// and the certificate is bad, don't allow overrides (RFC 6797 section
// 12.1, HPKP draft spec section 2.6).
uint32_t flags =
mInPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
bool isStsHost = false;
bool isPinnedHost = false;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsISiteSecurityService> sss =
do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HSTS, aURI,
flags, &isStsHost);
NS_ENSURE_SUCCESS(rv, rv);
rv = sss->IsSecureURI(nsISiteSecurityService::HEADER_HPKP, aURI,
flags, &isPinnedHost);
@@ -9444,17 +9444,17 @@ NS_IMPL_ISUPPORTS(nsCopyFaviconCallback,
} // anonymous namespace
void
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;
SerializeURI(aOldURI, oldURI);
SerializeURI(aNewURI, newURI);
contentChild->SendCopyFavicon(oldURI, newURI, aInPrivateBrowsing);
}
return;
@@ -13987,17 +13987,17 @@ nsDocShell::NotifyJSRunToCompletionStop(
void
nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
const nsString& aKeyword)
{
if (aProvider.IsEmpty()) {
return;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
if (contentChild) {
contentChild->SendNotifyKeywordSearchLoading(aProvider, aKeyword);
}
return;
}
#ifdef MOZ_TOOLKIT_SEARCH
--- a/dom/asmjscache/AsmJSCache.cpp
+++ b/dom/asmjscache/AsmJSCache.cpp
@@ -54,22 +54,16 @@ namespace mozilla {
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, PR_Close);
namespace dom {
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;
// The number of characters to hash into the Metadata::Entry::mFastHash.
static const unsigned sNumFastHashChars = 4096;
nsresult
@@ -498,17 +492,17 @@ public:
mWriteParams(aWriteParams),
mNeedAllowNextSynchronizedOp(false),
mPersistence(quota::PERSISTENCE_TYPE_INVALID),
mState(eInitial),
mResult(JS::AsmJSCache_InternalError),
mIsApp(false),
mEnforcingQuota(true)
{
- MOZ_ASSERT(IsMainProcess());
+ MOZ_ASSERT(XRE_IsParentProcess());
}
virtual ~MainProcessRunnable()
{
MOZ_ASSERT(mState == eFinished);
MOZ_ASSERT(!mNeedAllowNextSynchronizedOp);
}
@@ -1128,17 +1122,17 @@ public:
// the main thread.
SingleProcessRunnable(nsIPrincipal* aPrincipal,
OpenMode aOpenMode,
WriteParams aWriteParams,
ReadParams aReadParams)
: MainProcessRunnable(aPrincipal, aOpenMode, aWriteParams),
mReadParams(aReadParams)
{
- MOZ_ASSERT(IsMainProcess());
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
MOZ_COUNT_CTOR(SingleProcessRunnable);
}
protected:
~SingleProcessRunnable()
{
MOZ_COUNT_DTOR(SingleProcessRunnable);
@@ -1206,17 +1200,17 @@ public:
OpenMode aOpenMode,
WriteParams aWriteParams)
: MainProcessRunnable(aPrincipal, aOpenMode, aWriteParams),
mPrincipalHolder(aPrincipal),
mActorDestroyed(false),
mOpened(false),
mFinished(false)
{
- MOZ_ASSERT(IsMainProcess());
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
MOZ_COUNT_CTOR(ParentProcessRunnable);
}
private:
~ParentProcessRunnable()
{
MOZ_ASSERT(!mPrincipalHolder, "Should have already been released");
@@ -1383,17 +1377,17 @@ public:
ReadParams aReadParams)
: mPrincipal(aPrincipal),
mOpenMode(aOpenMode),
mWriteParams(aWriteParams),
mReadParams(aReadParams),
mActorDestroyed(false),
mState(eInitial)
{
- MOZ_ASSERT(!IsMainProcess());
+ MOZ_ASSERT(!XRE_IsParentProcess());
MOZ_ASSERT(!NS_IsMainThread());
MOZ_COUNT_CTOR(ChildProcessRunnable);
}
protected:
~ChildProcessRunnable()
{
MOZ_ASSERT(mState == eFinished);
@@ -1579,17 +1573,17 @@ OpenFile(nsIPrincipal* aPrincipal,
if (NS_IsMainThread()) {
return JS::AsmJSCache_SynchronousScript;
}
// If we are in a child process, we need to synchronously call into the
// 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> file;
- if (IsMainProcess()) {
+ if (XRE_IsParentProcess()) {
file = new SingleProcessRunnable(aPrincipal, aOpenMode, aWriteParams,
aReadParams);
} else {
file = new ChildProcessRunnable(aPrincipal, aOpenMode, aWriteParams,
aReadParams);
}
JS::AsmJSCacheResult openResult = file->BlockUntilOpen(aFile);
--- a/dom/audiochannel/AudioChannelService.cpp
+++ b/dom/audiochannel/AudioChannelService.cpp
@@ -65,31 +65,31 @@ static const nsAttrValue::EnumTable kMoz
};
// static
AudioChannelService*
AudioChannelService::GetAudioChannelService()
{
MOZ_ASSERT(NS_IsMainThread());
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return AudioChannelServiceChild::GetAudioChannelService();
}
return gAudioChannelService;
}
// static
AudioChannelService*
AudioChannelService::GetOrCreateAudioChannelService()
{
MOZ_ASSERT(NS_IsMainThread());
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return AudioChannelServiceChild::GetOrCreateAudioChannelService();
}
// If we already exist, exit early
if (gAudioChannelService) {
return gAudioChannelService;
}
@@ -99,17 +99,17 @@ AudioChannelService::GetOrCreateAudioCha
gAudioChannelService = service;
return gAudioChannelService;
}
void
AudioChannelService::Shutdown()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return AudioChannelServiceChild::Shutdown();
}
if (gAudioChannelService) {
gAudioChannelService = nullptr;
}
}
@@ -117,17 +117,17 @@ NS_IMPL_ISUPPORTS(AudioChannelService, n
AudioChannelService::AudioChannelService()
: mCurrentHigherChannel(-1)
, mCurrentVisibleHigherChannel(-1)
, mPlayableHiddenContentChildID(CONTENT_PROCESS_ID_UNKNOWN)
, mDisabled(false)
, mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(this, "ipc:content-shutdown", false);
obs->AddObserver(this, "xpcom-shutdown", false);
obs->AddObserver(this, "inner-window-destroyed", false);
#ifdef MOZ_WIDGET_GONK
// To monitor the volume settings based on audio channel.
obs->AddObserver(this, "mozsettings-changed", false);
@@ -175,17 +175,17 @@ AudioChannelService::RegisterType(AudioC
{
if (mDisabled) {
return;
}
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.
if (aChannel == AudioChannel::Telephony) {
RegisterTelephonyChild(aChildID);
}
// Since there is another telephony registered, we can unregister old one
@@ -267,17 +267,17 @@ AudioChannelService::UnregisterType(Audi
{
if (mDisabled) {
return;
}
// 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);
}
if (aChannel == AudioChannel::Telephony &&
(mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY_HIDDEN].Length() +
mChannelCounters[AUDIO_CHANNEL_INT_TELEPHONY].Length()) == 1) {
@@ -301,17 +301,17 @@ AudioChannelService::UnregisterTypeInter
// The array may contain multiple occurrence of this appId but
// this should remove only the first one.
AudioChannelInternalType type = GetInternalType(aChannel, aElementHidden);
MOZ_ASSERT(mChannelCounters[type].Contains(aChildID));
mChannelCounters[type].RemoveElement(aChildID);
// 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 &&
mPlayableHiddenContentChildID == aChildID &&
!mChannelCounters[AUDIO_CHANNEL_INT_CONTENT_HIDDEN].Contains(aChildID)) {
mPlayableHiddenContentChildID = CONTENT_PROCESS_ID_UNKNOWN;
}
@@ -542,17 +542,17 @@ AudioChannelService::SetDefaultVolumeCon
CONTENT_PROCESS_ID_MAIN);
}
void
AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel,
bool aVisible,
uint64_t aChildID)
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
// If this child is in the background and mDefChannelChildID is set to
// others then it means other child in the foreground already set it's
// own default channel already.
if (!aVisible && mDefChannelChildID != aChildID) {
return;
@@ -585,17 +585,17 @@ AudioChannelService::SetDefaultVolumeCon
obs->NotifyObservers(nullptr, "default-volume-channel-changed",
channelName.get());
}
}
void
AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
nsRefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), aChildID);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
--- a/dom/base/Crypto.cpp
+++ b/dom/base/Crypto.cpp
@@ -86,17 +86,17 @@ Crypto::GetRandomValues(JSContext* aCx,
return;
} else if (dataLen > 65536) {
aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
return;
}
uint8_t* data = aArray.Data();
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
InfallibleTArray<uint8_t> randomValues;
// Tell the parent process to generate random values via PContent
ContentChild* cc = ContentChild::GetSingleton();
if (!cc->SendGetRandomValues(dataLen, &randomValues) ||
randomValues.Length() == 0) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
--- a/dom/base/Navigator.cpp
+++ b/dom/base/Navigator.cpp
@@ -1476,17 +1476,17 @@ Navigator::GetFeature(const nsAString& a
nsRefPtr<Promise> p = Promise::Create(go, aRv);
if (aRv.Failed()) {
return nullptr;
}
#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);
return p.forget();
}
p->MaybeResolve((int)memLevel);
} else {
mozilla::dom::ContentChild* cc =
@@ -2567,17 +2567,17 @@ Navigator::HasTVSupport(JSContext* aCx,
// Only support TV Manager API for certified apps for now.
return status == nsIPrincipal::APP_STATUS_CERTIFIED;
}
/* static */
bool
Navigator::IsE10sEnabled(JSContext* aCx, JSObject* aGlobal)
{
- return XRE_GetProcessType() == GeckoProcessType_Content;
+ return XRE_IsContentProcess();
}
bool
Navigator::MozE10sEnabled()
{
// This will only be called if IsE10sEnabled() is true.
return true;
}
--- a/dom/base/nsCCUncollectableMarker.cpp
+++ b/dom/base/nsCCUncollectableMarker.cpp
@@ -135,17 +135,17 @@ MarkChildMessageManagers(nsIMessageBroad
}
}
}
static void
MarkMessageManagers()
{
// The global message manager only exists in the root process.
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
nsCOMPtr<nsIMessageBroadcaster> strongGlobalMM =
do_GetService("@mozilla.org/globalmessagemanager;1");
if (!strongGlobalMM) {
return;
}
nsIMessageBroadcaster* globalMM = strongGlobalMM;
--- a/dom/base/nsContentPermissionHelper.cpp
+++ b/dom/base/nsContentPermissionHelper.cpp
@@ -331,17 +331,17 @@ nsContentPermissionUtils::CreateContentP
/* static */ nsresult
nsContentPermissionUtils::AskPermission(nsIContentPermissionRequest* aRequest, nsPIDOMWindow* aWindow)
{
MOZ_ASSERT(!aWindow || aWindow->IsInnerWindow());
NS_ENSURE_STATE(aWindow && aWindow->IsCurrentInnerWindow());
// for content process
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
nsRefPtr<RemotePermissionRequest> req =
new RemotePermissionRequest(aRequest, aWindow);
MOZ_ASSERT(NS_IsMainThread()); // IPC can only be execute on main thread.
TabChild* child = TabChild::GetFrom(aWindow->GetDocShell());
NS_ENSURE_TRUE(child, NS_ERROR_FAILURE);
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -10632,17 +10632,17 @@ PLDHashOperator UnlockEnumerator(imgIReq
aKey->UnlockImage();
return PL_DHASH_NEXT;
}
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;
}
// If there's no change, there's nothing to do.
if (mLockingImages == aLocked)
return NS_OK;
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -692,17 +692,17 @@ nsFocusManager::WindowRaised(nsIDOMWindo
if (!sTestMode) {
baseWindow->SetVisibility(true);
}
}
// 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);
}
// retrieve the last focused element within the window that was raised
nsCOMPtr<nsPIDOMWindow> currentWindow;
nsCOMPtr<nsIContent> currentFocus =
GetFocusedDescendant(window, true, getter_AddRefs(currentWindow));
@@ -755,17 +755,17 @@ nsFocusManager::WindowLowered(nsIDOMWind
return NS_OK;
// clear the mouse capture as the active window has changed
nsIPresShell::SetCapturingContent(nullptr, 0);
// 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);
}
// keep track of the window being lowered, so that attempts to raise the
// window can be prevented until we return. Otherwise, focus can get into
// an unusual state.
mWindowBeingLowered = mActiveWindow;
mActiveWindow = nullptr;
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1596,22 +1596,22 @@ nsFrameLoader::ShouldUseRemoteProcess()
{
if (PR_GetEnv("MOZ_DISABLE_OOP_TABS") ||
Preferences::GetBool("dom.ipc.tabs.disabled", false)) {
return false;
}
// 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;
}
// If we're an <iframe mozbrowser> and we don't have a "remote" attribute,
// fall back to the default.
if (OwnerIsBrowserOrAppFrame() &&
@@ -2645,17 +2645,17 @@ nsFrameLoader::AttributeChanged(nsIDocum
}
}
void
nsFrameLoader::ResetPermissionManagerStatus()
{
// The resetting of the permissions status can run only
// in the main process.
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return;
}
// Finding the new app Id:
// . first we check if the owner is an app frame
// . second, we check if the owner is a browser frame
// in both cases we populate the appId variable.
uint32_t appId = nsIScriptSecurityManager::NO_APP_ID;
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -897,17 +897,17 @@ nsFrameMessageManager::Dump(const nsAStr
fputs(NS_ConvertUTF16toUTF8(aStr).get(), stdout);
fflush(stdout);
return NS_OK;
}
NS_IMETHODIMP
nsFrameMessageManager::PrivateNoteIntentionalCrash()
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
mozilla::NoteIntentionalCrash("tab");
return NS_OK;
} else {
return NS_ERROR_NOT_IMPLEMENTED;
}
}
NS_IMETHODIMP
@@ -1571,17 +1571,17 @@ ReportReferentCount(const char* aManager
}
NS_IMETHODIMP
MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure, bool aAnonymize)
{
nsresult rv;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIMessageBroadcaster> globalmm =
do_GetService("@mozilla.org/globalmessagemanager;1");
if (globalmm) {
nsRefPtr<nsFrameMessageManager> mm =
static_cast<nsFrameMessageManager*>(globalmm.get());
MessageManagerReferentCount count;
CountReferents(mm, &count);
rv = ReportReferentCount("global-manager", count, aCb, aClosure);
@@ -1607,17 +1607,17 @@ MessageManagerReporter::CollectReports(n
}
} // namespace dom
} // namespace mozilla
nsresult
NS_NewGlobalMessageManager(nsIMessageBroadcaster** aResult)
{
- NS_ENSURE_TRUE(XRE_GetProcessType() == GeckoProcessType_Default,
+ NS_ENSURE_TRUE(XRE_IsParentProcess(),
NS_ERROR_NOT_AVAILABLE);
nsRefPtr<nsFrameMessageManager> mm = new nsFrameMessageManager(nullptr,
nullptr,
MM_CHROME | MM_GLOBAL | MM_BROADCASTER);
RegisterStrongMemoryReporter(new MessageManagerReporter());
mm.forget(aResult);
return NS_OK;
}
@@ -2136,17 +2136,17 @@ nsFrameMessageManager::NewProcessMessage
nsresult
NS_NewChildProcessMessageManager(nsISyncMessageSender** aResult)
{
NS_ASSERTION(!nsFrameMessageManager::GetChildProcessManager(),
"Re-creating sChildProcessManager");
MessageManagerCallback* cb;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
cb = new SameChildProcessMessageManagerCallback();
} else {
cb = new ChildProcessMessageManagerCallback();
RegisterStrongMemoryReporter(new MessageManagerReporter());
}
nsFrameMessageManager* mm = new nsFrameMessageManager(cb,
nullptr,
MM_PROCESSMANAGER | MM_OWNSCALLBACK);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -8982,17 +8982,17 @@ nsGlobalWindow::ShowModalDialog(const ns
if (mDoc) {
mDoc->WarnOnceAbout(nsIDocument::eShowModalDialog);
}
FORWARD_TO_OUTER_OR_THROW(ShowModalDialog,
(aUrl, aArgument, aOptions, aError), aError,
nullptr);
- if (!IsShowModalDialogEnabled() || XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (!IsShowModalDialogEnabled() || XRE_IsContentProcess()) {
aError.Throw(NS_ERROR_NOT_AVAILABLE);
return nullptr;
}
Telemetry::Accumulate(Telemetry::DOM_WINDOW_SHOWMODALDIALOG_USED, true);
nsRefPtr<DialogValueHolder> argHolder =
new DialogValueHolder(nsContentUtils::SubjectPrincipal(), aArgument);
@@ -10771,17 +10771,17 @@ nsGlobalWindow::ShowSlowScriptDialog()
return KillSlowScript;
}
// Check if we should offer the option to debug
JS::AutoFilename filename;
unsigned lineno;
bool hasFrame = JS::DescribeScriptedCaller(cx, &filename, &lineno);
- if (XRE_GetProcessType() == GeckoProcessType_Content &&
+ if (XRE_IsContentProcess() &&
ProcessHangMonitor::Get()) {
ProcessHangMonitor::SlowScriptAction action;
nsRefPtr<ProcessHangMonitor> monitor = ProcessHangMonitor::Get();
nsCOMPtr<nsITabChild> child = do_GetInterface(GetDocShell());
action = monitor->NotifySlowScript(child,
filename.get(),
lineno);
if (action == ProcessHangMonitor::Terminate) {
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -3194,17 +3194,17 @@ nsObjectLoadingContent::ShouldPlay(Fallb
if (!sPrefsInitialized) {
Preferences::AddUintVarCache(&sSessionTimeoutMinutes,
"plugin.sessionPermissionNow.intervalInMinutes", 60);
Preferences::AddUintVarCache(&sPersistentTimeoutDays,
"plugin.persistentPermissionAlways.intervalInDays", 90);
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.
aReason = eFallbackDisabled;
return false;
}
nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
--- a/dom/base/nsWindowMemoryReporter.cpp
+++ b/dom/base/nsWindowMemoryReporter.cpp
@@ -529,17 +529,17 @@ nsWindowMemoryReporter::CollectReports(n
NS_ENSURE_SUCCESS(rv, rv);
WindowPaths windowPaths;
WindowPaths topWindowPaths;
// Collect window memory usage.
nsWindowSizes windowTotalSizes(nullptr);
nsCOMPtr<amIAddonManager> 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");
}
for (uint32_t i = 0; i < windows.Length(); i++) {
rv = CollectWindowReports(windows[i], addonManager,
&windowTotalSizes, &ghostWindows,
&windowPaths, &topWindowPaths, aCb,
aClosure, aAnonymize);
--- a/dom/base/nsXMLHttpRequest.cpp
+++ b/dom/base/nsXMLHttpRequest.cpp
@@ -2941,17 +2941,17 @@ nsXMLHttpRequest::Send(nsIVariant* aVari
nsAutoCString scheme;
rv = mChannel->GetURI(getter_AddRefs(uri));
if (NS_SUCCEEDED(rv)) {
uri->GetScheme(scheme);
if (scheme.LowerCaseEqualsLiteral("app") ||
scheme.LowerCaseEqualsLiteral("jar")) {
mIsMappedArrayBuffer = true;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
nsCOMPtr<nsIJARChannel> 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.
// Set this to make sure that file descriptor can be obtained by
// child process.
jarChannel->EnsureChildFd();
}
}
--- a/dom/bluetooth/BluetoothUtils.cpp
+++ b/dom/bluetooth/BluetoothUtils.cpp
@@ -328,15 +328,9 @@ DispatchStatusChangedEvent(const nsAStri
#ifndef MOZ_B2G_BT_API_V1
bs->DistributeSignal(aType, NS_LITERAL_STRING(KEY_ADAPTER), data);
#else
BluetoothSignal signal(nsString(aType), NS_LITERAL_STRING(KEY_ADAPTER), data);
bs->DistributeSignal(signal);
#endif
}
-bool
-IsMainProcess()
-{
- return XRE_GetProcessType() == GeckoProcessType_Default;
-}
-
END_BLUETOOTH_NAMESPACE
--- a/dom/bluetooth/BluetoothUtils.h
+++ b/dom/bluetooth/BluetoothUtils.h
@@ -152,19 +152,11 @@ void
DispatchReplyError(BluetoothReplyRunnable* aRunnable,
const enum BluetoothStatus aStatus);
void
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
--- a/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp
+++ b/dom/bluetooth/bluetooth1/BluetoothAdapter.cpp
@@ -779,17 +779,17 @@ BluetoothAdapter::SendFile(const nsAStri
new BluetoothVoidReplyRunnable(request);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
// In-process transfer
bs->SendFile(aDeviceAddress, &aBlob, results);
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
--- a/dom/bluetooth/bluetooth1/BluetoothService.cpp
+++ b/dom/bluetooth/bluetooth1/BluetoothService.cpp
@@ -93,22 +93,16 @@ USING_BLUETOOTH_NAMESPACE
namespace {
StaticRefPtr<BluetoothService> sBluetoothService;
bool sInShutdown = false;
bool sToggleInProgress = false;
-bool
-IsMainProcess()
-{
- return XRE_GetProcessType() == GeckoProcessType_Default;
-}
-
void
ShutdownTimeExceeded(nsITimer* aTimer, void* aClosure)
{
MOZ_ASSERT(NS_IsMainThread());
*static_cast<bool*>(aClosure) = true;
}
void
@@ -215,17 +209,17 @@ RemoveObserversExceptBluetoothManager
return PL_DHASH_NEXT;
}
// static
BluetoothService*
BluetoothService::Create()
{
#if defined(MOZ_B2G_BT)
- if (!IsMainProcess()) {
+ if (!XRE_IsParentProcess()) {
return BluetoothServiceChildProcess::Create();
}
#if defined(MOZ_B2G_BT_BLUEZ)
return new BluetoothDBusService();
#elif defined(MOZ_B2G_BT_BLUEDROID)
return new BluetoothServiceBluedroid();
#elif defined(MOZ_B2G_BT_DAEMON)
@@ -249,17 +243,17 @@ BluetoothService::Init()
if (NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
false))) {
BT_WARNING("Failed to add shutdown observer!");
return false;
}
// 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;
}
return true;
}
--- a/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
+++ b/dom/bluetooth/bluetooth2/BluetoothAdapter.cpp
@@ -1293,17 +1293,17 @@ BluetoothAdapter::SendFile(const nsAStri
new BluetoothVoidReplyRunnable(request);
BluetoothService* bs = BluetoothService::Get();
if (!bs) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
// In-process transfer
bs->SendFile(aDeviceAddress, &aBlob, results);
} else {
ContentChild *cc = ContentChild::GetSingleton();
if (!cc) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
--- a/dom/bluetooth/bluetooth2/BluetoothService.cpp
+++ b/dom/bluetooth/bluetooth2/BluetoothService.cpp
@@ -188,17 +188,17 @@ BluetoothService::~BluetoothService()
Cleanup();
}
// static
BluetoothService*
BluetoothService::Create()
{
#if defined(MOZ_B2G_BT)
- if (!IsMainProcess()) {
+ if (!XRE_IsParentProcess()) {
return BluetoothServiceChildProcess::Create();
}
#if defined(MOZ_B2G_BT_BLUEZ)
return new BluetoothDBusService();
#elif defined(MOZ_B2G_BT_BLUEDROID)
return new BluetoothServiceBluedroid();
#elif defined(MOZ_B2G_BT_DAEMON)
@@ -222,17 +222,17 @@ BluetoothService::Init()
if (NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID,
false))) {
BT_WARNING("Failed to add shutdown observer!");
return false;
}
// 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;
}
return true;
}
@@ -264,17 +264,17 @@ BluetoothService::RegisterBluetoothSigna
ol = new BluetoothSignalObserverList();
mBluetoothSignalObserverTable.Put(aNodeName, ol);
}
ol->AddObserver(aHandler);
// 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) {
DistributeSignal(mPendingPairReqSignals[i]);
}
mPendingPairReqSignals.Clear();
}
}
--- a/dom/bluetooth/bluez/BluetoothHfpManager.cpp
+++ b/dom/bluetooth/bluez/BluetoothHfpManager.cpp
@@ -438,17 +438,17 @@ BluetoothHfpManager::Reset()
mReceiveVgsFlag = false;
mController = nullptr;
}
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<nsIObserverService> obs = services::GetObserverService();
NS_ENSURE_TRUE(obs, false);
if (NS_FAILED(obs->AddObserver(this, MOZSETTINGS_CHANGED_ID, false)) ||
NS_FAILED(obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false))) {
BT_WARNING("Failed to add observers!");
--- a/dom/cellbroadcast/CellBroadcast.cpp
+++ b/dom/cellbroadcast/CellBroadcast.cpp
@@ -147,17 +147,17 @@ CellBroadcast::NotifyMessageReceived(uin
return DispatchTrustedEvent(event);
}
already_AddRefed<nsICellBroadcastService>
NS_CreateCellBroadcastService()
{
nsCOMPtr<nsICellBroadcastService> 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 {
service = do_GetService(GONK_CELLBROADCAST_SERVICE_CONTRACTID);
#endif
}
return service.forget();
--- a/dom/datastore/DataStoreService.cpp
+++ b/dom/datastore/DataStoreService.cpp
@@ -46,18 +46,18 @@
#include "nsContentUtils.h"
#include "nsNetCID.h"
#include "nsServiceManagerUtils.h"
#include "nsThreadUtils.h"
#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; \
}
namespace mozilla {
namespace dom {
using namespace indexedDB;
@@ -120,30 +120,16 @@ public:
namespace {
// Singleton for DataStoreService.
StaticRefPtr<DataStoreService> gDataStoreService;
static uint64_t gCounterID = 0;
typedef nsClassHashtable<nsUint32HashKey, DataStoreInfo> 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)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(NS_FAILED(aRv));
nsRefPtr<DOMError> error;
if (aRv == NS_ERROR_DOM_SECURITY_ERR) {
@@ -156,48 +142,45 @@ RejectPromise(nsPIDOMWindow* aWindow, Pr
aPromise->MaybeRejectBrokenly(error);
}
void
DeleteDatabase(const nsAString& aName,
const nsAString& aManifestURL)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
nsRefPtr<DataStoreDB> db = new DataStoreDB(aManifestURL, aName);
db->Delete();
}
PLDHashOperator
DeleteDataStoresAppEnumerator(
const uint32_t& aAppId,
nsAutoPtr<DataStoreInfo>& aInfo,
void* aUserData)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* appId = static_cast<uint32_t*>(aUserData);
if (*appId != aAppId) {
return PL_DHASH_NEXT;
}
DeleteDatabase(aInfo->mName, aInfo->mManifestURL);
return PL_DHASH_REMOVE;
}
PLDHashOperator
DeleteDataStoresEnumerator(const nsAString& aName,
nsAutoPtr<HashApp>& 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;
}
void
GeneratePermissionName(nsAString& aPermission,
const nsAString& aName,
@@ -210,18 +193,17 @@ GeneratePermissionName(nsAString& aPermi
}
nsresult
ResetPermission(uint32_t aAppId, const nsAString& aOriginURL,
const nsAString& aManifestURL,
const nsAString& aPermission,
bool aReadOnly)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
nsresult rv;
nsCOMPtr<nsIIOService> ioService(do_GetService(NS_IOSERVICE_CONTRACTID, &rv));
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsCOMPtr<nsIURI> uri;
@@ -342,18 +324,17 @@ public:
nsTArray<DataStoreInfo>& mStores;
};
PLDHashOperator
GetDataStoreInfosEnumerator(const uint32_t& aAppId,
DataStoreInfo* aInfo,
void* aUserData)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* data = static_cast<GetDataStoreInfosData*>(aUserData);
if (aAppId == data->mAppId) {
return PL_DHASH_NEXT;
}
HashApp* apps;
if (!data->mAccessStores.Get(data->mName, &apps)) {
@@ -379,18 +360,17 @@ GetDataStoreInfosEnumerator(const uint32
return PL_DHASH_NEXT;
}
PLDHashOperator
GetAppManifestURLsEnumerator(const uint32_t& aAppId,
DataStoreInfo* aInfo,
void* aUserData)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* manifestURLs = static_cast<nsIMutableArray*>(aUserData);
nsCOMPtr<nsISupportsString> manifestURL(do_CreateInstance(NS_SUPPORTS_STRING_CONTRACTID));
if (manifestURL) {
manifestURL->SetData(aInfo->mManifestURL);
manifestURLs->AppendElement(manifestURL, false);
}
@@ -412,18 +392,17 @@ public:
nsresult mResult;
};
PLDHashOperator
AddPermissionsEnumerator(const uint32_t& aAppId,
DataStoreInfo* aInfo,
void* userData)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* data = static_cast<AddPermissionsData*>(userData);
// ReadOnly is decided by the owner first.
bool readOnly = data->mReadOnly || aInfo->mReadOnly;
data->mResult = ResetPermission(aAppId, aInfo->mOriginURL,
aInfo->mManifestURL,
@@ -452,18 +431,17 @@ public:
nsresult mResult;
};
PLDHashOperator
AddAccessPermissionsEnumerator(const uint32_t& aAppId,
DataStoreInfo* aInfo,
void* userData)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
auto* data = static_cast<AddAccessPermissionsData*>(userData);
nsString permission;
GeneratePermissionName(permission, data->mName, aInfo->mManifestURL);
// ReadOnly is decided by the owner first.
bool readOnly = aInfo->mReadOnly || data->mReadOnly;
@@ -512,25 +490,23 @@ public:
RevisionAddedEnableStoreCallback(uint32_t aAppId,
const nsAString& aName,
const nsAString& aManifestURL)
: mAppId(aAppId)
, 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<DataStoreService> service = DataStoreService::Get();
MOZ_ASSERT(service);
service->EnableDataStore(mAppId, mName, mManifestURL);
}
private:
@@ -548,25 +524,23 @@ public:
NS_DECL_ISUPPORTS
FirstRevisionIdCallback(uint32_t aAppId, const nsAString& aName,
const nsAString& aManifestURL)
: mAppId(aAppId)
, 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) {
NS_WARNING("Failed to create the first revision.");
return;
}
ErrorResult error;
@@ -637,18 +611,17 @@ public:
return NS_OK;
}
// nsIDOMEventListener
NS_IMETHOD
HandleEvent(nsIDOMEvent* aEvent) override
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
nsRefPtr<IDBRequest> request;
request.swap(mRequest);
nsRefPtr<IDBTransaction> txn;
txn.swap(mTxn);
request->RemoveEventListener(NS_LITERAL_STRING("success"), this, false);
@@ -825,17 +798,17 @@ DataStoreService::Get()
}
/* static */ void
DataStoreService::Shutdown()
{
MOZ_ASSERT(NS_IsMainThread());
if (gDataStoreService) {
- if (IsMainProcess()) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->RemoveObserver(gDataStoreService, "webapps-clear-data");
}
}
gDataStoreService = nullptr;
}
@@ -858,17 +831,17 @@ DataStoreService::DataStoreService()
DataStoreService::~DataStoreService()
{
MOZ_ASSERT(NS_IsMainThread());
}
nsresult
DataStoreService::Init()
{
- if (!IsMainProcess()) {
+ if (!XRE_IsParentProcess()) {
return NS_OK;
}
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (!obs) {
return NS_ERROR_FAILURE;
}
@@ -968,17 +941,17 @@ DataStoreService::GetDataStores(nsIDOMWi
nsCOMPtr<nsIPrincipal> principal = document->NodePrincipal();
MOZ_ASSERT(principal);
nsTArray<DataStoreInfo> stores;
// 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)) {
RejectPromise(window, promise, rv);
promise.forget(aDataStores);
return NS_OK;
}
@@ -1127,18 +1100,17 @@ DataStoreService::GetDataStoresResolve(n
// name and available for this 'aAppId'.
nsresult
DataStoreService::GetDataStoreInfos(const nsAString& aName,
const nsAString& aOwner,
uint32_t aAppId,
nsIPrincipal* aPrincipal,
nsTArray<DataStoreInfo>& aStores)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
nsCOMPtr<nsIAppsService> appsService =
do_GetService("@mozilla.org/AppsService;1");
if (NS_WARN_IF(!appsService)) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<mozIApplication> app;
@@ -1237,30 +1209,28 @@ DataStoreService::CheckPermission(nsIPri
return NS_OK;
}
// This method is called when an app with DataStores is deleted.
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);
}
NS_IMETHODIMP
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;
}
nsCOMPtr<mozIApplicationClearPrivateDataParams> params =
do_QueryInterface(aSubject);
MOZ_ASSERT(params);
@@ -1289,18 +1259,17 @@ DataStoreService::Observe(nsISupports* a
nsresult
DataStoreService::AddPermissions(uint32_t aAppId,
const nsAString& aName,
const nsAString& aOriginURL,
const nsAString& aManifestURL,
bool aReadOnly)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
// This is the permission name.
nsString permission;
GeneratePermissionName(permission, aName, aManifestURL);
// When a new DataStore is installed, the permissions must be set for the
// owner app.
nsresult rv = ResetPermission(aAppId, aOriginURL, aManifestURL, permission,
@@ -1322,18 +1291,17 @@ DataStoreService::AddPermissions(uint32_
}
nsresult
DataStoreService::AddAccessPermissions(uint32_t aAppId, const nsAString& aName,
const nsAString& aOriginURL,
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.
HashApp* apps = nullptr;
if (!mStores.Get(aName, &apps)) {
return NS_OK;
}
@@ -1344,18 +1312,17 @@ DataStoreService::AddAccessPermissions(u
// This method starts the operation to create the first revision for a DataStore
// if needed.
nsresult
DataStoreService::CreateFirstRevisionId(uint32_t aAppId,
const nsAString& aName,
const nsAString& aManifestURL)
{
- AssertIsInMainProcess();
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
nsRefPtr<DataStoreDB> db = new DataStoreDB(aManifestURL, aName);
nsRefPtr<FirstRevisionIdCallback> callback =
new FirstRevisionIdCallback(aAppId, aName, aManifestURL);
Sequence<nsString> dbs;
if (!dbs.AppendElement(NS_LITERAL_STRING(DATASTOREDB_REVISION), fallible)) {
@@ -1375,17 +1342,17 @@ DataStoreService::EnableDataStore(uint32
HashApp* apps = nullptr;
DataStoreInfo* info = nullptr;
if (mStores.Get(aName, &apps) && apps->Get(aAppId, &info)) {
info->Enable();
}
}
// Notify the child processes.
- if (IsMainProcess()) {
+ if (XRE_IsParentProcess()) {
nsTArray<ContentParent*> children;
ContentParent::GetAll(children);
for (uint32_t i = 0; i < children.Length(); i++) {
if (children[i]->NeedsDataStoreInfos()) {
unused << children[i]->SendDataStoreNotify(aAppId, nsAutoString(aName),
nsAutoString(aManifestURL));
}
}
@@ -1442,18 +1409,17 @@ DataStoreService::RemoveCounter(uint32_t
}
nsresult
DataStoreService::GetDataStoresFromIPC(const nsAString& aName,
const nsAString& aOwner,
nsIPrincipal* aPrincipal,
nsTArray<DataStoreSetting>* aValue)
{
- MOZ_ASSERT(IsMainProcess());
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(XRE_IsParentProcess() && NS_IsMainThread());
uint32_t appId;
nsresult rv = aPrincipal->GetAppId(&appId);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
nsTArray<DataStoreInfo> stores;
--- a/dom/devicestorage/nsDeviceStorage.cpp
+++ b/dom/devicestorage/nsDeviceStorage.cpp
@@ -556,17 +556,17 @@ FileUpdateDispatcher::Observe(nsISupport
return NS_OK;
}
if (!dsf || !dsf->mFile) {
NS_WARNING("FileUpdateDispatcher: Device storage file looks invalid!");
return NS_OK;
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
// Child process. Forward the notification to the parent.
ContentChild::GetSingleton()
->SendFilePathUpdateNotify(dsf->mStorageType,
dsf->mStorageName,
dsf->mPath,
NS_ConvertUTF16toUTF8(aData));
return NS_OK;
}
@@ -687,17 +687,17 @@ DeviceStorageFile::Dump(const char* labe
{
nsString path;
if (mFile) {
mFile->GetPath(path);
} else {
path = NS_LITERAL_STRING("(null)");
}
const char* ptStr;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
ptStr = "parent";
} else {
ptStr = "child";
}
printf_stderr("DSF (%s) %s: mStorageType '%s' mStorageName '%s' "
"mRootDir '%s' mPath '%s' mFile->GetPath '%s'\n",
ptStr, label,
@@ -809,17 +809,17 @@ OverrideRootDir::Init()
NS_NewLocalFile(overrideRootDir, false,
getter_AddRefs(sDirs->overrideRootDir));
} else {
sDirs->overrideRootDir = nullptr;
}
}
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
// prior to the parent.
nsresult rv
= sDirs->overrideRootDir->Create(nsIFile::DIRECTORY_TYPE, 0777);
nsString path;
sDirs->overrideRootDir->GetPath(path);
@@ -931,17 +931,17 @@ InitDirs()
#else
dirService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(sDirs->apps));
if (sDirs->apps) {
sDirs->apps->AppendRelativeNativePath(NS_LITERAL_CSTRING("webapps"));
}
#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"));
}
} else {
// NS_GetSpecialDirectory("UAppData") fails in content processes because
// gAppData from toolkit/xre/nsAppRunner.cpp is not initialized.
#ifdef MOZ_WIDGET_GONK
@@ -2053,17 +2053,17 @@ ContinueCursorEvent::GetNextFile()
return nullptr;
}
ContinueCursorEvent::~ContinueCursorEvent() {}
void
ContinueCursorEvent::Continue()
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
DebugOnly<nsresult> rv = NS_DispatchToMainThread(this);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return;
}
nsRefPtr<DeviceStorageFile> file = GetNextFile();
if (!file) {
@@ -2239,17 +2239,17 @@ nsDOMDeviceStorageCursor::Allow(JS::Hand
MOZ_ASSERT(aChoices.isUndefined());
if (!mFile->IsSafePath()) {
nsCOMPtr<nsIRunnable> r
= new PostErrorEvent(this, POST_ERROR_EVENT_PERMISSION_DENIED);
return NS_DispatchToMainThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(this, mFile);
DeviceStorageEnumerationParams params(mFile->mStorageType,
mFile->mStorageName,
mFile->mRootDir,
mSince);
ContentChild::GetSingleton()->SendPDeviceStorageRequestConstructor(child,
params);
@@ -3008,17 +3008,17 @@ public:
}
if (!typeChecker->Check(mFile->mStorageType, mFile->mFile)) {
r = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_ILLEGAL_TYPE);
return NS_DispatchToCurrentThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
DeviceStorageCreateFdParams params;
params.type() = mFile->mStorageType;
params.storageName() = mFile->mStorageName;
params.relpath() = mFile->mPath;
mFile->Dump("DeviceStorageCreateFdParams");
@@ -3048,17 +3048,17 @@ public:
if (!typeChecker->Check(mFile->mStorageType, mFile->mFile) ||
!typeChecker->Check(mFile->mStorageType, mBlob)) {
r = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_ILLEGAL_TYPE);
return NS_DispatchToCurrentThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
BlobChild* actor
= ContentChild::GetSingleton()->GetOrCreateActorForBlob(
static_cast<Blob*>(mBlob.get()));
if (!actor) {
return NS_ERROR_FAILURE;
}
DeviceStorageAddParams params;
@@ -3094,17 +3094,17 @@ public:
if (!typeChecker->Check(mFile->mStorageType, mFile->mFile) ||
!typeChecker->Check(mFile->mStorageType, mBlob)) {
r = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_ILLEGAL_TYPE);
return NS_DispatchToCurrentThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
BlobChild* actor
= ContentChild::GetSingleton()->GetOrCreateActorForBlob(
static_cast<Blob*>(mBlob.get()));
if (!actor) {
return NS_ERROR_FAILURE;
}
DeviceStorageAppendParams params;
@@ -3140,17 +3140,17 @@ public:
}
if (!typeChecker->Check(mFile->mStorageType, mFile->mFile)) {
r = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_ILLEGAL_TYPE);
return NS_DispatchToCurrentThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageGetParams params(mFile->mStorageType,
mFile->mStorageName,
mFile->mRootDir,
mFile->mPath);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
@@ -3174,48 +3174,48 @@ public:
}
if (!typeChecker->Check(mFile->mStorageType, mFile->mFile)) {
r = new PostErrorEvent(mRequest.forget(),
POST_ERROR_EVENT_ILLEGAL_TYPE);
return NS_DispatchToCurrentThread(r);
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageDeleteParams params(mFile->mStorageType,
mFile->mStorageName,
mFile->mPath);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
r = new DeleteFileEvent(mFile, mRequest.forget());
break;
}
case DEVICE_STORAGE_REQUEST_FREE_SPACE:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageFreeSpaceParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
r = new FreeSpaceFileEvent(mFile, mRequest.forget());
break;
}
case DEVICE_STORAGE_REQUEST_USED_SPACE:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageUsedSpaceParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -3226,32 +3226,32 @@ public:
MOZ_ASSERT(usedSpaceCache);
r = new UsedSpaceFileEvent(mFile, mRequest.forget());
usedSpaceCache->Dispatch(r);
return NS_OK;
}
case DEVICE_STORAGE_REQUEST_AVAILABLE:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageAvailableParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
r = new PostAvailableResultEvent(mFile, mRequest);
return NS_DispatchToCurrentThread(r);
}
case DEVICE_STORAGE_REQUEST_STATUS:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageStatusParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
@@ -3262,47 +3262,47 @@ public:
case DEVICE_STORAGE_REQUEST_WATCH:
{
mDeviceStorage->mAllowedToWatchFile = true;
return NS_OK;
}
case DEVICE_STORAGE_REQUEST_FORMAT:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageFormatParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
r = new PostFormatResultEvent(mFile, mRequest);
return NS_DispatchToCurrentThread(r);
}
case DEVICE_STORAGE_REQUEST_MOUNT:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageMountParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
r = new PostMountResultEvent(mFile, mRequest);
return NS_DispatchToCurrentThread(r);
}
case DEVICE_STORAGE_REQUEST_UNMOUNT:
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
PDeviceStorageRequestChild* child
= new DeviceStorageRequestChild(mRequest, mFile);
DeviceStorageUnmountParams params(mFile->mStorageType,
mFile->mStorageName);
ContentChild::GetSingleton()
->SendPDeviceStorageRequestConstructor(child, params);
return NS_OK;
}
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -592,17 +592,17 @@ EventStateManager::PreHandleEvent(nsPres
case NS_MOUSE_EXIT_WIDGET:
// If this is a remote frame, we receive NS_MOUSE_EXIT_WIDGET from the parent
// the mouse exits our content. Since the parent may update the cursor
// while the mouse is outside our frame, and since PuppetWidget caches the
// current cursor internally, re-entering our content (say from over a
// 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);
}
// Flag helps to suppress double event sending into process of content.
// For more information see comment above, at NS_MOUSE_ENTER_WIDGET case.
aEvent->mFlags.mNoCrossProcessBoundaryForwarding = true;
// If the event is not a top-level window exit, then it's not
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -927,17 +927,17 @@ IMEStateManager::SetIMEState(const IMESt
(formElement ?
NS_LITERAL_STRING("next") : EmptyString()));
}
}
// 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;
}
MOZ_LOG(sISMLog, LogLevel::Debug,
("ISM: IMEStateManager::SetIMEState(), "
"calling nsIWidget::SetInputContext(context={ mIMEState={ mEnabled=%s, "
"mOpen=%s }, mHTMLInputType=\"%s\", mHTMLInputInputmode=\"%s\", "
--- a/dom/filehandle/FileStreamWrappers.cpp
+++ b/dom/filehandle/FileStreamWrappers.cpp
@@ -237,17 +237,17 @@ FileInputStreamWrapper::IsNonBlocking(bo
*_retval = false;
return NS_OK;
}
void
FileInputStreamWrapper::Serialize(InputStreamParams& aParams,
FileDescriptorArray& /* aFDs */)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIInputStream> thisStream = do_QueryObject(this);
aParams = mozilla::ipc::SameProcessInputStreamParams(
reinterpret_cast<intptr_t>(thisStream.forget().take()));
}
--- a/dom/filesystem/CreateDirectoryTask.cpp
+++ b/dom/filesystem/CreateDirectoryTask.cpp
@@ -34,17 +34,17 @@ CreateDirectoryTask::CreateDirectoryTask
}
CreateDirectoryTask::CreateDirectoryTask(
FileSystemBase* aFileSystem,
const FileSystemCreateDirectoryParams& aParam,
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);
mTargetRealPath = aParam.realPath();
}
CreateDirectoryTask::~CreateDirectoryTask()
{
@@ -79,17 +79,17 @@ CreateDirectoryTask::SetSuccessRequestRe
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
FileSystemDirectoryResponse r = aValue;
mTargetRealPath = r.realPath();
}
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!");
if (mFileSystem->IsShutdown()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIFile> file = mFileSystem->GetLocalFile(mTargetRealPath);
--- a/dom/filesystem/CreateFileTask.cpp
+++ b/dom/filesystem/CreateFileTask.cpp
@@ -34,17 +34,17 @@ CreateFileTask::CreateFileTask(FileSyste
: FileSystemTaskBase(aFileSystem)
, mTargetRealPath(aPath)
, mReplace(replace)
{
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
MOZ_ASSERT(aFileSystem);
GetOutputBufferSize();
if (aBlobData) {
- if (FileSystemUtils::IsParentProcess()) {
+ if (XRE_IsParentProcess()) {
aBlobData->GetInternalStream(getter_AddRefs(mBlobStream), aRv);
NS_WARN_IF(aRv.Failed());
} else {
mBlobData = aBlobData;
}
}
mArrayData.SwapElements(aArrayData);
nsCOMPtr<nsIGlobalObject> globalObject =
@@ -56,17 +56,17 @@ CreateFileTask::CreateFileTask(FileSyste
}
CreateFileTask::CreateFileTask(FileSystemBase* aFileSystem,
const FileSystemCreateFileParams& aParam,
FileSystemRequestParent* aParent)
: 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);
GetOutputBufferSize();
mTargetRealPath = aParam.realPath();
mReplace = aParam.replace();
@@ -163,17 +163,17 @@ CreateFileTask::Work()
~AutoClose()
{
mStream->Close();
}
private:
nsCOMPtr<nsIOutputStream> mStream;
};
- MOZ_ASSERT(FileSystemUtils::IsParentProcess(),
+ MOZ_ASSERT(XRE_IsParentProcess(),
"Only call from parent process!");
MOZ_ASSERT(!NS_IsMainThread(), "Only call on worker thread!");
if (mFileSystem->IsShutdown()) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIFile> file = mFileSystem->GetLocalFile(mTargetRealPath);
@@ -319,17 +319,17 @@ CreateFileTask::GetPermissionAccessType(
}
aAccess.AssignLiteral("create");
}
void
CreateFileTask::GetOutputBufferSize() const
{
- if (sOutputBufferSize || !FileSystemUtils::IsParentProcess()) {
+ if (sOutputBufferSize || !XRE_IsParentProcess()) {
return;
}
sOutputBufferSize =
mozilla::Preferences::GetUint("dom.filesystem.outputBufferSize", 4096 * 4);
}
} // namespace dom
} // namespace mozilla
--- a/dom/filesystem/DeviceStorageFileSystem.cpp
+++ b/dom/filesystem/DeviceStorageFileSystem.cpp
@@ -42,17 +42,17 @@ DeviceStorageFileSystem::DeviceStorageFi
// Get the permission name required to access the file system.
nsresult rv =
DeviceStorageTypeChecker::GetPermissionForType(mStorageType, mPermission);
NS_WARN_IF(NS_FAILED(rv));
// 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<nsIFile> rootFile;
DeviceStorageFile::GetRootDirectoryForType(aStorageType,
aStorageName,
getter_AddRefs(rootFile));
NS_WARN_IF(!rootFile || NS_FAILED(rootFile->GetPath(mLocalRootPath)));
@@ -95,33 +95,33 @@ DeviceStorageFileSystem::GetWindow() con
return nullptr;
}
return mDeviceStorage->GetOwner();
}
already_AddRefed<nsIFile>
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);
localPath = mLocalRootPath + localPath;
nsCOMPtr<nsIFile> file;
nsresult rv = NS_NewLocalFile(localPath, false, getter_AddRefs(file));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}
return file.forget();
}
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.");
aRealPath.Truncate();
nsAutoString filePath;
ErrorResult rv;
aFile->GetMozFullPathInternal(filePath, rv);
@@ -136,17 +136,17 @@ const nsAString&
DeviceStorageFileSystem::GetRootName() const
{
return mStorageName;
}
bool
DeviceStorageFileSystem::IsSafeFile(nsIFile* aFile) const
{
- MOZ_ASSERT(FileSystemUtils::IsParentProcess(),
+ MOZ_ASSERT(XRE_IsParentProcess(),
"Should be on parent process!");
MOZ_ASSERT(aFile);
// Check if this file belongs to this storage.
nsAutoString path;
if (NS_FAILED(aFile->GetPath(path))) {
return false;
}
--- a/dom/filesystem/FileSystemTaskBase.cpp
+++ b/dom/filesystem/FileSystemTaskBase.cpp
@@ -30,17 +30,17 @@ FileSystemTaskBase::FileSystemTaskBase(F
FileSystemTaskBase::FileSystemTaskBase(FileSystemBase* aFileSystem,
const FileSystemParams& aParam,
FileSystemRequestParent* aParent)
: mErrorValue(NS_OK)
, 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.");
}
FileSystemTaskBase::~FileSystemTaskBase()
{
}
@@ -56,17 +56,17 @@ FileSystemTaskBase::Start()
{
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
if (HasError()) {
NS_DispatchToMainThread(this);
return;
}
- if (FileSystemUtils::IsParentProcess()) {
+ if (XRE_IsParentProcess()) {
// Run in parent process.
// Start worker thread.
nsCOMPtr<nsIEventTarget> target
= do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID);
NS_ASSERTION(target, "Must have stream transport service.");
target->Dispatch(this, NS_DISPATCH_NORMAL);
return;
}
@@ -116,30 +116,30 @@ FileSystemTaskBase::HandleResult()
} else {
HandlerCallback();
}
}
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()) {
return FileSystemErrorResponse(mErrorValue);
} else {
return GetSuccessRequestResult();
}
}
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) {
FileSystemErrorResponse r = aValue;
mErrorValue = r.error();
} else {
SetSuccessRequestResult(aValue);
}
@@ -151,17 +151,17 @@ FileSystemTaskBase::Recv__delete__(const
SetRequestResult(aValue);
HandlerCallback();
return true;
}
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);
// Load the lazy dom file data from the parent before sending to the child.
nsString mimeType;
aFile->GetType(mimeType);
--- a/dom/filesystem/FileSystemUtils.cpp
+++ b/dom/filesystem/FileSystemUtils.cpp
@@ -60,17 +60,10 @@ FileSystemUtils::IsDescendantPath(const
if (aDescendantPath.Length() < prefix.Length() ||
!StringBeginsWith(aDescendantPath, prefix)) {
return false;
}
return true;
}
-// static
-bool
-FileSystemUtils::IsParentProcess()
-{
- return XRE_GetProcessType() == GeckoProcessType_Default;
-}
-
} // namespace dom
} // namespace mozilla
--- a/dom/filesystem/FileSystemUtils.h
+++ b/dom/filesystem/FileSystemUtils.h
@@ -36,18 +36,15 @@ public:
/*
* Return true if aDescendantPath is a descendant of aPath. Both aPath and
* aDescendantPath are absolute DOM path.
*/
static bool
IsDescendantPath(const nsAString& aPath, const nsAString& aDescendantPath);
- static bool
- IsParentProcess();
-
static const char16_t kSeparatorChar = char16_t('/');
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_FileSystemUtils_h
--- a/dom/filesystem/GetFileOrDirectoryTask.cpp
+++ b/dom/filesystem/GetFileOrDirectoryTask.cpp
@@ -42,17 +42,17 @@ GetFileOrDirectoryTask::GetFileOrDirecto
GetFileOrDirectoryTask::GetFileOrDirectoryTask(
FileSystemBase* aFileSystem,
const FileSystemGetFileOrDirectoryParams& aParam,
FileSystemRequestParent* aParent)
: 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);
mTargetRealPath = aParam.realPath();
}
GetFileOrDirectoryTask::~GetFileOrDirectoryTask()
{
@@ -114,17 +114,17 @@ GetFileOrDirectoryTask::SetSuccessReques
break;
}
}
}
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!");
if (mFileSystem->IsShutdown()) {
return NS_ERROR_FAILURE;
}
// Whether we want to get the root directory.
--- a/dom/filesystem/RemoveTask.cpp
+++ b/dom/filesystem/RemoveTask.cpp
@@ -44,17 +44,17 @@ RemoveTask::RemoveTask(FileSystemBase* a
RemoveTask::RemoveTask(FileSystemBase* aFileSystem,
const FileSystemRemoveParams& aParam,
FileSystemRequestParent* aParent)
: FileSystemTaskBase(aFileSystem, aParam, aParent)
, 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);
mDirRealPath = aParam.directory();
mRecursive = aParam.recursive();
@@ -118,17 +118,17 @@ RemoveTask::SetSuccessRequestResult(cons
MOZ_ASSERT(NS_IsMainThread(), "Only call on main thread!");
FileSystemBooleanResponse r = aValue;
mReturnValue = r.success();
}
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!");
if (mFileSystem->IsShutdown()) {
return NS_ERROR_FAILURE;
}
// Get the DOM path if a File is passed as the target.
--- a/dom/fmradio/FMRadioService.cpp
+++ b/dom/fmradio/FMRadioService.cpp
@@ -37,17 +37,17 @@ using namespace mozilla::hal;
using mozilla::Preferences;
BEGIN_FMRADIO_NAMESPACE
// static
IFMRadioService*
IFMRadioService::Singleton()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return FMRadioChild::Singleton();
} else {
return FMRadioService::Singleton();
}
}
StaticRefPtr<FMRadioService> FMRadioService::sFMRadioService;
@@ -1238,17 +1238,17 @@ FMRadioService::UpdateFrequency()
mRadiotextSet = false;
}
}
// static
FMRadioService*
FMRadioService::Singleton()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
if (!sFMRadioService) {
sFMRadioService = new FMRadioService();
ClearOnShutdown(&sFMRadioService);
}
return sFMRadioService;
--- a/dom/fmradio/ipc/FMRadioChild.cpp
+++ b/dom/fmradio/ipc/FMRadioChild.cpp
@@ -333,17 +333,17 @@ FMRadioChild::EnableAudio(bool aAudioEna
{
SendEnableAudio(aAudioEnabled);
}
// static
FMRadioChild*
FMRadioChild::Singleton()
{
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
+ MOZ_ASSERT(!XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
if (!sFMRadioChild) {
sFMRadioChild = new FMRadioChild();
}
return sFMRadioChild;
}
--- a/dom/gamepad/GamepadFunctions.cpp
+++ b/dom/gamepad/GamepadFunctions.cpp
@@ -19,17 +19,17 @@ namespace {
uint32_t gGamepadIndex = 0;
}
template<class T>
void
NotifyGamepadChange(const T& aInfo)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
GamepadChangeEvent e(aInfo);
nsTArray<ContentParent*> t;
ContentParent::GetAll(t);
for(uint32_t i = 0; i < t.Length(); ++i) {
unused << t[i]->SendGamepadUpdate(e);
}
// If we have a GamepadService in the main process, send directly to it.
if (GamepadService::IsServiceRunning()) {
@@ -39,69 +39,69 @@ NotifyGamepadChange(const T& aInfo)
}
uint32_t
AddGamepad(const char* aID,
GamepadMappingType aMapping,
uint32_t aNumButtons, uint32_t aNumAxes)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
int index = gGamepadIndex;
gGamepadIndex++;
GamepadAdded a(NS_ConvertUTF8toUTF16(nsDependentCString(aID)), index,
(uint32_t)aMapping, aNumButtons, aNumAxes);
gGamepadIndex++;
NotifyGamepadChange<GamepadAdded>(a);
return index;
}
void
RemoveGamepad(uint32_t aIndex)
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
GamepadRemoved a(aIndex);
NotifyGamepadChange<GamepadRemoved>(a);
}
void
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<GamepadButtonInformation>(a);
}
void
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);
}
void
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<GamepadAxisInformation>(a);
}
void
ResetGamepadIndexes()
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
gGamepadIndex = 0;
}
} // namespace GamepadFunctions
} // namespace dom
} // namespace mozilla
--- a/dom/gamepad/GamepadMonitoring.cpp
+++ b/dom/gamepad/GamepadMonitoring.cpp
@@ -12,17 +12,17 @@ namespace mozilla {
namespace dom {
using namespace GamepadFunctions;
void
MaybeStopGamepadMonitoring()
{
MOZ_ASSERT(NS_IsMainThread());
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsTArray<ContentParent*> t;
ContentParent::GetAll(t);
for(uint32_t i = 0; i < t.Length(); ++i) {
if (t[i]->HasGamepadListener()) {
return;
}
}
StopGamepadMonitoring();
--- a/dom/gamepad/GamepadService.cpp
+++ b/dom/gamepad/GamepadService.cpp
@@ -80,17 +80,17 @@ GamepadService::Observe(nsISupports* aSu
void
GamepadService::BeginShutdown()
{
mShuttingDown = true;
if (mTimer) {
mTimer->Cancel();
}
if (mStarted) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
MaybeStopGamepadMonitoring();
} else {
ContentChild::GetSingleton()->SendGamepadListenerRemoved();
}
mStarted = false;
}
// Don't let windows call back to unregister during shutdown
for (uint32_t i = 0; i < mListeners.Length(); i++) {
@@ -110,17 +110,17 @@ GamepadService::AddListener(nsGlobalWind
return;
}
if (mListeners.IndexOf(aWindow) != NoIndex) {
return; // already exists
}
if (!mStarted && mEnabled) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
StartGamepadMonitoring();
} else {
ContentChild::GetSingleton()->SendGamepadListenerAdded();
}
mStarted = true;
}
mListeners.AppendElement(aWindow);
}
@@ -495,17 +495,17 @@ GamepadService::TimeoutHandler(nsITimer*
return;
}
if (self->mShuttingDown) {
return;
}
if (self->mListeners.Length() == 0) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
MaybeStopGamepadMonitoring();
} else {
ContentChild::GetSingleton()->SendGamepadListenerRemoved();
}
self->mStarted = false;
self->mGamepads.Clear();
}
--- a/dom/geolocation/nsGeolocation.cpp
+++ b/dom/geolocation/nsGeolocation.cpp
@@ -559,17 +559,17 @@ SynthesizeLocation(DOMTimeStamp aTimesta
return pos.forget();
}
already_AddRefed<nsIDOMGeoPosition>
nsGeolocationRequest::AdjustedLocation(nsIDOMGeoPosition *aPosition)
{
nsCOMPtr<nsIDOMGeoPosition> pos = aPosition;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
GPSLOG("child process just copying position");
return pos.forget();
}
// get the settings cache
nsRefPtr<nsGeolocationSettings> gs = nsGeolocationSettings::GetGeolocationSettings();
if (!gs) {
return pos.forget();
@@ -753,17 +753,17 @@ nsresult nsGeolocationService::Init()
{
Preferences::AddIntVarCache(&sProviderTimeout, "geo.timeout", sProviderTimeout);
Preferences::AddBoolVarCache(&sGeoEnabled, "geo.enabled", sGeoEnabled);
if (!sGeoEnabled) {
return NS_ERROR_FAILURE;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
sGeoInitPending = false;
return NS_OK;
}
// check if the geolocation service is enable from settings
nsCOMPtr<nsISettingsService> settings =
do_GetService("@mozilla.org/settingsService;1");
@@ -1008,17 +1008,17 @@ nsGeolocationService::StartDevice(nsIPri
return NS_ERROR_NOT_AVAILABLE;
}
// we do not want to keep the geolocation devices online
// indefinitely. Close them down after a reasonable period of
// inactivivity
SetDisconnectTimer();
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
cpc->SendAddGeolocationListener(IPC::Principal(aPrincipal),
HighAccuracyRequested());
return NS_OK;
}
// Start them up!
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
@@ -1071,17 +1071,17 @@ nsGeolocationService::HighAccuracyReques
return false;
}
void
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);
}
return;
}
if (!mHigherAccuracy && highRequired) {
@@ -1098,17 +1098,17 @@ nsGeolocationService::UpdateAccuracy(boo
void
nsGeolocationService::StopDevice()
{
if(mDisconnectTimer) {
mDisconnectTimer->Cancel();
mDisconnectTimer = nullptr;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
cpc->SendRemoveGeolocationListener();
return; // bail early
}
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
if (!obs) {
return;
--- a/dom/geolocation/nsGeolocationSettings.cpp
+++ b/dom/geolocation/nsGeolocationSettings.cpp
@@ -44,17 +44,17 @@ using namespace mozilla::dom;
NS_IMPL_ISUPPORTS(nsGeolocationSettings, nsIObserver)
StaticRefPtr<nsGeolocationSettings> nsGeolocationSettings::sSettings;
already_AddRefed<nsGeolocationSettings>
nsGeolocationSettings::GetGeolocationSettings()
{
// this singleton is only needed in the parent process...
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return nullptr;
}
nsRefPtr<nsGeolocationSettings> result;
if (nsGeolocationSettings::sSettings) {
result = nsGeolocationSettings::sSettings;
return result.forget();
}
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -741,17 +741,17 @@ UploadLastDir::FetchDirectoryAndDisplayP
nsIURI* docURI = aDoc->GetDocumentURI();
NS_PRECONDITION(docURI, "docURI is null");
nsCOMPtr<nsILoadContext> loadContext = aDoc->GetLoadContext();
nsCOMPtr<nsIContentPrefCallback2> prefCallback =
new UploadLastDir::ContentPrefCallback(aFilePicker, aFpCallback);
#ifdef MOZ_B2G
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
prefCallback->HandleCompletion(nsIContentPrefCallback2::COMPLETE_ERROR);
return NS_OK;
}
#endif
// Attempt to get the CPS, if it's not present we'll fallback to use the Desktop folder
nsCOMPtr<nsIContentPrefService2> contentPrefService =
do_GetService(NS_CONTENT_PREF_SERVICE_CONTRACTID);
@@ -772,17 +772,17 @@ nsresult
UploadLastDir::StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir)
{
NS_PRECONDITION(aDoc, "aDoc is null");
if (!aDir) {
return NS_OK;
}
#ifdef MOZ_B2G
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return NS_OK;
}
#endif
nsCOMPtr<nsIURI> docURI = aDoc->GetDocumentURI();
NS_PRECONDITION(docURI, "docURI is null");
// Attempt to get the CPS, if it's not present we'll just return
@@ -2100,17 +2100,17 @@ HTMLInputElement::MozSetFileArray(const
files.AppendElement(file);
}
SetFiles(files, true);
}
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;
}
nsTArray<nsRefPtr<File>> files;
for (uint32_t i = 0; i < aFileNames.Length(); ++i) {
nsCOMPtr<nsIFile> file;
--- a/dom/html/nsGenericHTMLFrameElement.cpp
+++ b/dom/html/nsGenericHTMLFrameElement.cpp
@@ -591,17 +591,17 @@ nsGenericHTMLFrameElement::GetAppManifes
// At the moment, you can't be an app without being a browser.
if (!nsIMozBrowserFrame::GetReallyIsBrowserOrApp()) {
return NS_OK;
}
// 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");
return NS_OK;
}
nsAutoString appManifestURL;
nsAutoString widgetManifestURL;
--- a/dom/icc/IccManager.cpp
+++ b/dom/icc/IccManager.cpp
@@ -138,17 +138,17 @@ IccManager::GetIccById(const nsAString&
return nullptr;
}
already_AddRefed<nsIIccService>
NS_CreateIccService()
{
nsCOMPtr<nsIIccService> 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 {
service = do_GetService(GONK_ICC_SERVICE_CONTRACTID);
#endif
}
return service.forget();
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -813,17 +813,17 @@ class WorkerPermissionRequest final : pu
public:
WorkerPermissionRequest(Element* aElement,
nsIPrincipal* aPrincipal,
WorkerPermissionChallenge* aChallenge)
: PermissionRequestBase(aElement, aPrincipal)
, mChallenge(aChallenge)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aChallenge);
}
private:
~WorkerPermissionRequest()
{
MOZ_ASSERT(NS_IsMainThread());
@@ -839,17 +839,17 @@ class WorkerPermissionRequestChildProces
{
nsRefPtr<WorkerPermissionChallenge> mChallenge;
public:
explicit WorkerPermissionRequestChildProcessActor(
WorkerPermissionChallenge* aChallenge)
: mChallenge(aChallenge)
{
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
+ MOZ_ASSERT(!XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aChallenge);
}
protected:
~WorkerPermissionRequestChildProcessActor()
{}
@@ -945,17 +945,17 @@ private:
nsresult rv;
nsCOMPtr<nsIPrincipal> principal =
mozilla::ipc::PrincipalInfoToPrincipal(mPrincipalInfo, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return true;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<Element> ownerElement =
do_QueryInterface(window->GetChromeEventHandler());
if (NS_WARN_IF(!ownerElement)) {
return true;
}
nsRefPtr<WorkerPermissionRequest> helper =
new WorkerPermissionRequest(ownerElement, principal, this);
@@ -1394,17 +1394,17 @@ BackgroundFactoryRequestChild::RecvPermi
nsresult rv;
nsCOMPtr<nsIPrincipal> principal =
mozilla::ipc::PrincipalInfoToPrincipal(aPrincipalInfo, &rv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return false;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsPIDOMWindow> window = mFactory->GetParentObject();
MOZ_ASSERT(window);
nsCOMPtr<Element> ownerElement =
do_QueryInterface(window->GetChromeEventHandler());
if (NS_WARN_IF(!ownerElement)) {
return false;
}
--- a/dom/indexedDB/FileSnapshot.cpp
+++ b/dom/indexedDB/FileSnapshot.cpp
@@ -77,17 +77,17 @@ BlobImplSnapshot::~BlobImplSnapshot()
}
#ifdef DEBUG
// static
void
BlobImplSnapshot::AssertSanity()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
}
#endif // DEBUG
NS_IMPL_ISUPPORTS_INHERITED(BlobImplSnapshot, BlobImpl, PIBlobImplSnapshot)
void
--- a/dom/indexedDB/IndexedDatabaseManager.cpp
+++ b/dom/indexedDB/IndexedDatabaseManager.cpp
@@ -247,17 +247,17 @@ IndexedDatabaseManager::GetOrCreate()
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (IsClosed()) {
NS_ERROR("Calling GetOrCreate() after shutdown!");
return nullptr;
}
if (!gDBManager) {
- sIsMainProcess = XRE_GetProcessType() == GeckoProcessType_Default;
+ sIsMainProcess = XRE_IsParentProcess();
if (!sLoggingModule) {
sLoggingModule = PR_NewLogModule("IndexedDB");
}
if (sIsMainProcess && Preferences::GetBool("disk_space_watcher.enabled", false)) {
// See if we're starting up in low disk space conditions.
nsCOMPtr<nsIDiskSpaceWatcher> watcher =
@@ -593,17 +593,17 @@ IndexedDatabaseManager::IsClosed()
#ifdef DEBUG
// static
bool
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;
}
//static
bool
IndexedDatabaseManager::InLowDiskSpaceMode()
{
--- a/dom/indexedDB/PermissionRequestBase.cpp
+++ b/dom/indexedDB/PermissionRequestBase.cpp
@@ -38,17 +38,17 @@ const char kPermissionResponseTopic[] =
#undef TOPIC_PREFIX
#undef IDB_PREFIX
const uint32_t kPermissionDefault = nsIPermissionManager::UNKNOWN_ACTION;
void
AssertSanity()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
}
} // anonymous namespace
PermissionRequestBase::PermissionRequestBase(Element* aOwnerElement,
nsIPrincipal* aPrincipal)
: mOwnerElement(aOwnerElement)
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -3245,17 +3245,17 @@ BlobChild::AssertIsOnOwningThread() cons
}
#endif // DEBUG
// static
void
BlobChild::Startup(const FriendKey& /* aKey */)
{
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
+ MOZ_ASSERT(!XRE_IsParentProcess());
CommonStartup();
}
// static
BlobChild*
BlobChild::GetOrCreate(nsIContentChild* aManager, BlobImpl* aBlobImpl)
{
@@ -3768,17 +3768,17 @@ BlobParent::AssertIsOnOwningThread() con
}
#endif // DEBUG
// static
void
BlobParent::Startup(const FriendKey& /* aKey */)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
CommonStartup();
ClearOnShutdown(&sIDTable);
sIDTableMutex = new Mutex("BlobParent::sIDTableMutex");
ClearOnShutdown(&sIDTableMutex);
}
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -2825,17 +2825,17 @@ static const uint64_t kWindowIDProcessBi
static const uint64_t kWindowIDWindowBits = kWindowIDTotalBits - kWindowIDProcessBits;
// Try to return a window ID that is unique across processes and that will never
// be recycled.
uint64_t
NextWindowID()
{
uint64_t processID = 0;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild* cc = ContentChild::GetSingleton();
processID = cc->GetID();
}
MOZ_RELEASE_ASSERT(processID < (uint64_t(1) << kWindowIDProcessBits));
uint64_t processBits = processID & ((uint64_t(1) << kWindowIDProcessBits) - 1);
// Make sure no actual window ends up with mWindowID == 0.
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -773,17 +773,17 @@ ContentParent::GetNewOrPreallocatedAppPr
/*static*/ void
ContentParent::StartUp()
{
// We could launch sub processes from content process
// FIXME Bug 1023701 - Stop using ContentParent static methods in
// child process
sCanLaunchSubprocesses = true;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
#if defined(MOZ_CONTENT_SANDBOX) && defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 19
// Require sandboxing on B2G >= KitKat. This condition must stay
// in sync with ContentChild::RecvSetProcessSandbox.
if (!SandboxInfo::Get().CanSandboxContent()) {
// MOZ_CRASH strings are only for debug builds; make sure the
@@ -1147,17 +1147,17 @@ ContentParent::CreateBrowserOrApp(const
}
if (TabParent* parent = TabParent::GetNextTabParent()) {
parent->SetOwnerElement(aFrameElement);
return parent;
}
ProcessPriority initialPriority = GetInitialProcessPriority(aFrameElement);
- bool isInContentProcess = (XRE_GetProcessType() != GeckoProcessType_Default);
+ bool isInContentProcess = !XRE_IsParentProcess();
TabId tabId;
nsIDocShell* docShell = GetOpenerDocShellHelper(aFrameElement);
TabId openerTabId;
if (docShell) {
openerTabId = TabParent::GetTabIdFrom(docShell);
}
@@ -1806,17 +1806,17 @@ ContentParent::OnChannelError()
// Handle app or Nuwa process exit before normal channel error handling.
PreallocatedProcessManager::MaybeForgetSpare(this);
#endif
PContentParent::OnChannelError();
}
void
ContentParent::OnBeginSyncTransaction() {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
JSContext *cx = nsContentUtils::GetCurrentJSContext();
if (!sDisableUnsafeCPOWWarnings) {
if (console && cx) {
nsAutoString filename;
uint32_t lineno = 0;
nsJSUtils::GetCallingLocation(cx, filename, &lineno);
nsCOMPtr<nsIScriptError> error(do_CreateInstance(NS_SCRIPTERROR_CONTRACTID));
@@ -4870,34 +4870,34 @@ ContentParent::NotifyUpdatedDictionaries
}
/*static*/ TabId
ContentParent::AllocateTabId(const TabId& aOpenerTabId,
const IPCTabContext& aContext,
const ContentParentId& aCpId)
{
TabId tabId;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
tabId = cpm->AllocateTabId(aOpenerTabId, aContext, aCpId);
}
else {
ContentChild::GetSingleton()->SendAllocateTabId(aOpenerTabId,
aContext,
aCpId,
&tabId);
}
return tabId;
}
/*static*/ void
ContentParent::DeallocateTabId(const TabId& aTabId,
const ContentParentId& aCpId)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
ContentProcessManager::GetSingleton()->DeallocateTabId(aCpId,
aTabId);
}
else {
ContentChild::GetSingleton()->SendDeallocateTabId(aTabId);
}
}
@@ -5086,25 +5086,25 @@ ContentParent::DeallocPContentPermission
nsContentPermissionUtils::NotifyRemoveContentPermissionRequestParent(actor);
delete actor;
return true;
}
bool
ContentParent::RecvGetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration* aConfig)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
return GetBrowserConfiguration(aURI, *aConfig);;
}
/*static*/ bool
ContentParent::GetBrowserConfiguration(const nsCString& aURI, BrowserConfiguration& aConfig)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
MOZ_ASSERT(swr);
swr->GetRegistrations(aConfig.serviceWorkerRegistrations());
return true;
}
return ContentChild::GetSingleton()->SendGetBrowserConfiguration(aURI, &aConfig);
--- a/dom/ipc/ContentProcessManager.cpp
+++ b/dom/ipc/ContentProcessManager.cpp
@@ -27,17 +27,17 @@ static uint64_t gTabId = 0;
/* static */
StaticAutoPtr<ContentProcessManager>
ContentProcessManager::sSingleton;
/* static */ ContentProcessManager*
ContentProcessManager::GetSingleton()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (!sSingleton) {
sSingleton = new ContentProcessManager();
ClearOnShutdown(&sSingleton);
}
return sSingleton;
}
--- a/dom/ipc/ProcessHangMonitor.cpp
+++ b/dom/ipc/ProcessHangMonitor.cpp
@@ -882,17 +882,17 @@ ProcessHangMonitor* ProcessHangMonitor::
ProcessHangMonitor::ProcessHangMonitor()
: mCPOWTimeout(false)
{
MOZ_RELEASE_ASSERT(NS_IsMainThread());
MOZ_COUNT_CTOR(ProcessHangMonitor);
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
obs->AddObserver(this, "xpcom-shutdown", false);
}
mThread = new base::Thread("ProcessHangMonitor");
if (!mThread->Start()) {
delete mThread;
mThread = nullptr;
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -379,17 +379,17 @@ ProcessPriorityManagerImpl::PrefsEnabled
/* static */ void
ProcessPriorityManagerImpl::StaticInit()
{
if (sInitialized) {
return;
}
// The process priority manager is main-process only.
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
sInitialized = true;
return;
}
// If IPC tabs aren't enabled at startup, don't bother with any of this.
if (!PrefsEnabled()) {
LOG("InitProcessPriorityManager bailing due to prefs.");
@@ -422,17 +422,17 @@ ProcessPriorityManagerImpl::GetSingleton
return sSingleton;
}
ProcessPriorityManagerImpl::ProcessPriorityManagerImpl()
: mHighPriority(false)
, mBackgroundLRUPool(PROCESS_PRIORITY_BACKGROUND)
, mBackgroundPerceivableLRUPool(PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
RegisterWakeLockObserver(this);
}
ProcessPriorityManagerImpl::~ProcessPriorityManagerImpl()
{
UnregisterWakeLockObserver(this);
}
@@ -655,17 +655,17 @@ ParticularProcessPriorityManager::Partic
, mChildID(aContentParent->ChildID())
, mPriority(PROCESS_PRIORITY_UNKNOWN)
, mLRU(0)
, mHoldsCPUWakeLock(false)
, mHoldsHighPriorityWakeLock(false)
, mIsActivityOpener(false)
, mFrozen(aFrozen)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
LOGP("Creating ParticularProcessPriorityManager.");
}
void
ParticularProcessPriorityManager::Init()
{
RegisterWakeLockObserver(this);
@@ -821,17 +821,17 @@ void
ParticularProcessPriorityManager::OnRemoteBrowserFrameShown(nsISupports* aSubject)
{
nsCOMPtr<nsIFrameLoader> fl = do_QueryInterface(aSubject);
NS_ENSURE_TRUE_VOID(fl);
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;
}
// Ignore notifications that aren't from a BrowserOrApp
bool isBrowserOrApp;
fl->GetOwnerIsBrowserOrAppFrame(&isBrowserOrApp);
if (isBrowserOrApp) {
@@ -845,17 +845,17 @@ ParticularProcessPriorityManager::OnRemo
}
void
ParticularProcessPriorityManager::OnTabParentDestroyed(nsISupports* aSubject)
{
nsCOMPtr<nsITabParent> 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;
}
ResetPriority();
}
void
@@ -868,17 +868,17 @@ ParticularProcessPriorityManager::OnFram
return; // Ignore visibility changes when the screen is off
}
TabParent* tp = TabParent::GetFrom(fl);
if (!tp) {
return;
}
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (tp->Manager() != mContentParent) {
return;
}
// Most of the time when something changes in a process we call
// ResetPriority(), giving a grace period before downgrading its priority.
// But notice that here don't give a grace period: We call ResetPriorityNow()
// instead.
@@ -1208,29 +1208,29 @@ ProcessPriorityManagerChild::Singleton()
return sSingleton;
}
NS_IMPL_ISUPPORTS(ProcessPriorityManagerChild,
nsIObserver)
ProcessPriorityManagerChild::ProcessPriorityManagerChild()
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
mCachedPriority = PROCESS_PRIORITY_MASTER;
} else {
mCachedPriority = PROCESS_PRIORITY_UNKNOWN;
}
}
void
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<nsIObserverService> os = services::GetObserverService();
NS_ENSURE_TRUE_VOID(os);
os->AddObserver(this, "ipc:process-priority-changed", /* weak = */ false);
}
}
NS_IMETHODIMP
ProcessPriorityManagerChild::Observe(
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -443,17 +443,17 @@ TabParent::Destroy()
unused << SendDestroy();
if (RenderFrameParent* frame = GetRenderFrame()) {
RemoveTabParentFromTable(frame->GetLayersId());
frame->Destroy();
}
mIsDestroyed = true;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
Manager()->AsContentParent()->NotifyTabDestroying(this);
}
// Let all PluginWidgets know we are tearing down. Prevents
// these objects from sending async events after the child side
// is shut down.
const nsTArray<PPluginWidgetParent*>& kids = ManagedPPluginWidgetParent();
for (uint32_t idx = 0; idx < kids.Length(); ++idx) {
@@ -461,17 +461,17 @@ TabParent::Destroy()
}
mMarkedDestroying = true;
}
bool
TabParent::Recv__delete__()
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
Manager()->AsContentParent()->NotifyTabDestroyed(this, mMarkedDestroying);
ContentParent::DeallocateTabId(mTabId,
Manager()->AsContentParent()->ChildID());
}
else {
ContentParent::DeallocateTabId(mTabId, ContentParentId(0));
}
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -1444,17 +1444,17 @@ MediaManager::NotifyRecordingStatusChang
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
obs->NotifyObservers(static_cast<nsIPropertyBag2*>(props),
"recording-device-events",
aMsg.get());
// 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,
aIsAudio,
aIsVideo);
}
return NS_OK;
--- a/dom/media/gmp/GMPService.cpp
+++ b/dom/media/gmp/GMPService.cpp
@@ -104,17 +104,17 @@ private:
}
static already_AddRefed<GeckoMediaPluginService>
GetOrCreateOnMainThread()
{
MOZ_ASSERT(NS_IsMainThread());
if (!sSingletonService) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<GeckoMediaPluginServiceParent> service =
new GeckoMediaPluginServiceParent();
service->Init();
sSingletonService = service;
} else {
nsRefPtr<GeckoMediaPluginServiceChild> service =
new GeckoMediaPluginServiceChild();
service->Init();
--- a/dom/media/gmp/GMPServiceChild.cpp
+++ b/dom/media/gmp/GMPServiceChild.cpp
@@ -28,17 +28,17 @@ namespace mozilla {
#endif
#define __CLASS__ "GMPService"
namespace gmp {
already_AddRefed<GeckoMediaPluginServiceChild>
GeckoMediaPluginServiceChild::GetSingleton()
{
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
+ MOZ_ASSERT(!XRE_IsParentProcess());
nsRefPtr<GeckoMediaPluginService> service(
GeckoMediaPluginService::GetGeckoMediaPluginService());
#ifdef DEBUG
if (service) {
nsCOMPtr<mozIGeckoMediaPluginChromeService> chromeService;
CallQueryInterface(service.get(), getter_AddRefs(chromeService));
MOZ_ASSERT(!chromeService);
}
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -55,17 +55,17 @@ namespace mozilla {
namespace gmp {
static const uint32_t NodeIdSaltLength = 32;
already_AddRefed<GeckoMediaPluginServiceParent>
GeckoMediaPluginServiceParent::GetSingleton()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsRefPtr<GeckoMediaPluginService> service(
GeckoMediaPluginServiceParent::GetGeckoMediaPluginService());
#ifdef DEBUG
if (service) {
nsCOMPtr<mozIGeckoMediaPluginChromeService> chromeService;
CallQueryInterface(service.get(), getter_AddRefs(chromeService));
MOZ_ASSERT(chromeService);
}
@@ -139,17 +139,17 @@ GeckoMediaPluginServiceParent::Init()
nsresult
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;
}
// Directory service is main thread only, so cache the profile dir here
// so that we can use it off main thread.
#ifdef MOZ_WIDGET_GONK
nsresult rv = NS_NewLocalFile(NS_LITERAL_STRING("/data/b2g/mozilla"), false, getter_AddRefs(mStorageBaseDir));
#else
--- a/dom/media/webspeech/synth/nsSpeechTask.cpp
+++ b/dom/media/webspeech/synth/nsSpeechTask.cpp
@@ -141,17 +141,17 @@ nsSpeechTask::SetChosenVoiceURI(const ns
{
mChosenVoiceURI = aUri;
}
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"));
mCallback = aCallback;
if (mIndirectAudio) {
if (argc > 0) {
NS_WARNING("Audio info arguments in Setup() are ignored for indirect audio services.");
@@ -190,17 +190,17 @@ makeSamples(int16_t* aData, uint32_t aDa
return samples;
}
NS_IMETHODIMP
nsSpeechTask::SendAudio(JS::Handle<JS::Value> aData, JS::Handle<JS::Value> 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);
NS_ENSURE_TRUE(mChannels, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(aData.isObject(), NS_ERROR_INVALID_ARG);
if (mIndirectAudio) {
NS_WARNING("Can't call SendAudio from an indirect audio speech service.");
@@ -232,17 +232,17 @@ nsSpeechTask::SendAudio(JS::Handle<JS::V
SendAudioImpl(samples, dataLen);
return NS_OK;
}
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);
NS_ENSURE_TRUE(mChannels, NS_ERROR_FAILURE);
if (mIndirectAudio) {
NS_WARNING("Can't call SendAudio from an indirect audio speech service.");
return NS_ERROR_FAILURE;
@@ -476,49 +476,49 @@ nsSpeechTask::DispatchMarkImpl(const nsA
aCharIndex, aElapsedTime,
aName);
return NS_OK;
}
void
nsSpeechTask::Pause()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (mCallback) {
DebugOnly<nsresult> rv = mCallback->OnPause();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onPause() callback");
}
if (mStream) {
mStream->ChangeExplicitBlockerCount(1);
DispatchPauseImpl(GetCurrentTime(), GetCurrentCharOffset());
}
}
void
nsSpeechTask::Resume()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (mCallback) {
DebugOnly<nsresult> rv = mCallback->OnResume();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onResume() callback");
}
if (mStream) {
mStream->ChangeExplicitBlockerCount(-1);
DispatchResumeImpl(GetCurrentTime(), GetCurrentCharOffset());
}
}
void
nsSpeechTask::Cancel()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
LOG(LogLevel::Debug, ("nsSpeechTask::Cancel"));
if (mCallback) {
DebugOnly<nsresult> rv = mCallback->OnCancel();
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Unable to call onCancel() callback");
}
--- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
+++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
@@ -95,17 +95,17 @@ public:
static StaticRefPtr<nsSynthVoiceRegistry> gSynthVoiceRegistry;
NS_IMPL_ISUPPORTS(nsSynthVoiceRegistry, nsISynthVoiceRegistry)
nsSynthVoiceRegistry::nsSynthVoiceRegistry()
: mSpeechSynthChild(nullptr)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
mSpeechSynthChild = new SpeechSynthesisChild();
ContentChild::GetSingleton()->SendPSpeechSynthesisConstructor(mSpeechSynthChild);
InfallibleTArray<RemoteVoice> voices;
InfallibleTArray<nsString> defaults;
mSpeechSynthChild->SendReadVoiceList(&voices, &defaults);
@@ -160,17 +160,17 @@ nsSynthVoiceRegistry::GetInstanceForServ
return registry.forget();
}
void
nsSynthVoiceRegistry::Shutdown()
{
LOG(LogLevel::Debug, ("[%s] nsSynthVoiceRegistry::Shutdown()",
- (XRE_GetProcessType() == GeckoProcessType_Content) ? "Content" : "Default"));
+ (XRE_IsContentProcess()) ? "Content" : "Default"));
gSynthVoiceRegistry = nullptr;
}
void
nsSynthVoiceRegistry::SendVoices(InfallibleTArray<RemoteVoice>* aVoices,
InfallibleTArray<nsString>* aDefaults)
{
for (uint32_t i=0; i < mVoices.Length(); ++i) {
@@ -231,31 +231,31 @@ nsSynthVoiceRegistry::AddVoice(nsISpeech
bool aLocalService)
{
LOG(LogLevel::Debug,
("nsSynthVoiceRegistry::AddVoice uri='%s' name='%s' lang='%s' local=%s",
NS_ConvertUTF16toUTF8(aUri).get(), NS_ConvertUTF16toUTF8(aName).get(),
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,
aLocalService);
}
NS_IMETHODIMP
nsSynthVoiceRegistry::RemoveVoice(nsISpeechService* aService,
const nsAString& aUri)
{
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);
NS_ENSURE_TRUE(found, NS_ERROR_NOT_AVAILABLE);
NS_ENSURE_TRUE(aService == retval->mService, NS_ERROR_INVALID_ARG);
mVoices.RemoveElement(retval);
@@ -284,17 +284,17 @@ nsSynthVoiceRegistry::SetDefaultVoice(co
LOG(LogLevel::Debug, ("nsSynthVoiceRegistry::SetDefaultVoice %s %s",
NS_ConvertUTF16toUTF8(aUri).get(),
aIsDefault ? "true" : "false"));
if (aIsDefault) {
mDefaultVoices.AppendElement(retval);
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsTArray<SpeechSynthesisParent*> ssplist;
GetAllSpeechSynthActors(ssplist);
for (uint32_t i = 0; i < ssplist.Length(); ++i) {
unused << ssplist[i]->SendSetDefaultVoice(nsString(aUri), aIsDefault);
}
}
@@ -516,17 +516,17 @@ nsSynthVoiceRegistry::SpeakUtterance(Spe
nsString lang = nsString(aUtterance.mLang.IsEmpty() ? aDocLang : aUtterance.mLang);
nsAutoString uri;
if (aUtterance.mVoice) {
aUtterance.mVoice->GetVoiceURI(uri);
}
nsRefPtr<nsSpeechTask> task;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
task = new SpeechTaskChild(&aUtterance);
SpeechSynthesisRequestChild* actor =
new SpeechSynthesisRequestChild(static_cast<SpeechTaskChild*>(task.get()));
mSpeechSynthChild->SendPSpeechSynthesisRequestConstructor(actor,
aUtterance.mText,
lang,
uri,
aUtterance.Volume(),
--- a/dom/media/webspeech/synth/pico/nsPicoService.cpp
+++ b/dom/media/webspeech/synth/pico/nsPicoService.cpp
@@ -718,17 +718,17 @@ nsPicoService::CurrentVoice()
}
// static methods
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;
}
if (!sSingleton) {
sSingleton = new nsPicoService();
}
--- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp
+++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp
@@ -321,17 +321,17 @@ nsFakeSynthServices::Observe(nsISupports
}
// static methods
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;
}
if (!sSingleton) {
sSingleton = new nsFakeSynthServices();
}
--- a/dom/mobileconnection/MobileConnectionArray.cpp
+++ b/dom/mobileconnection/MobileConnectionArray.cpp
@@ -96,17 +96,17 @@ MobileConnectionArray::IndexedGetter(uin
return mMobileConnections[aIndex];
}
already_AddRefed<nsIMobileConnectionService>
NS_CreateMobileConnectionService()
{
nsCOMPtr<nsIMobileConnectionService> 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)
service = do_GetService(GONK_MOBILECONNECTION_SERVICE_CONTRACTID);
#endif
}
return service.forget();
--- a/dom/mobilemessage/MobileMessageManager.cpp
+++ b/dom/mobilemessage/MobileMessageManager.cpp
@@ -840,34 +840,34 @@ MobileMessageManager::SetSmscAddress(con
} // namespace dom
} // namespace mozilla
already_AddRefed<nsISmsService>
NS_CreateSmsService()
{
nsCOMPtr<nsISmsService> smsService;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
smsService = SmsIPCService::GetSingleton();
} else {
#ifdef MOZ_WIDGET_ANDROID
smsService = new SmsService();
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
smsService = do_GetService(GONK_SMSSERVICE_CONTRACTID);
#endif
}
return smsService.forget();
}
already_AddRefed<nsIMobileMessageDatabaseService>
NS_CreateMobileMessageDatabaseService()
{
nsCOMPtr<nsIMobileMessageDatabaseService> mobileMessageDBService;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
mobileMessageDBService = SmsIPCService::GetSingleton();
} else {
#ifdef MOZ_WIDGET_ANDROID
mobileMessageDBService = new MobileMessageDatabaseService();
#elif defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
mobileMessageDBService =
do_CreateInstance(GONK_MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID);
#endif
@@ -876,17 +876,17 @@ NS_CreateMobileMessageDatabaseService()
return mobileMessageDBService.forget();
}
already_AddRefed<nsIMmsService>
NS_CreateMmsService()
{
nsCOMPtr<nsIMmsService> mmsService;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
mmsService = SmsIPCService::GetSingleton();
} else {
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_RIL)
mmsService = do_CreateInstance("@mozilla.org/mms/gonkmmsservice;1");
#endif
}
return mmsService.forget();
--- a/dom/network/UDPSocket.cpp
+++ b/dom/network/UDPSocket.cpp
@@ -553,17 +553,17 @@ UDPSocket::Init(const nsString& aLocalAd
}
uint16_t localPort = 0;
if (!mSocket->mLocalPort.IsNull()) {
localPort = mSocket->mLocalPort.Value();
}
nsresult rv;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
rv = mSocket->InitRemote(mSocket->mLocalAddress, localPort);
} else {
rv = mSocket->InitLocal(mSocket->mLocalAddress, localPort);
}
if (NS_WARN_IF(NS_FAILED(rv))) {
mSocket->CloseWithReason(NS_ERROR_DOM_NETWORK_ERR);
}
--- a/dom/nfc/gonk/NfcService.cpp
+++ b/dom/nfc/gonk/NfcService.cpp
@@ -307,17 +307,17 @@ NfcService::NfcService()
NfcService::~NfcService()
{
MOZ_ASSERT(!gNfcService);
}
already_AddRefed<NfcService>
NfcService::FactoryCreate()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
MOZ_ASSERT(NS_IsMainThread());
if (!gNfcService) {
gNfcService = new NfcService();
ClearOnShutdown(&gNfcService);
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -244,17 +244,17 @@ nsNPAPIPlugin::PluginCrashed(const nsASt
{
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
host->PluginCrashed(this, pluginDumpID, browserDumpID);
}
bool
nsNPAPIPlugin::RunPluginOOP(const nsPluginTag *aPluginTag)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return true;
}
#if (MOZ_WIDGET_GTK == 3)
// We force OOP on Linux/GTK3 because some plugins use GTK2 and both GTK
// libraries can't be loaded in the same process.
return true;
#else
@@ -399,17 +399,17 @@ nsNPAPIPlugin::RunPluginOOP(const nsPlug
inline PluginLibrary*
GetNewPluginLibrary(nsPluginTag *aPluginTag)
{
if (!aPluginTag) {
return nullptr;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return PluginModuleContentParent::LoadModule(aPluginTag->mId);
}
if (nsNPAPIPlugin::RunPluginOOP(aPluginTag)) {
return PluginModuleChromeParent::LoadModule(aPluginTag->mFullPath.get(), aPluginTag->mId, aPluginTag);
}
return new PluginPRLibrary(aPluginTag->mFullPath.get(), aPluginTag->mLibrary);
}
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -248,17 +248,17 @@ static bool UnloadPluginsASAP()
nsPluginHost::nsPluginHost()
// No need to initialize members to nullptr, false etc because this class
// has a zeroing operator new.
{
// Bump the pluginchanged epoch on startup. This insures content gets a
// 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();
}
// check to see if pref is set at startup to let plugins take over in
// full page mode for certain image mime types that we handle internally
mOverrideInternalTypes =
Preferences::GetBool("plugin.override_internal_types", false);
@@ -1266,17 +1266,17 @@ nsresult nsPluginHost::EnsurePluginLoade
aPluginTag->mPlugin = plugin;
}
return NS_OK;
}
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();
nsPluginTag* pluginTag = PluginWithId(aPluginId);
if (pluginTag) {
// When setting up a bridge, double check with chrome to see if this plugin
// is blocked hard. Note this does not protect against vulnerable plugins
@@ -1331,17 +1331,17 @@ public:
protected:
uint32_t mPluginId;
};
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.
nsRefPtr<nsPluginUnloadRunnable> runnable =
new nsPluginUnloadRunnable(aPluginId);
NS_DispatchToMainThread(runnable);
}
@@ -1837,17 +1837,17 @@ nsPluginHost::AddPluginTag(nsPluginTag*
}
typedef NS_NPAPIPLUGIN_CALLBACK(char *, NP_GETMIMEDESCRIPTION)(void);
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;
*aPluginsChanged = false;
#ifdef PLUGIN_LOGGING
nsAutoCString dirPath;
@@ -2044,17 +2044,17 @@ nsresult nsPluginHost::ScanPluginsDirect
return NS_OK;
}
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) {
nsCOMPtr<nsISupports> supports;
nsresult rv = dirEnum->GetNext(getter_AddRefs(supports));
if (NS_FAILED(rv))
continue;
nsCOMPtr<nsIFile> nextDir(do_QueryInterface(supports, &rv));
@@ -2073,38 +2073,38 @@ nsresult nsPluginHost::ScanPluginsDirect
break;
}
return NS_OK;
}
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;
}
#ifdef XP_WIN
static void
WatchRegKey(uint32_t aRoot, nsCOMPtr<nsIWindowsRegKey>& aKey)
{
if (aKey) {
@@ -2124,17 +2124,17 @@ WatchRegKey(uint32_t aRoot, nsCOMPtr<nsI
}
aKey->StartWatching(true);
}
#endif
nsresult nsPluginHost::LoadPlugins()
{
#ifdef ANDROID
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return NS_OK;
}
#endif
// do not do anything if it is already done
// use ReloadPlugins() to enforce loading
if (mPluginsLoaded)
return NS_OK;
@@ -2148,33 +2148,33 @@ nsresult nsPluginHost::LoadPlugins()
bool pluginschanged;
nsresult rv = FindPlugins(true, &pluginschanged);
if (NS_FAILED(rv))
return rv;
// only if plugins have changed will we notify plugin-change observers
if (pluginschanged) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
IncrementChromeEpoch();
}
nsCOMPtr<nsIObserverService> obsService =
mozilla::services::GetObserverService();
if (obsService)
obsService->NotifyObservers(nullptr, "plugins-list-updated", nullptr);
}
return NS_OK;
}
nsresult
nsPluginHost::FindPluginsInContent(bool aCreatePluginList, bool* aPluginsChanged)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
+ MOZ_ASSERT(XRE_IsContentProcess());
dom::ContentChild* cp = dom::ContentChild::GetSingleton();
nsTArray<PluginTag> plugins;
uint32_t parentEpoch;
if (!cp->SendFindPlugins(ChromeEpochForContent(), &plugins, &parentEpoch)) {
return NS_ERROR_NOT_AVAILABLE;
}
@@ -2220,17 +2220,17 @@ nsPluginHost::FindPluginsInContent(bool
nsresult nsPluginHost::FindPlugins(bool aCreatePluginList, bool * aPluginsChanged)
{
Telemetry::AutoTimer<Telemetry::FIND_PLUGINS> telemetry;
NS_ENSURE_ARG_POINTER(aPluginsChanged);
*aPluginsChanged = false;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return FindPluginsInContent(aCreatePluginList, aPluginsChanged);
}
nsresult rv;
// Read cached plugins info. If the profile isn't yet available then don't
// scan for plugins
if (ReadPluginInfo() == NS_ERROR_NOT_AVAILABLE)
@@ -2387,29 +2387,29 @@ nsresult nsPluginHost::FindPlugins(bool
return NS_OK;
}
bool
mozilla::plugins::FindPluginsForContent(uint32_t aPluginEpoch,
nsTArray<PluginTag>* aPlugins,
uint32_t* aNewPluginEpoch)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
host->FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch);
return true;
}
void
nsPluginHost::FindPluginsForContent(uint32_t aPluginEpoch,
nsTArray<PluginTag>* aPlugins,
uint32_t* aNewPluginEpoch)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
// Load plugins so that the epoch is correct.
LoadPlugins();
*aNewPluginEpoch = ChromeEpoch();
if (aPluginEpoch == ChromeEpoch()) {
return;
}
@@ -2439,17 +2439,17 @@ nsPluginHost::FindPluginsForContent(uint
tag->mLastModifiedTime,
tag->IsFromExtension()));
}
}
void
nsPluginHost::UpdatePluginInfo(nsPluginTag* aPluginTag)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
ReadPluginInfo();
WritePluginInfo();
NS_ITERATIVE_UNREF_LIST(nsRefPtr<nsPluginTag>, mCachedPlugins, mNext);
NS_ITERATIVE_UNREF_LIST(nsRefPtr<nsInvalidPluginTag>, mInvalidPlugins, mNext);
if (!aPluginTag) {
return;
@@ -2525,17 +2525,17 @@ nsPluginHost::RegisterWithCategoryManage
true);
}
}
}
nsresult
nsPluginHost::WritePluginInfo()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsresult rv = NS_OK;
nsCOMPtr<nsIProperties> directoryService(do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID,&rv));
if (NS_FAILED(rv))
return rv;
directoryService->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
getter_AddRefs(mPluginRegFile));
@@ -2670,17 +2670,17 @@ nsPluginHost::WritePluginInfo()
NS_ENSURE_SUCCESS(rv, rv);
rv = pluginReg->MoveToNative(parent, kPluginRegistryFilename);
return rv;
}
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;
// we need to import the legacy flags from the plugin registry once
const bool pluginStateImported =
Preferences::GetDefaultBool("plugin.importedState", false);
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -647,17 +647,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Get
// Given that this HWND may not be that of the document's window, there is a slight risk
// of confusing a plugin that is using this HWND for illicit purposes, but since the documentation
// does not suggest this HWND IS that of the document window, rather that of the window
// the plugin is drawn in, this seems like a safe fix.
// 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
// now we only return the enclosing window when there is an actual offset which
// would otherwise cause coordinates to be offset incorrectly. (i.e.
// if the enclosing window if offset from the document window)
//
// fixing both the caret and ability to interact issues for a windowless control in a non document aligned windw
@@ -2835,17 +2835,17 @@ NS_IMETHODIMP nsPluginInstanceOwner::Cre
nsCOMPtr<nsIWidget> parentWidget;
nsIDocument *doc = nullptr;
nsCOMPtr<nsIContent> content = do_QueryReferent(mContent);
if (content) {
doc = content->OwnerDoc();
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<nsIDOMWindow> window = doc->GetWindow();
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
if (topWindow) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {
// This returns a PluginWidgetProxy which remotes a number of calls.
@@ -2957,17 +2957,17 @@ void nsPluginInstanceOwner::FixUpPluginW
// fix up the clipping region
mPluginWindow->clipRect.top = 0;
mPluginWindow->clipRect.left = 0;
if (inPaintState == ePluginPaintDisable) {
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
// for even if the plugin is mostly outside of the scroll port. Thus
// we never trim the window to the bounds of the widget.
mPluginWindow->clipRect.bottom = mPluginWindow->clipRect.top + mPluginWindow->height;
mPluginWindow->clipRect.right = mPluginWindow->clipRect.left + mPluginWindow->width;
}
@@ -3151,17 +3151,17 @@ nsPluginInstanceOwner::UpdateDocumentAct
}
#endif // #ifdef MOZ_WIDGET_ANDROID
// We don't have a connection to PluginWidgetParent in the chrome
// process when dealing with tab visibility changes, so this needs
// 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);
}
#endif // #ifndef XP_MACOSX
}
NS_IMETHODIMP
nsPluginInstanceOwner::CallSetWindow()
--- a/dom/plugins/base/nsPluginNativeWindowGtk.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowGtk.cpp
@@ -67,17 +67,17 @@ nsresult PLUG_DeletePluginNativeWindow(n
delete p;
return NS_OK;
}
nsresult nsPluginNativeWindowGtk::CallSetWindow(nsRefPtr<nsNPAPIPluginInstance> &aPluginInstance)
{
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.
SetWindow((XID)window);
} else if (type == NPWindowTypeWindow) {
if (!mSocketWidget) {
nsresult rv;
--- a/dom/plugins/base/nsPluginNativeWindowWin.cpp
+++ b/dom/plugins/base/nsPluginNativeWindowWin.cpp
@@ -612,17 +612,17 @@ nsresult nsPluginNativeWindowWin::CallSe
if (NS_SUCCEEDED(aPluginInstance->GetMIMEType(&mimetype)) && mimetype) {
mPluginType = nsPluginHost::GetSpecialType(nsDependentCString(mimetype));
}
}
// 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;
}
if (window) {
// grab the widget procedure before the plug-in does a subclass in
// setwindow. We'll use this in PluginWndProc for forwarding focus
// events to the widget.
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -646,17 +646,17 @@ nsPluginTag::GetBlocklistState(uint32_t
*aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
return NS_OK;
#else
if (mCachedBlocklistStateValid) {
*aResult = mCachedBlocklistState;
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)) {
return NS_OK;
}
} else {
nsCOMPtr<nsIBlocklistService> blocklist =
do_GetService("@mozilla.org/extensions/blocklist;1");
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -1851,17 +1851,17 @@ PluginInstanceParent::PluginWindowHookPr
void
PluginInstanceParent::SubclassPluginWindow(HWND aWnd)
{
if ((aWnd && mPluginHWND == aWnd) || (!aWnd && mPluginHWND)) {
return;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
if (!aWnd) {
NS_WARNING("PluginInstanceParent::SubclassPluginWindow unexpected null window");
return;
}
mPluginHWND = aWnd; // now a remote window, we can't subclass this
mPluginWndProc = nullptr;
// Note sPluginInstanceList wil delete 'this' if we do not remove
// it on shutdown.
@@ -1881,17 +1881,17 @@ PluginInstanceParent::SubclassPluginWind
"PluginInstanceParent::SubclassPluginWindow failed to set subclass!");
NS_ASSERTION(bRes,
"PluginInstanceParent::SubclassPluginWindow failed to set prop!");
}
void
PluginInstanceParent::UnsubclassPluginWindow()
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
if (mPluginHWND) {
// Remove 'this' from the plugin list safely
nsAutoPtr<PluginInstanceParent> tmp;
MOZ_ASSERT(sPluginInstanceList);
sPluginInstanceList->RemoveAndForget((void*)mPluginHWND, tmp);
tmp.forget();
if (!sPluginInstanceList->Count()) {
delete sPluginInstanceList;
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -347,17 +347,17 @@ PRCList PluginModuleMapping::sModuleList
bool PluginModuleMapping::sIsLoadModuleOnStack = false;
} // anonymous namespace
void
mozilla::plugins::TerminatePlugin(uint32_t aPluginId, const nsString& aBrowserDumpId)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsRefPtr<nsPluginHost> host = nsPluginHost::GetInst();
nsPluginTag* pluginTag = host->PluginWithId(aPluginId);
if (!pluginTag || !pluginTag->mPlugin) {
return;
}
nsRefPtr<nsNPAPIPlugin> plugin = pluginTag->mPlugin;
PluginModuleChromeParent* chromeParent = static_cast<PluginModuleChromeParent*>(plugin->GetLibrary());
@@ -365,17 +365,17 @@ mozilla::plugins::TerminatePlugin(uint32
}
/* static */ PluginLibrary*
PluginModuleContentParent::LoadModule(uint32_t aPluginId)
{
PluginModuleMapping::NotifyLoadingModule loadingModule;
nsAutoPtr<PluginModuleMapping> 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
* message. Before it sends its response, it sends a message to create
* PluginModuleParent instance. That message is handled by
* PluginModuleContentParent::Initialize, which saves the instance in
* its module mapping. We fetch it from there after LoadPlugin finishes.
*/
--- a/dom/promise/PromiseDebugging.cpp
+++ b/dom/promise/PromiseDebugging.cpp
@@ -91,17 +91,17 @@ PromiseDebugging::sIDPrefix;
/* static */ void
PromiseDebugging::Init()
{
FlushRejections::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 {
sIDPrefix.AppendLiteral("0.");
}
}
/* static */ void
--- a/dom/quota/QuotaManager.cpp
+++ b/dom/quota/QuotaManager.cpp
@@ -751,21 +751,16 @@ struct MOZ_STACK_CLASS InactiveOriginsIn
origins(aOrigins)
{ }
OriginCollection& persistentCollection;
OriginCollection& temporaryCollection;
nsTArray<OriginInfo*>& origins;
};
-bool
-IsMainProcess()
-{
- return XRE_GetProcessType() == GeckoProcessType_Default;
-}
void
SanitizeOriginString(nsCString& aOrigin)
{
// We want profiles to be platform-independent so we always need to replace
// the same characters on every platform. Windows has the most extensive set
// of illegal characters so we use its FILE_ILLEGAL_CHARACTERS and
// FILE_PATH_SEPARATOR.
@@ -1365,17 +1360,17 @@ QuotaManager::IsShuttingDown()
{
return gShutdown;
}
nsresult
QuotaManager::Init()
{
nsresult rv;
- if (IsMainProcess()) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIFile> baseDir;
rv = NS_GetSpecialDirectory(NS_APP_INDEXEDDB_PARENT_DIR,
getter_AddRefs(baseDir));
if (NS_FAILED(rv)) {
rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
getter_AddRefs(baseDir));
}
NS_ENSURE_SUCCESS(rv, rv);
@@ -2786,17 +2781,17 @@ QuotaManager::GetUsageForURI(nsIURI* aUR
nsIQuotaRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ENSURE_ARG_POINTER(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;
}
// Figure out which origin we're dealing with.
nsCString group;
nsCString origin;
@@ -2874,17 +2869,17 @@ QuotaManager::ClearStoragesForURI(nsIURI
Nullable<PersistenceType> persistenceType;
nsresult rv =
NullablePersistenceTypeFromText(aPersistenceType, &persistenceType);
if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_INVALID_ARG;
}
// 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;
}
// Figure out which origin we're dealing with.
nsCString origin;
rv = GetInfoFromURI(aURI, aAppId, aInMozBrowserOnly, nullptr, &origin,
@@ -2977,17 +2972,17 @@ QuotaManager::Observe(nsISupports* aSubj
if (!strcmp(aTopic, PROFILE_BEFORE_CHANGE_OBSERVER_ID)) {
// Setting this flag prevents the service from being recreated and prevents
// further storagess from being created.
if (gShutdown.exchange(true)) {
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))) {
NS_WARNING("Failed to initialize shutdown timer!");
}
// Each client will spin the event loop while we wait on all the threads
// to close. Our timer may fire during that loop.
@@ -3016,17 +3011,17 @@ QuotaManager::Observe(nsISupports* aSubj
NS_WARNING("Failed to shutdown IO thread!");
}
}
return NS_OK;
}
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!");
// Grab all live storages, for all origins.
StorageMatcher<nsAutoTArray<nsIOfflineStorage*, 50> > liveStorages;
liveStorages.Find(mLiveStorages);
@@ -3210,17 +3205,17 @@ QuotaManager::FindSynchronizedOp(const n
nsresult
QuotaManager::ClearStoragesForApp(uint32_t aAppId, bool aBrowserOnly)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
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);
// Clear both temporary and persistent storages.
Nullable<PersistenceType> persistenceType;
// If there is a pending or running clear operation for this app, return
--- a/dom/speakermanager/SpeakerManagerService.cpp
+++ b/dom/speakermanager/SpeakerManagerService.cpp
@@ -25,17 +25,17 @@ using namespace mozilla::dom;
StaticRefPtr<SpeakerManagerService> gSpeakerManagerService;
// static
SpeakerManagerService*
SpeakerManagerService::GetOrCreateSpeakerManagerService()
{
MOZ_ASSERT(NS_IsMainThread());
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return SpeakerManagerServiceChild::GetOrCreateSpeakerManagerService();
}
// If we already exist, exit early
if (gSpeakerManagerService) {
return gSpeakerManagerService;
}
@@ -47,27 +47,27 @@ SpeakerManagerService::GetOrCreateSpeake
return gSpeakerManagerService;
}
SpeakerManagerService*
SpeakerManagerService::GetSpeakerManagerService()
{
MOZ_ASSERT(NS_IsMainThread());
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return SpeakerManagerServiceChild::GetSpeakerManagerService();
}
return gSpeakerManagerService;
}
void
SpeakerManagerService::Shutdown()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return SpeakerManagerServiceChild::Shutdown();
}
if (gSpeakerManagerService) {
gSpeakerManagerService = nullptr;
}
}
@@ -183,17 +183,17 @@ SpeakerManagerService::Observe(nsISuppor
return NS_OK;
}
SpeakerManagerService::SpeakerManagerService()
: mOrgSpeakerStatus(false),
mVisible(false)
{
MOZ_COUNT_CTOR(SpeakerManagerService);
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->AddObserver(this, "ipc:content-shutdown", false);
}
}
AudioChannelService* audioChannelService =
AudioChannelService::GetOrCreateAudioChannelService();
if (audioChannelService) {
--- a/dom/storage/DOMStorageCache.cpp
+++ b/dom/storage/DOMStorageCache.cpp
@@ -756,17 +756,17 @@ DOMStorageCache::StartDatabase()
{
if (sDatabase || sDatabaseDown) {
// When sDatabaseDown is at true, sDatabase is null.
// Checking sDatabaseDown flag here prevents reinitialization of
// the database after shutdown.
return sDatabase;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsAutoPtr<DOMStorageDBThread> db(new DOMStorageDBThread());
nsresult rv = db->Init();
if (NS_FAILED(rv)) {
return nullptr;
}
sDatabase = db.forget();
@@ -801,17 +801,17 @@ DOMStorageCache::StopDatabase()
{
if (!sDatabase) {
return NS_OK;
}
sDatabaseDown = true;
nsresult rv = sDatabase->Shutdown();
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
delete sDatabase;
} else {
DOMStorageDBChild* child = static_cast<DOMStorageDBChild*>(sDatabase);
NS_RELEASE(child);
}
sDatabase = nullptr;
return rv;
--- a/dom/storage/DOMStorageManager.cpp
+++ b/dom/storage/DOMStorageManager.cpp
@@ -587,17 +587,17 @@ DOMStorageManager::Observe(const char* a
// This immediately completely reloads all caches from the database.
ClearCacheEnumeratorData data(DOMStorageCache::kTestReload);
mCaches.EnumerateEntries(ClearCacheEnumerator, &data);
return NS_OK;
}
if (!strcmp(aTopic, "test-flushed")) {
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
obs->NotifyObservers(nullptr, "domstorage-test-flushed", nullptr);
}
}
return NS_OK;
}
@@ -610,17 +610,17 @@ DOMStorageManager::Observe(const char* a
// DOMLocalStorageManager
DOMLocalStorageManager::DOMLocalStorageManager()
: DOMStorageManager(LocalStorage)
{
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
DOMStorageCache::StartDatabase();
}
}
DOMLocalStorageManager::~DOMLocalStorageManager()
@@ -643,17 +643,17 @@ DOMLocalStorageManager::Ensure()
return sSelf;
}
// DOMSessionStorageManager
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();
}
}
} // ::dom
} // ::mozilla
--- a/dom/storage/DOMStorageObserver.cpp
+++ b/dom/storage/DOMStorageObserver.cpp
@@ -70,17 +70,17 @@ DOMStorageObserver::Init()
obs->AddObserver(sSelf, "xpcom-shutdown", true);
// Observe low device storage notifications.
obs->AddObserver(sSelf, "disk-space-watcher", true);
#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);
}
obs->AddObserver(sSelf, "domstorage-test-reload", true);
#endif
return NS_OK;
--- a/dom/system/gonk/AudioManager.cpp
+++ b/dom/system/gonk/AudioManager.cpp
@@ -550,17 +550,17 @@ AudioManager::~AudioManager() {
}
static StaticRefPtr<AudioManager> sAudioManager;
already_AddRefed<AudioManager>
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.");
}
// Avoid createing multiple AudioManager instance inside main process.
if (!sAudioManager) {
sAudioManager = new AudioManager();
ClearOnShutdown(&sAudioManager);
}
--- a/dom/system/gonk/AutoMounter.cpp
+++ b/dom/system/gonk/AutoMounter.cpp
@@ -1293,57 +1293,57 @@ ShutdownAutoMounterIOThread()
sAutoMounter = nullptr;
ShutdownVolumeManager();
}
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);
sAutoMounter->SetMode(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);
sAutoMounter->SetSharingMode(aVolumeName, aAllowSharing);
}
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);
sAutoMounter->FormatVolume(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);
sAutoMounter->MountVolume(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);
sAutoMounter->UnmountVolume(aVolumeName);
}
static void
UsbCableEventIOThread()
--- a/dom/system/gonk/NetworkWorker.cpp
+++ b/dom/system/gonk/NetworkWorker.cpp
@@ -129,17 +129,17 @@ NetworkWorker::~NetworkWorker()
{
MOZ_ASSERT(!gNetworkWorker);
MOZ_ASSERT(!mListener);
}
already_AddRefed<NetworkWorker>
NetworkWorker::FactoryCreate()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
MOZ_ASSERT(NS_IsMainThread());
if (!gNetworkWorker) {
gNetworkWorker = new NetworkWorker();
ClearOnShutdown(&gNetworkWorker);
--- a/dom/system/gonk/SystemWorkerManager.cpp
+++ b/dom/system/gonk/SystemWorkerManager.cpp
@@ -67,17 +67,17 @@ SystemWorkerManager::~SystemWorkerManage
NS_ASSERTION(!gInstance || gInstance == this,
"There should only be one instance!");
gInstance = nullptr;
}
nsresult
SystemWorkerManager::Init()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return NS_ERROR_NOT_AVAILABLE;
}
NS_ASSERTION(NS_IsMainThread(), "We can only initialize on the main thread");
NS_ASSERTION(!mShutdown, "Already shutdown!");
mozilla::AutoSafeJSContext cx;
--- a/dom/system/gonk/Volume.cpp
+++ b/dom/system/gonk/Volume.cpp
@@ -228,17 +228,17 @@ Volume::SetConfig(const nsCString& aConf
return;
}
ERR("Volume %s: invalid config '%s'", NameStr(), aConfigName.get());
}
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
// when media is removed (while Idle), we get the following:
// 631 Volume sdcard /mnt/sdcard disk removed (179:0)
// 605 Volume sdcard /mnt/sdcard state changed from 1 (Idle-Unmounted) to 0 (No-Media)
//
// And on media insertion, we get:
@@ -303,17 +303,17 @@ Volume::SetUnmountRequested(bool aUnmoun
LOG("SetUnmountRequested for volume %s to %d CanBeMounted = %d",
NameStr(), (int)mUnmountRequested, (int)CanBeMounted());
}
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;
}
if (aNewState == nsIVolume::STATE_MOUNTED) {
mMountGeneration = ++sMountGeneration;
LOG("Volume %s (%u): changing state from %s to %s @ '%s' (%d observers) "
"mountGeneration = %d, locked = %d",
@@ -375,85 +375,85 @@ Volume::SetState(Volume::STATE aNewState
}
mState = aNewState;
sEventObserverList.Broadcast(this);
}
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)) {
return;
}
mMountPoint = aMountPoint;
DBG("Volume %s: Setting mountpoint to '%s'", NameStr(), mMountPoint.get());
}
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));
}
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));
}
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));
}
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));
}
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));
}
void
Volume::StartCommand(VolumeCommand* aCommand)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(MessageLoop::current() == XRE_GetIOMessageLoop());
VolumeManager::PostCommand(aCommand);
}
//static
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);
DBG("Added Volume Observer '%s' @%p, length = %u",
aName, aObserver, sEventObserverList.Length());
// Send an initial event to the observer (for each volume)
@@ -463,49 +463,49 @@ Volume::RegisterVolumeObserver(Volume::E
aObserver->Notify(vol);
}
}
//static
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);
DBG("Removed Volume Observer '%s' @%p, length = %u",
aName, aObserver, sEventObserverList.Length());
}
//static
void
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<Volume> vol = VolumeManager::FindVolumeByName(aVolumeName);
if (!vol || (vol->mMountGeneration != aMountGeneration)) {
return;
}
if (vol->mMountLocked != aMountLocked) {
vol->mMountLocked = aMountLocked;
DBG("Volume::UpdateMountLock for '%s' to %d\n", vol->NameStr(), (int)aMountLocked);
sEventObserverList.Broadcast(vol);
}
}
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
// to the token after the volume name
switch (aResponseCode) {
case ::ResponseCode::VolumeListResult: {
// Each line will look something like:
//
--- a/dom/system/gonk/nsVolume.cpp
+++ b/dom/system/gonk/nsVolume.cpp
@@ -241,77 +241,77 @@ NS_IMETHODIMP nsVolume::GetIsRemovable(b
NS_IMETHODIMP nsVolume::GetIsHotSwappable(bool *aIsHotSwappable)
{
*aIsHotSwappable = mIsHotSwappable;
return NS_OK;
}
NS_IMETHODIMP nsVolume::Format()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(FormatVolumeIOThread, NameStr()));
return NS_OK;
}
/* 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) {
return;
}
AutoMounterFormatVolume(aVolume);
}
NS_IMETHODIMP nsVolume::Mount()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(MountVolumeIOThread, NameStr()));
return NS_OK;
}
/* 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) {
return;
}
AutoMounterMountVolume(aVolume);
}
NS_IMETHODIMP nsVolume::Unmount()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
XRE_GetIOMessageLoop()->PostTask(
FROM_HERE,
NewRunnableFunction(UnmountVolumeIOThread, NameStr()));
return NS_OK;
}
/* 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) {
return;
}
AutoMounterUnmountVolume(aVolume);
}
@@ -359,17 +359,17 @@ void nsVolume::Set(nsIVolume* aVolume)
}
if (mMountGeneration == volMountGeneration) {
// No change in mount generation, nothing else to do
return;
}
mMountGeneration = volMountGeneration;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
// Child processes just track the state, not maintain it.
aVolume->GetIsMountLocked(&mMountLocked);
return;
}
// Notify the Volume on IOThread whether the volume is locked or not.
nsCOMPtr<nsIPowerManagerService> pmService =
do_GetService(POWERMANAGERSERVICE_CONTRACTID);
@@ -381,28 +381,28 @@ void nsVolume::Set(nsIVolume* aVolume)
nsString mountLockState;
pmService->GetWakeLockState(mountLockName, mountLockState);
UpdateMountLock(mountLockState);
}
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
// I figured it was easier to use negtive logic and compare for unlocked.
UpdateMountLock(!aMountLockState.EqualsLiteral("unlocked"));
}
void
nsVolume::UpdateMountLock(bool aMountLocked)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
if (aMountLocked == mMountLocked) {
return;
}
// The locked/unlocked state changed. Tell IOThread about it.
mMountLocked = aMountLocked;
LogState();
@@ -442,17 +442,17 @@ nsVolume::SetIsHotSwappable(bool aIsHotS
}
}
void
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());
if (aState == mState) {
return;
}
if (aState == nsIVolume::STATE_MOUNTED) {
--- a/dom/system/gonk/nsVolumeService.cpp
+++ b/dom/system/gonk/nsVolumeService.cpp
@@ -63,17 +63,17 @@ nsVolumeService::GetSingleton()
// static
void
nsVolumeService::Shutdown()
{
if (!sSingleton) {
return;
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
sSingleton = nullptr;
return;
}
nsCOMPtr<nsIPowerManagerService> pmService =
do_GetService(POWERMANAGERSERVICE_CONTRACTID);
if (pmService) {
pmService->RemoveWakeLockListener(sSingleton.get());
@@ -87,17 +87,17 @@ nsVolumeService::Shutdown()
}
nsVolumeService::nsVolumeService()
: mArrayMonitor("nsVolumeServiceArray"),
mGotVolumesFromParent(false)
{
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;
}
// Startup the IOThread side of things. The actual volume changes
// are captured by the IOThread and forwarded to main thread.
XRE_GetIOMessageLoop()->PostTask(
@@ -266,17 +266,17 @@ nsVolumeService::GetVolumeNames(nsIArray
volNames.forget(aVolNames);
return NS_OK;
}
void
nsVolumeService::GetVolumesForIPC(nsTArray<VolumeInfo>* aResult)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
MonitorAutoLock autoLock(mArrayMonitor);
nsVolume::Array::size_type numVolumes = mVolumeArray.Length();
nsVolume::Array::index_type volIndex;
for (volIndex = 0; volIndex < numVolumes; volIndex++) {
nsRefPtr<nsVolume> vol = mVolumeArray[volIndex];
@@ -294,17 +294,17 @@ nsVolumeService::GetVolumesForIPC(nsTArr
volInfo->isRemovable() = vol->mIsRemovable;
volInfo->isHotSwappable() = vol->mIsHotSwappable;
}
}
void
nsVolumeService::RecvVolumesFromParent(const nsTArray<VolumeInfo>& aVolumes)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
// We are the parent. Therefore our volumes are already correct.
return;
}
if (mGotVolumesFromParent) {
// We've already done this, no need to do it again.
return;
}
@@ -335,17 +335,17 @@ nsVolumeService::CreateMountLock(const n
mountLock.forget(aResult);
return NS_OK;
}
void
nsVolumeService::CheckMountLock(const nsAString& aMountLockName,
const nsAString& aMountLockState)
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(NS_IsMainThread());
nsRefPtr<nsVolume> vol = FindVolumeByMountLockName(aMountLockName);
if (vol) {
vol->UpdateMountLock(aMountLockState);
}
}
@@ -433,17 +433,17 @@ nsVolumeService::UpdateVolume(nsIVolume*
}
NS_ConvertUTF8toUTF16 stateStr(vol->StateStr());
obs->NotifyObservers(vol, NS_VOLUME_STATE_CHANGED, stateStr.get());
}
NS_IMETHODIMP
nsVolumeService::CreateFakeVolume(const nsAString& name, const nsAString& path)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<nsVolume> vol = new nsVolume(name, path, nsIVolume::STATE_INIT,
-1 /* mountGeneration */,
true /* isMediaPresent */,
false /* isSharing */,
false /* isFormatting */,
true /* isFake */,
false /* isUnmounting */,
false /* isRemovable */,
@@ -456,17 +456,17 @@ nsVolumeService::CreateFakeVolume(const
ContentChild::GetSingleton()->SendCreateFakeVolume(nsString(name), nsString(path));
return NS_OK;
}
NS_IMETHODIMP
nsVolumeService::SetFakeVolumeState(const nsAString& name, int32_t state)
{
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<nsVolume> vol;
{
MonitorAutoLock autoLock(mArrayMonitor);
vol = FindVolumeByName(name);
}
if (!vol || !vol->IsFake()) {
return NS_ERROR_NOT_AVAILABLE;
}
@@ -484,17 +484,17 @@ nsVolumeService::SetFakeVolumeState(cons
ContentChild::GetSingleton()->SendSetFakeVolumeState(nsString(name), state);
return NS_OK;
}
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;
}
ContentChild::GetSingleton()->SendRemoveFakeVolume(nsString(name));
return NS_OK;
}
@@ -507,17 +507,17 @@ nsVolumeService::RemoveVolumeByName(cons
MonitorAutoLock autoLock(mArrayMonitor);
vol = FindVolumeByName(aName);
}
if (!vol) {
return;
}
mVolumeArray.RemoveElement(vol);
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIObserverService> obs = GetObserverService();
if (!obs) {
return;
}
obs->NotifyObservers(nullptr, NS_VOLUME_REMOVED, nsString(aName).get());
}
}
--- a/dom/telephony/Telephony.cpp
+++ b/dom/telephony/Telephony.cpp
@@ -715,17 +715,17 @@ Telephony::DispatchCallEvent(const nsASt
return DispatchTrustedEvent(event);
}
already_AddRefed<nsITelephonyService>
NS_CreateTelephonyService()
{
nsCOMPtr<nsITelephonyService> 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)
service = do_CreateInstance(GONK_TELEPHONY_SERVICE_CONTRACTID);
#endif
}
return service.forget();
--- a/dom/voicemail/Voicemail.cpp
+++ b/dom/voicemail/Voicemail.cpp
@@ -245,17 +245,17 @@ Voicemail::NotifyStatusChanged(nsIVoicem
return DispatchTrustedEvent(event);
}
already_AddRefed<nsIVoicemailService>
NS_CreateVoicemailService()
{
nsCOMPtr<nsIVoicemailService> service;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
service = new mozilla::dom::voicemail::VoicemailIPCService();
} else {
#if defined(MOZ_B2G_RIL)
#if defined(MOZ_WIDGET_GONK)
service = do_GetService(GONK_VOICEMAIL_SERVICE_CONTRACTID);
#endif // MOZ_WIDGET_GONK
#endif // MOZ_B2G_RIL
}
--- a/dom/wifi/WifiCertService.cpp
+++ b/dom/wifi/WifiCertService.cpp
@@ -438,17 +438,17 @@ WifiCertService::WifiCertService()
WifiCertService::~WifiCertService()
{
MOZ_ASSERT(!gWifiCertService);
}
already_AddRefed<WifiCertService>
WifiCertService::FactoryCreate()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
MOZ_ASSERT(NS_IsMainThread());
if (!gWifiCertService) {
gWifiCertService = new WifiCertService();
ClearOnShutdown(&gWifiCertService);
--- a/dom/wifi/WifiProxyService.cpp
+++ b/dom/wifi/WifiProxyService.cpp
@@ -145,17 +145,17 @@ WifiProxyService::WifiProxyService()
WifiProxyService::~WifiProxyService()
{
MOZ_ASSERT(!gWifiProxyService);
}
already_AddRefed<WifiProxyService>
WifiProxyService::FactoryCreate()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
MOZ_ASSERT(NS_IsMainThread());
if (!gWifiProxyService) {
gWifiProxyService = new WifiProxyService();
ClearOnShutdown(&gWifiProxyService);
--- a/dom/workers/ServiceWorkerManager.cpp
+++ b/dom/workers/ServiceWorkerManager.cpp
@@ -397,17 +397,17 @@ ServiceWorkerManager::Init()
{
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
DebugOnly<nsresult> rv;
rv = obs->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false /* ownsWeak */);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<ServiceWorkerRegistrar> swr = ServiceWorkerRegistrar::Get();
MOZ_ASSERT(swr);
nsTArray<ServiceWorkerRegistrationData> data;
swr->GetRegistrations(data);
LoadRegistrations(data);
if (obs) {
@@ -4540,17 +4540,17 @@ ServiceWorkerManager::RemoveAll()
AssertIsOnMainThread();
mRegistrationInfos.EnumerateRead(UnregisterIfMatchesHostPerPrincipal, nullptr);
}
void
ServiceWorkerManager::PropagateRemoveAll()
{
AssertIsOnMainThread();
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (!mActor) {
nsRefPtr<nsIRunnable> runnable = new PropagateRemoveAllRunnable();
AppendPendingOperation(runnable);
return;
}
mActor->SendPropagateRemoveAll();
@@ -4597,31 +4597,31 @@ ServiceWorkerManager::UpdateAllRegistrat
}
NS_IMETHODIMP
ServiceWorkerManager::Observe(nsISupports* aSubject,
const char* aTopic,
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<mozIApplicationClearPrivateDataParams> params =
do_QueryInterface(aSubject);
if (NS_WARN_IF(!params)) {
return NS_OK;
}
uint32_t appId;
nsresult rv = params->GetAppId(&appId);
@@ -4651,17 +4651,17 @@ ServiceWorkerManager::Observe(nsISupport
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
mShuttingDown = true;
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
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);
}
}
if (mActor) {
mActor->ManagerShuttingDown();
--- a/dom/workers/ServiceWorkerPeriodicUpdater.cpp
+++ b/dom/workers/ServiceWorkerPeriodicUpdater.cpp
@@ -23,17 +23,17 @@ NS_IMPL_ISUPPORTS(ServiceWorkerPeriodicU
StaticRefPtr<ServiceWorkerPeriodicUpdater>
ServiceWorkerPeriodicUpdater::sInstance;
bool
ServiceWorkerPeriodicUpdater::sPeriodicUpdatesEnabled = true;
already_AddRefed<ServiceWorkerPeriodicUpdater>
ServiceWorkerPeriodicUpdater::GetSingleton()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
if (!sInstance) {
sInstance = new ServiceWorkerPeriodicUpdater();
ClearOnShutdown(&sInstance);
}
nsRefPtr<ServiceWorkerPeriodicUpdater> copy(sInstance.get());
return copy.forget();
}
--- a/dom/workers/ServiceWorkerRegistrar.cpp
+++ b/dom/workers/ServiceWorkerRegistrar.cpp
@@ -43,17 +43,17 @@ StaticRefPtr<ServiceWorkerRegistrar> gSe
NS_IMPL_ISUPPORTS(ServiceWorkerRegistrar,
nsIObserver)
void
ServiceWorkerRegistrar::Initialize()
{
MOZ_ASSERT(!gServiceWorkerRegistrar);
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
gServiceWorkerRegistrar = new ServiceWorkerRegistrar();
ClearOnShutdown(&gServiceWorkerRegistrar);
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
if (obs) {
@@ -65,17 +65,17 @@ ServiceWorkerRegistrar::Initialize()
false);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
}
/* static */ already_AddRefed<ServiceWorkerRegistrar>
ServiceWorkerRegistrar::Get()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
MOZ_ASSERT(gServiceWorkerRegistrar);
nsRefPtr<ServiceWorkerRegistrar> service = gServiceWorkerRegistrar.get();
return service.forget();
}
ServiceWorkerRegistrar::ServiceWorkerRegistrar()
: mMonitor("ServiceWorkerRegistrar.mMonitor")
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2698,17 +2698,17 @@ private:
nsCOMPtr<nsIURI> scriptURI;
if (NS_FAILED(NS_NewURI(getter_AddRefs(scriptURI),
mWorkerPrivate->ScriptURL()))) {
return;
}
mAlreadyMappedToAddon = true;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
// Only try to access the service from the main process.
return;
}
nsAutoCString addonId;
bool ok;
nsCOMPtr<amIAddonManager> addonManager =
do_GetService("@mozilla.org/addons/integration;1");
--- a/embedding/browser/nsWebBrowser.cpp
+++ b/embedding/browser/nsWebBrowser.cpp
@@ -1233,17 +1233,17 @@ nsWebBrowser::Create()
// event.
if (!mInitInfo->sessionHistory) {
mInitInfo->sessionHistory = do_CreateInstance(NS_SHISTORY_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
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");
}
NS_ENSURE_SUCCESS(mDocShellAsWin->Create(), NS_ERROR_FAILURE);
// Hook into the OnSecurityChange() notification for lock/unlock icon
--- a/embedding/components/windowwatcher/nsWindowWatcher.cpp
+++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp
@@ -475,17 +475,17 @@ nsWindowWatcher::OpenWindowInternal(nsID
nsCOMPtr<nsPIDOMWindow> parent = do_QueryInterface(aParent);
if (parent && parent->IsInnerWindow()) {
NS_ENSURE_STATE(parent->IsCurrentInnerWindow());
aParent = parent->GetOuterWindow();
}
MOZ_ASSERT_IF(openedFromRemoteTab,
- XRE_GetProcessType() == GeckoProcessType_Default);
+ XRE_IsParentProcess());
NS_ENSURE_ARG_POINTER(aResult);
*aResult = 0;
if (!nsContentUtils::IsSafeToRunScript()) {
nsContentUtils::WarnScriptWasIgnored(nullptr);
return NS_ERROR_FAILURE;
}
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -43,17 +43,17 @@ static nsPermissionManager *gPermissionM
using mozilla::dom::ContentParent;
using mozilla::dom::ContentChild;
using mozilla::unused; // ha!
static bool
IsChildProcess()
{
- return XRE_GetProcessType() == GeckoProcessType_Content;
+ return XRE_IsContentProcess();
}
/**
* @returns The child process object, or if we are not in the child
* process, nullptr.
*/
static ContentChild*
ChildProcess()
--- a/extensions/spellcheck/src/mozSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozSpellChecker.cpp
@@ -44,27 +44,27 @@ mozSpellChecker::~mozSpellChecker()
if (mPersonalDictionary) {
// mPersonalDictionary->Save();
mPersonalDictionary->EndSession();
}
mSpellCheckingEngine = nullptr;
mPersonalDictionary = nullptr;
if (mEngine) {
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Content);
+ MOZ_ASSERT(XRE_IsContentProcess());
mEngine->Send__delete__(mEngine);
MOZ_ASSERT(!mEngine);
}
}
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);
contentChild->SendPRemoteSpellcheckEngineConstructor(mEngine);
} else {
mPersonalDictionary = do_GetService("@mozilla.org/spellchecker/personaldictionary;1");
}
@@ -125,17 +125,17 @@ mozSpellChecker::NextMisspelledWord(nsAS
}
NS_IMETHODIMP
mozSpellChecker::CheckWord(const nsAString &aWord, bool *aIsMisspelled, nsTArray<nsString> *aSuggestions)
{
nsresult result;
bool correct;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
nsString wordwrapped = nsString(aWord);
bool rv;
if (aSuggestions) {
rv = mEngine->SendCheckAndSuggest(wordwrapped, aIsMisspelled, aSuggestions);
} else {
rv = mEngine->SendCheck(wordwrapped, aIsMisspelled);
}
return rv ? NS_OK : NS_ERROR_NOT_AVAILABLE;
@@ -304,17 +304,17 @@ mozSpellChecker::GetPersonalDictionary(n
aWordList->AppendElement(word);
}
return NS_OK;
}
NS_IMETHODIMP
mozSpellChecker::GetDictionaryList(nsTArray<nsString> *aDictionaryList)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild *child = ContentChild::GetSingleton();
child->GetAvailableDictionaries(*aDictionaryList);
return NS_OK;
}
nsresult rv;
// For catching duplicates
@@ -352,17 +352,17 @@ mozSpellChecker::GetDictionaryList(nsTAr
}
return NS_OK;
}
NS_IMETHODIMP
mozSpellChecker::GetCurrentDictionary(nsAString &aDictionary)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
aDictionary = mCurrentDictionary;
return NS_OK;
}
if (!mSpellCheckingEngine) {
aDictionary.Truncate();
return NS_OK;
}
@@ -371,17 +371,17 @@ mozSpellChecker::GetCurrentDictionary(ns
mSpellCheckingEngine->GetDictionary(getter_Copies(dictname));
aDictionary = dictname;
return NS_OK;
}
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);
if (!isSuccess) {
mCurrentDictionary.Truncate();
return NS_ERROR_NOT_AVAILABLE;
}
@@ -531,17 +531,17 @@ mozSpellChecker::GetCurrentBlockIndex(ns
*outBlockIndex = blockIndex;
return result;
}
nsresult
mozSpellChecker::GetEngineList(nsCOMArray<mozISpellCheckingEngine>* aSpellCheckingEngines)
{
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Content);
+ MOZ_ASSERT(!XRE_IsContentProcess());
nsresult rv;
bool hasMoreEngines;
nsCOMPtr<nsICategoryManager> catMgr = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
if (!catMgr)
return NS_ERROR_NULL_POINTER;
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -35,17 +35,16 @@ GLScreenBuffer::Create(GLContext* gl,
{
UniquePtr<GLScreenBuffer> ret;
if (caps.antialias &&
!gl->IsSupported(GLFeature::framebuffer_multisample))
{
return Move(ret);
}
-
layers::TextureFlags flags = layers::TextureFlags::ORIGIN_BOTTOM_LEFT;
if (!caps.premultAlpha) {
flags |= layers::TextureFlags::NON_PREMULTIPLIED;
}
UniquePtr<SurfaceFactory> factory = MakeUnique<SurfaceFactory_Basic>(gl, caps, flags);
ret.reset( new GLScreenBuffer(gl, caps, Move(factory)) );
--- a/gfx/layers/client/ClientCanvasLayer.cpp
+++ b/gfx/layers/client/ClientCanvasLayer.cpp
@@ -83,18 +83,17 @@ ClientCanvasLayer::Initialize(const Data
switch (forwarder->GetCompositorBackendType()) {
case mozilla::layers::LayersBackend::LAYERS_OPENGL: {
#if defined(XP_MACOSX)
factory = SurfaceFactory_IOSurface::Create(mGLContext, caps, forwarder, mFlags);
#elif defined(MOZ_WIDGET_GONK)
factory = MakeUnique<SurfaceFactory_Gralloc>(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);
}
}
#endif
break;
}
case mozilla::layers::LayersBackend::LAYERS_D3D11: {
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -216,17 +216,17 @@ ClientLayerManager::BeginTransactionWith
#if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK)
if (mWidget && mWidget->GetOwningTabChild()) {
mCompositorMightResample = AsyncPanZoomEnabled();
}
#endif
// 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,
"Content-process ClientLayerManager::BeginTransactionWithTarget not supported");
}
// If this is a new paint, increment the paint sequence number.
if (!mIsRepeatTransaction && gfxPrefs::APZTestLoggingEnabled()) {
@@ -365,17 +365,17 @@ ClientLayerManager::GetRemoteRenderer()
}
return mWidget->GetRemoteRenderer();
}
CompositorChild*
ClientLayerManager::GetCompositorChild()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return CompositorChild::Get();
}
return GetRemoteRenderer();
}
void
ClientLayerManager::Composite()
{
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -157,17 +157,17 @@ CompositorChild::OpenSameProcess(Composi
ipc::ChildSide);
return mCanSend;
}
/*static*/ CompositorChild*
CompositorChild::Get()
{
// This is only expected to be used in child processes.
- MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
+ MOZ_ASSERT(!XRE_IsParentProcess());
return sCompositor;
}
PLayerTransactionChild*
CompositorChild::AllocPLayerTransactionChild(const nsTArray<LayersBackend>& aBackendHints,
const uint64_t& aId,
TextureFactoryIdentifier*,
bool*)
--- a/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsGralloc.cpp
@@ -143,17 +143,17 @@ ParamTraits<MagicGrallocBufferHandle>::R
// But in shared cross-thread, dup fd is not necessary because we get
// a pointer to the GraphicBuffer directly from SharedBufferManagerParent
// and don't create a new GraphicBuffer around the fd.
fds[n] = fd.fd;
}
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);
} else {
// Deserialize GraphicBuffer
#if ANDROID_VERSION >= 19
sp<GraphicBuffer> buffer(new GraphicBuffer());
const void* datap = (const void*)data;
@@ -210,17 +210,17 @@ LayerManagerComposite::PlatformSyncBefor
//-----------------------------------------------------------------------------
// Both processes
/*static*/ sp<GraphicBuffer>
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);
}
} else {
MagicGrallocBufferHandle realHandle = aHandle.get_MagicGrallocBufferHandle();
return realHandle.mGraphicBuffer;
}
--- a/gfx/layers/opengl/TextureClientOGL.cpp
+++ b/gfx/layers/opengl/TextureClientOGL.cpp
@@ -24,17 +24,17 @@ EGLImageTextureClient::EGLImageTextureCl
TextureFlags aFlags,
EGLImageImage* aImage,
gfx::IntSize aSize)
: TextureClient(aAllocator, aFlags)
, mImage(aImage)
, 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);
if (aImage->GetData()->mOriginPos == gl::OriginPos::BottomLeft) {
AddFlags(TextureFlags::ORIGIN_BOTTOM_LEFT);
}
}
@@ -80,17 +80,17 @@ SurfaceTextureClient::SurfaceTextureClie
AndroidSurfaceTexture* aSurfTex,
gfx::IntSize aSize,
gl::OriginPos aOriginPos)
: TextureClient(aAllocator, aFlags)
, mSurfTex(aSurfTex)
, 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.
AddFlags(TextureFlags::DEALLOCATE_CLIENT);
if (aOriginPos == gl::OriginPos::BottomLeft) {
AddFlags(TextureFlags::ORIGIN_BOTTOM_LEFT);
}
--- a/gfx/thebes/gfxAndroidPlatform.cpp
+++ b/gfx/thebes/gfxAndroidPlatform.cpp
@@ -387,17 +387,17 @@ gfxAndroidPlatform::RequiresLinearZoom()
// browser process, not other apps.
return true;
#endif
#ifdef MOZ_WIDGET_GONK
// 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
NS_NOTREACHED("oops, what platform is this?");
return gfxPlatform::RequiresLinearZoom();
}
int
--- a/gfx/thebes/gfxFT2FontList.cpp
+++ b/gfx/thebes/gfxFT2FontList.cpp
@@ -630,17 +630,17 @@ public:
mOps = (PLDHashTableOps) {
StringHash,
HashMatchEntry,
MoveEntry,
PL_DHashClearEntryStub,
nullptr
};
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
+ MOZ_ASSERT(XRE_IsParentProcess(),
"StartupCacheFontNameCache should only be used in chrome "
"process");
mCache = mozilla::scache::StartupCache::GetSingleton();
Init();
}
~FontNameCache()
@@ -1143,17 +1143,17 @@ gfxFT2FontList::FindFonts()
if (fc)
fc->AgeAllGenerations();
mPrefFonts.Clear();
mCodepointsWithNoFonts.reset();
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<FontListEntry> fonts;
mozilla::dom::ContentChild::GetSingleton()->SendReadFontList(&fonts);
for (uint32_t i = 0, n = fonts.Length(); i < n; ++i) {
// We don't need to identify "standard" font files here,
// as the faces are already sorted.
AppendFaceFromFontListEntry(fonts[i], kUnknown);
}
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -709,17 +709,17 @@ gfxPlatform::InitLayersIPC()
{
if (sLayersIPCIsUp) {
return;
}
sLayersIPCIsUp = true;
AsyncTransactionTrackersHolder::Initialize();
- if (XRE_GetProcessType() == GeckoProcessType_Default)
+ if (XRE_IsParentProcess())
{
mozilla::layers::CompositorParent::StartUp();
#ifndef MOZ_WIDGET_GONK
if (gfxPrefs::AsyncVideoEnabled()) {
mozilla::layers::ImageBridgeChild::StartUp();
}
#else
mozilla::layers::ImageBridgeChild::StartUp();
@@ -731,17 +731,17 @@ gfxPlatform::InitLayersIPC()
/* static */ void
gfxPlatform::ShutdownLayersIPC()
{
if (!sLayersIPCIsUp) {
return;
}
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.
layers::ImageBridgeChild::ShutDown();
#ifdef MOZ_WIDGET_GONK
layers::SharedBufferManagerChild::ShutDown();
#endif
@@ -1065,17 +1065,17 @@ gfxPlatform::SetTileSize(int aWidth, int
mTileHeight = aHeight;
}
void
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.");
}
int32_t w = gfxPrefs::LayersTileWidth();
int32_t h = gfxPrefs::LayersTileHeight();
// TODO We may want to take the screen size into consideration here.
if (gfxPrefs::LayersTilesAdjust()) {
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -646,17 +646,17 @@ gfxWindowsPlatform::CreateDevice(nsRefPt
// If we fail here, the DirectX version or video card probably
// changed. We previously could use 10.1 but now we can't
// anymore. Revert back to doing a 10.0 check first before
// the 10.1 check.
if (device) {
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);
}
}
return device ? S_OK : hr;
}
#endif
--- a/image/decoders/icon/android/nsIconChannel.cpp
+++ b/image/decoders/icon/android/nsIconChannel.cpp
@@ -75,17 +75,17 @@ moz_icon_to_channel(nsIURI* aURI, const
uint8_t* const buf = (uint8_t*)moz_xmalloc(buf_size);
NS_ENSURE_TRUE(buf, NS_ERROR_OUT_OF_MEMORY);
uint8_t* out = buf;
*(out++) = width;
*(out++) = height;
nsresult rv;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
rv = GetIconForExtension(aFileExt, aIconSize, out);
} else {
rv = CallRemoteGetIconForExtension(aFileExt, aIconSize, out);
}
NS_ENSURE_SUCCESS(rv, rv);
// Encode the RGBA data
const uint8_t* in = out;
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -46,17 +46,17 @@
#ifdef RELEASE_BUILD
#define THREADSAFETY_ASSERT MOZ_ASSERT
#else
#define THREADSAFETY_ASSERT MOZ_RELEASE_ASSERT
#endif
#define CRASH_IN_CHILD_PROCESS(_msg) \
do { \
- if (IsMainProcess()) { \
+ if (XRE_IsParentProcess()) { \
MOZ_ASSERT(false, _msg); \
} else { \
MOZ_CRASH(_msg); \
} \
} \
while (0)
using namespace mozilla;
@@ -64,42 +64,27 @@ using namespace mozilla::dom;
using namespace mozilla::ipc;
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
AssertIsOnMainThread()
{
THREADSAFETY_ASSERT(NS_IsMainThread());
}
@@ -2052,17 +2037,17 @@ ChildImpl::OpenProtocolOnMainThread(nsIE
AssertIsOnMainThread();
MOZ_ASSERT(aEventTarget);
if (sShutdownHasStarted) {
MOZ_CRASH("Called BackgroundChild::GetOrCreateForCurrentThread after "
"shutdown has started!");
}
- if (IsMainProcess()) {
+ if (XRE_IsParentProcess()) {
nsRefPtr<ParentImpl::CreateCallback> parentCallback =
new ParentCreateCallback(aEventTarget);
if (!ParentImpl::CreateActorForSameProcess(parentCallback)) {
NS_WARNING("BackgroundParent::CreateActor() failed!");
DispatchFailureCallback(aEventTarget);
return false;
}
--- a/ipc/glue/BackgroundParentImpl.cpp
+++ b/ipc/glue/BackgroundParentImpl.cpp
@@ -43,17 +43,17 @@ using mozilla::dom::MessagePortParent;
using mozilla::dom::PMessagePortParent;
using mozilla::dom::UDPSocketParent;
namespace {
void
AssertIsInMainProcess()
{
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
}
void
AssertIsOnMainThread()
{
MOZ_ASSERT(NS_IsMainThread());
}
--- a/ipc/glue/InputStreamUtils.cpp
+++ b/ipc/glue/InputStreamUtils.cpp
@@ -101,17 +101,17 @@ DeserializeInputStream(const InputStream
case InputStreamParams::TMultiplexInputStreamParams:
serializable = do_CreateInstance(kMultiplexInputStreamCID);
break;
// 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;
}
const nsID& id = aParams.get_RemoteInputStreamParams().id();
nsRefPtr<BlobImpl> blobImpl = BlobParent::GetBlobImplForID(id);
MOZ_ASSERT(blobImpl, "Invalid blob contents");
--- a/ipc/glue/ScopedXREEmbed.cpp
+++ b/ipc/glue/ScopedXREEmbed.cpp
@@ -62,17 +62,17 @@ ScopedXREEmbed::Start()
rv = localFile->GetParent(getter_AddRefs(parent));
if (NS_FAILED(rv))
return;
localFile = do_QueryInterface(parent);
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));
if (NS_FAILED(rv))
return;
localFile = do_QueryInterface(parent);
NS_ENSURE_TRUE_VOID(localFile);
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -578,17 +578,17 @@ mozJSComponentLoader::PrepareObjectForLo
nsCOMPtr<nsIFile> testFile;
if (NS_SUCCEEDED(rv)) {
fileURL->GetFile(getter_AddRefs(testFile));
}
if (testFile) {
*aRealFile = true;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsIXPConnectJSObjectHolder> locationHolder;
rv = xpc->WrapNative(aCx, obj, aComponentFile,
NS_GET_IID(nsIFile),
getter_AddRefs(locationHolder));
NS_ENSURE_SUCCESS(rv, nullptr);
RootedObject locationObj(aCx, locationHolder->GetJSObject());
NS_ENSURE_TRUE(locationObj, nullptr);
--- a/js/xpconnect/src/XPCJSRuntime.cpp
+++ b/js/xpconnect/src/XPCJSRuntime.cpp
@@ -1349,17 +1349,17 @@ XPCJSRuntime::InterruptCallback(JSContex
return true;
}
// Sometimes we get called back during XPConnect initialization, before Gecko
// has finished bootstrapping. Avoid crashing in nsContentUtils below.
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
// is.
TimeDuration duration = TimeStamp::NowLoRes() - self->mSlowScriptCheckpoint;
bool chrome = nsContentUtils::IsCallerChrome();
const char* prefName = contentProcess ? PREF_MAX_SCRIPT_RUN_TIME_CHILD
: chrome ? PREF_MAX_SCRIPT_RUN_TIME_CHROME
@@ -2576,17 +2576,17 @@ nsresult
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats& rtStats,
const nsACString& rtPath,
nsIMemoryReporterCallback* cb,
nsISupports* closure,
bool anonymize,
size_t* rtTotalOut)
{
nsCOMPtr<amIAddonManager> 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");
}
return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(),
cb, closure, anonymize, rtTotalOut);
}
@@ -2832,17 +2832,17 @@ JSReporter::CollectReports(WindowPaths*
// In the first step we get all the stats and stash them in a local
// data structure. In the second step we pass all the stashed stats to
// the callback. Separating these steps is important because the
// callback may be a JS function, and executing JS while getting these
// stats seems like a bad idea.
nsCOMPtr<amIAddonManager> 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");
}
bool getLocations = !!addonManager;
XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations,
anonymize);
OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
if (!JS::CollectRuntimeStats(xpcrt->Runtime(), &rtStats, &orphanReporter,
--- a/js/xpconnect/src/XPCWrappedNativeInfo.cpp
+++ b/js/xpconnect/src/XPCWrappedNativeInfo.cpp
@@ -231,17 +231,17 @@ XPCNativeInterface::NewInstance(nsIInter
bool canScript;
if (NS_FAILED(aInfo->IsScriptable(&canScript)) || !canScript)
return nullptr;
bool mainProcessScriptableOnly;
if (NS_FAILED(aInfo->IsMainProcessScriptableOnly(&mainProcessScriptableOnly)))
return nullptr;
- if (mainProcessScriptableOnly && XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (mainProcessScriptableOnly && !XRE_IsParentProcess()) {
nsCOMPtr<nsIConsoleService> console(do_GetService(NS_CONSOLESERVICE_CONTRACTID));
if (console) {
char* intfNameChars;
aInfo->GetName(&intfNameChars);
nsPrintfCString errorMsg("Use of %s in content process is deprecated.", intfNameChars);
nsAutoString filename;
uint32_t lineno = 0;
--- a/js/xpconnect/wrappers/AccessCheck.cpp
+++ b/js/xpconnect/wrappers/AccessCheck.cpp
@@ -223,17 +223,17 @@ AccessCheck::checkPassToPrivilegedCode(J
if (!js::IsWrapper(obj))
return true;
// CPOWs use COWs (in the unprivileged junk scope) for all child->parent
// references. Without this test, the child process wouldn't be able to
// 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;
}
// COWs are fine to pass to chrome if and only if they have __exposedProps__,
// since presumably content should never have a reason to pass an opaque
// object back to chrome.
if (AccessCheck::isChrome(js::UncheckedUnwrap(wrapper)) && WrapperFactory::IsCOW(obj)) {
--- a/js/xpconnect/wrappers/WrapperFactory.cpp
+++ b/js/xpconnect/wrappers/WrapperFactory.cpp
@@ -422,17 +422,17 @@ WrapperFactory::Rewrap(JSContext* cx, Ha
// Special handling for chrome objects being exposed to content.
else if (originIsChrome && !targetIsChrome) {
// If this is a chrome function being exposed to content, we need to allow
// call (but nothing else). We allow CPOWs that purport to be function's
// 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<CrossCompartmentSecurityWrapper, OpaqueWithCall>::singleton;
}
// For Vanilla JSObjects exposed from chrome to content, we use a wrapper
// that supports __exposedProps__. We'd like to get rid of these eventually,
// but in their current form they don't cause much trouble.
else if (IdentifyStandardInstance(obj) == JSProto_Object) {
--- a/layout/base/nsDisplayList.cpp
+++ b/layout/base/nsDisplayList.cpp
@@ -1640,17 +1640,17 @@ already_AddRefed<LayerManager> nsDisplay
flags = LayerManager::END_NO_REMOTE_COMPOSITE;
}
}
// If this is the content process, we ship plugin geometry updates over with layer
// 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);
}
MaybeSetupTransactionIdAllocator(layerManager, view);
layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
aBuilder, flags);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3397,17 +3397,17 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
}
if (builder.WillComputePluginGeometry()) {
// For single process compute and apply plugin geometry updates to plugin
// windows, then request composition. For content processes skip eveything
// 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
// instead. We could instead have the compositor send back an equivalent
// to WillPaintWindow, but it should be close enough to now not to matter.
if (layerManager && !layerManager->NeedsWidgetInvalidation()) {
rootPresContext->ApplyPluginGeometryUpdates();
}
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2759,17 +2759,17 @@ nsPresContext::IsRootContentDocument()
bool
nsPresContext::IsCrossProcessRootContentDocument()
{
if (!IsRootContentDocument()) {
return false;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
return true;
}
TabChild* tabChild = TabChild::GetFrom(mShell);
return (tabChild && tabChild->IsRootContentDocument());
}
bool nsPresContext::GetPaintFlashing() const
@@ -2895,17 +2895,17 @@ nsRootPresContext::ComputePluginGeometry
aList->ComputeVisibilityForRoot(aBuilder, ®ion);
}
#ifdef XP_MACOSX
// We control painting of Mac plugins, so just apply geometry updates now.
// This is not happening during a paint event.
ApplyPluginGeometryUpdates();
#else
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
InitApplyPluginGeometryTimer();
}
#endif
}
static void
ApplyPluginGeometryUpdatesCallback(nsITimer *aTimer, void *aClosure)
{
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -4672,17 +4672,17 @@ PresShell::RenderDocument(const nsRect&
nsView* view = rootFrame->GetView();
if (view && view->GetWidget() &&
nsLayoutUtils::GetDisplayRootFrame(rootFrame) == rootFrame) {
LayerManager* layerManager = view->GetWidget()->GetLayerManager();
// ClientLayerManagers in content processes don't support
// taking snapshots.
if (layerManager &&
(!layerManager->AsClientLayerManager() ||
- XRE_GetProcessType() == GeckoProcessType_Default)) {
+ XRE_IsParentProcess())) {
flags |= nsLayoutUtils::PAINT_WIDGET_LAYERS;
}
}
}
if (!(aFlags & RENDER_CARET)) {
wouldFlushRetainedLayers = true;
flags |= nsLayoutUtils::PAINT_HIDE_CARET;
}
@@ -5245,17 +5245,17 @@ void PresShell::UpdateCanvasBackground()
}
// If the root element of the document (ie html) has style 'display: none'
// then the document's background color does not get drawn; cache the
// color we actually draw.
if (!FrameConstructor()->GetRootElementFrame()) {
mCanvasBackgroundColor = GetDefaultBackgroundColorToDraw();
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
if (TabChild* tabChild = TabChild::GetFrom(this)) {
tabChild->SetBackgroundColor(mCanvasBackgroundColor);
}
}
}
nscolor PresShell::ComputeBackstopColor(nsView* aDisplayRoot)
{
@@ -5950,17 +5950,17 @@ class AutoUpdateHitRegion
{
public:
AutoUpdateHitRegion(PresShell* aShell, nsIFrame* aFrame)
: mShell(aShell), mFrame(aFrame)
{
}
~AutoUpdateHitRegion()
{
- if (XRE_GetProcessType() != GeckoProcessType_Content ||
+ if (!XRE_IsContentProcess() ||
!mFrame || !mShell) {
return;
}
TabChild* tabChild = TabChild::GetFrom(mShell);
if (!tabChild || !tabChild->GetUpdateHitRegion()) {
return;
}
nsRegion region;
@@ -10784,17 +10784,17 @@ nsIPresShell::RecomputeFontSizeInflation
if (!FontSizeInflationForceEnabled()) {
if (TabChild* tab = TabChild::GetFrom(this)) {
// We're in a child process. Cancel inflation if we're not
// async-pan zoomed.
if (!tab->AsyncPanZoomEnabled()) {
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()) {
mFontSizeInflationEnabled = false;
return;
}
}
}
--- a/layout/base/nsStyleSheetService.cpp
+++ b/layout/base/nsStyleSheetService.cpp
@@ -96,17 +96,17 @@ nsStyleSheetService::FindSheetByURI(cons
nsresult
nsStyleSheetService::Init()
{
// If you make changes here, consider whether
// 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;
}
// Enumerate all of the style sheet URIs registered in the category
// manager and load them.
nsCOMPtr<nsICategoryManager> catMan =
do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
@@ -151,17 +151,17 @@ nsStyleSheetService::LoadAndRegisterShee
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
if (serv) {
// We're guaranteed that the new sheet is the last sheet in
// mSheets[aSheetType]
const nsCOMArray<nsIStyleSheet> & sheets = mSheets[aSheetType];
serv->NotifyObservers(sheets[sheets.Count() - 1], message, nullptr);
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsTArray<dom::ContentParent*> children;
dom::ContentParent::GetAll(children);
if (children.IsEmpty()) {
return rv;
}
mozilla::ipc::URIParams uri;
@@ -260,17 +260,17 @@ nsStyleSheetService::UnregisterSheet(nsI
message = "author-sheet-removed";
break;
}
nsCOMPtr<nsIObserverService> serv = services::GetObserverService();
if (serv)
serv->NotifyObservers(sheet, message, nullptr);
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsTArray<dom::ContentParent*> children;
dom::ContentParent::GetAll(children);
if (children.IsEmpty()) {
return NS_OK;
}
mozilla::ipc::URIParams uri;
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -1786,17 +1786,17 @@ nsListControlFrame::GetIndexFromDOMEvent
}
return NS_ERROR_FAILURE;
}
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,
false);
return true;
}
return false;
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -411,17 +411,17 @@ nsPluginFrame::GetWidgetConfiguration(ns
return;
}
nsIWidget::Configuration* configuration = aConfigurations->AppendElement();
configuration->mChild = mWidget;
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();
}
#endif // defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
}
void
nsPluginFrame::GetDesiredSize(nsPresContext* aPresContext,
@@ -763,17 +763,17 @@ nsPluginFrame::IsHidden(bool aCheckVisib
return false;
}
mozilla::LayoutDeviceIntPoint
nsPluginFrame::GetRemoteTabChromeOffset()
{
LayoutDeviceIntPoint offset;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetContent()->OwnerDoc()->GetWindow());
if (window) {
nsCOMPtr<nsIDOMWindow> topWindow;
window->GetTop(getter_AddRefs(topWindow));
if (topWindow) {
dom::TabChild* tc = dom::TabChild::GetFrom(topWindow);
if (tc) {
LayoutDeviceIntPoint chromeOffset;
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -306,30 +306,30 @@ RenderFrameParent::RenderFrameParent(nsF
// Perhaps the document containing this frame currently has no presentation?
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
*aTextureFactoryIdentifier =
static_cast<ClientLayerManager*>(lm.get())->GetTextureFactoryIdentifier();
} else {
*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();
if (lm && lm->GetBackendType() == LayersBackend::LAYERS_CLIENT) {
ClientLayerManager *clientManager =
static_cast<ClientLayerManager*>(lm.get());
clientManager->GetRemoteRenderer()->SendNotifyChildCreated(mLayersId);
}
if (mAsyncPanZoomEnabled) {
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);
}
*aSuccess = true;
}
APZCTreeManager*
@@ -425,17 +425,17 @@ RenderFrameParent::OwnerContentChanged(n
clientManager->GetRemoteRenderer()->SendAdoptChild(mLayersId);
}
}
void
RenderFrameParent::ActorDestroy(ActorDestroyReason why)
{
if (mLayersId != 0) {
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild::GetSingleton()->SendDeallocateLayerTreeId(mLayersId);
} else {
CompositorParent::DeallocateLayerTreeId(mLayersId);
}
if (mContentController) {
// Stop our content controller from requesting repaints of our
// content.
mContentController->ClearRenderFrame();
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -1456,17 +1456,17 @@ static nr_socket_vtbl nr_socket_local_vt
nr_socket_local_listen,
nr_socket_local_accept
};
int nr_socket_local_create(void *obj, nr_transport_addr *addr, nr_socket **sockp) {
RefPtr<NrSocketBase> sock;
// create IPC bridge for content process
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
sock = new NrSocket();
} else {
sock = new NrSocketIpc();
}
int r, _status;
r = sock->create(addr);
--- a/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
+++ b/media/webrtc/signaling/src/common/browser_logging/WebRtcLog.cpp
@@ -142,17 +142,17 @@ void ConfigWebRtcLog(uint32_t trace_mask
if (trace_mask != 0) {
if (aLogFile.EqualsLiteral("nspr")) {
webrtc::Trace::SetTraceCallback(&gWebRtcCallback);
} else {
webrtc::Trace::SetTraceFile(aLogFile.get(), multi_log);
}
}
#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);
}
#endif
return;
}
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionCtx.cpp
@@ -321,17 +321,17 @@ nsresult PeerConnectionCtx::Initialize()
mTelemetryTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
MOZ_ASSERT(mTelemetryTimer);
nsresult rv = mTelemetryTimer->SetTarget(gMainThread);
NS_ENSURE_SUCCESS(rv, rv);
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
return NS_OK;
}
static void GMPReady_m() {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -257,17 +257,17 @@ private:
};
#endif
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
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;
}
static bool nssStarted = false;
if (nssStarted) {
return NS_OK;
}
@@ -590,17 +590,17 @@ PeerConnectionImpl::AddIceServer(const R
port = (isStuns || isTurns)? 5349 : 3478;
if (isTurn || isTurns) {
NS_ConvertUTF16toUTF8 credential(aServer.mCredential);
NS_ConvertUTF16toUTF8 username(aServer.mUsername);
// Bug 1039655 - TURN TCP is not e10s ready
if ((transport == kNrIceTransportTcp) &&
- (XRE_GetProcessType() != GeckoProcessType_Default)) {
+ (!XRE_IsParentProcess())) {
continue;
}
if (!aDst->addTurnServer(host.get(), port,
username.get(),
credential.get(),
(transport.IsEmpty() ?
kNrIceTransportUdp : transport.get()))) {
@@ -638,17 +638,17 @@ PeerConnectionImpl::Initialize(PeerConne
// Find the STS thread
mSTSThread = do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &res);
MOZ_ASSERT(mSTSThread);
#if !defined(MOZILLA_EXTERNAL_LINKAGE)
// 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<nsISupports> nssDummy = do_GetService("@mozilla.org/psm;1", &res);
NS_ENSURE_SUCCESS(res, res);
} else {
NS_ENSURE_SUCCESS(res = InitNSSInContent(), res);
}
// Currently no standalone unit tests for DataChannel,
--- a/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
+++ b/media/webrtc/signaling/src/peerconnection/WebrtcGlobalInformation.cpp
@@ -256,17 +256,17 @@ OnStatsReport_m(WebrtcGlobalChild* aThis
}
}
unused << aThisChild->SendGetStatsResult(aRequestId, stats);
return;
}
// 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);
if (!request) {
CSFLogError(logTag, "Bad RequestId");
return;
}
@@ -327,17 +327,17 @@ static void OnGetLogging_m(WebrtcGlobalC
nsLogs.AppendElement(NS_LITERAL_STRING("+++++++ END ++++++++"), fallible);
}
unused << aThisChild->SendGetLogResult(aRequestId, nsLogs);
return;
}
// 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);
if (!request) {
CSFLogError(logTag, "Bad RequestId");
return;
}
@@ -438,17 +438,17 @@ WebrtcGlobalInformation::GetAllStats(
const Optional<nsAString>& pcIdFilter,
ErrorResult& aRv)
{
if (!NS_IsMainThread()) {
aRv.Throw(NS_ERROR_NOT_SAME_THREAD);
return;
}
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
// CallbackObject does not support threadsafe refcounting, and must be
// destroyed on main.
StatsRequestCallback callbackHandle(
new nsMainThreadPtrHolder<WebrtcGlobalStatisticsCallback>(&aStatsCallback));
nsString filter;
if (pcIdFilter.WasPassed()) {
@@ -529,17 +529,17 @@ WebrtcGlobalInformation::GetLogging(
WebrtcGlobalLoggingCallback& aLoggingCallback,
ErrorResult& aRv)
{
if (!NS_IsMainThread()) {
aRv.Throw(NS_ERROR_NOT_SAME_THREAD);
return;
}
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
// CallbackObject does not support threadsafe refcounting, and must be
// destroyed on main.
LogRequestCallback callbackHandle(
new nsMainThreadPtrHolder<WebrtcGlobalLoggingCallback>(&aLoggingCallback));
nsAutoCString pattern;
CopyUTF16toUTF8(aPattern, pattern);
--- a/modules/libjar/nsJARProtocolHandler.cpp
+++ b/modules/libjar/nsJARProtocolHandler.cpp
@@ -27,17 +27,17 @@ static NS_DEFINE_CID(kZipReaderCacheCID,
#define NS_JAR_CACHE_SIZE 32
//-----------------------------------------------------------------------------
nsJARProtocolHandler *gJarHandler = nullptr;
nsJARProtocolHandler::nsJARProtocolHandler()
-: mIsMainProcess(XRE_GetProcessType() == GeckoProcessType_Default)
+: mIsMainProcess(XRE_IsParentProcess())
{
MOZ_ASSERT(NS_IsMainThread());
}
nsJARProtocolHandler::~nsJARProtocolHandler()
{
MOZ_ASSERT(gJarHandler == this);
gJarHandler = nullptr;
--- a/modules/libpref/Preferences.cpp
+++ b/modules/libpref/Preferences.cpp
@@ -45,25 +45,25 @@
#include "nsTArray.h"
#include "nsRefPtrHashtable.h"
#include "nsIMemoryReporter.h"
#include "nsThreadUtils.h"
#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; \
} \
} 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
class PrefCallback;
namespace mozilla {
@@ -524,17 +524,17 @@ Preferences::Init()
nsresult rv;
PREF_Init();
rv = pref_InitInitialObjects();
NS_ENSURE_SUCCESS(rv, rv);
using mozilla::dom::ContentChild;
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
InfallibleTArray<PrefSetting> prefs;
ContentChild::GetSingleton()->SendReadPrefsArray(&prefs);
// Store the array
for (uint32_t i = 0; i < prefs.Length(); ++i) {
pref_SetPref(prefs[i]);
}
return NS_OK;
@@ -575,17 +575,17 @@ Preferences::ResetAndReadUserPrefs()
sPreferences->ResetUserPrefs();
return sPreferences->ReadUserPrefs(nullptr);
}
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;
if (!nsCRT::strcmp(aTopic, "profile-before-change")) {
rv = SavePrefFile(nullptr);
} else if (!strcmp(aTopic, "load-extension-defaults")) {
pref_LoadPrefsInDirList(NS_EXT_PREFS_DEFAULTS_DIR_LIST);
@@ -600,17 +600,17 @@ Preferences::Observe(nsISupports *aSubje
}
return rv;
}
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;
}
nsresult rv;
if (nullptr == aFile) {
rv = UseDefaultPrefFile();
@@ -630,45 +630,45 @@ Preferences::ReadUserPrefs(nsIFile *aFil
}
return rv;
}
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;
}
NotifyServiceObservers(NS_PREFSERVICE_RESET_TOPIC_ID);
PREF_CleanupPrefs();
PREF_Init();
return pref_InitInitialObjects();
}
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;
}
PREF_ClearAllUserPrefs();
return NS_OK;
}
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;
}
return SavePrefFileInternal(aFile);
}
static nsresult
--- a/modules/libpref/nsPrefBranch.cpp
+++ b/modules/libpref/nsPrefBranch.cpp
@@ -57,17 +57,17 @@ static PLDHashOperator
pref_enumChild(PLDHashTable *table, PLDHashEntryHdr *heh,
uint32_t i, void *arg);
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!");
}
return cpc;
}
return nullptr;
}
--- a/netwerk/base/nsBaseChannel.cpp
+++ b/netwerk/base/nsBaseChannel.cpp
@@ -274,17 +274,17 @@ nsBaseChannel::ContinueHandleAsyncRedire
CallbacksChanged();
}
void
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;
}
if (mLoadFlags & LOAD_CLASSIFY_URI) {
nsRefPtr<nsChannelClassifier> classifier = new nsChannelClassifier();
if (classifier) {
classifier->Start(this, false);
} else {
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -54,17 +54,17 @@ nsChannelClassifier::nsChannelClassifier
gChannelClassifierLog = PR_NewLogModule("nsChannelClassifier");
}
nsresult
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;
if (!Preferences::GetBool("privacy.trackingprotection.enabled", false) &&
(!Preferences::GetBool("privacy.trackingprotection.pbmode.enabled",
false) || !NS_UsePrivateBrowsing(aChannel))) {
return NS_OK;
@@ -251,17 +251,17 @@ nsChannelClassifier::Start(nsIChannel *a
OnClassifyComplete(NS_OK);
}
}
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)
nsresult status;
mChannel->GetStatus(&status);
if (NS_FAILED(status))
return status;
@@ -364,17 +364,17 @@ nsChannelClassifier::StartInternal()
}
// Note in the cache entry that this URL was classified, so that future
// cached loads don't need to be checked.
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) {
return;
}
nsCOMPtr<nsICachingChannel> cachingChannel = do_QueryInterface(mChannel);
if (!cachingChannel) {
@@ -396,17 +396,17 @@ nsChannelClassifier::MarkEntryClassified
cacheEntry->SetMetaDataElement("necko:classified",
NS_SUCCEEDED(status) ? "1" : nullptr);
}
bool
nsChannelClassifier::HasBeenClassified(nsIChannel *aChannel)
{
// Should only be called in the parent process.
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsCOMPtr<nsICachingChannel> cachingChannel =
do_QueryInterface(aChannel);
if (!cachingChannel) {
return false;
}
// Only check the tag if we are loading from the cache without
@@ -494,17 +494,17 @@ nsChannelClassifier::SetBlockedTrackingC
return NS_OK;
}
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) {
MarkEntryClassified(aErrorCode);
if (NS_FAILED(aErrorCode)) {
#ifdef DEBUG
nsCOMPtr<nsIURI> uri;
--- a/netwerk/base/nsFileStreams.cpp
+++ b/netwerk/base/nsFileStreams.cpp
@@ -617,17 +617,17 @@ nsFileInputStream::Deserialize(const Inp
NS_WARNING("Failed to import file handle!");
return false;
}
mFD = fileDesc;
}
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;
// A child process will not be able to reopen the file so this flag is
// meaningless.
mBehaviorFlags &= ~nsIFileInputStream::REOPEN_ON_REWIND;
}
--- a/netwerk/base/nsIOService.cpp
+++ b/netwerk/base/nsIOService.cpp
@@ -277,17 +277,17 @@ nsIOService::InitializeNetworkLinkServic
return rv;
if (!NS_IsMainThread()) {
NS_WARNING("Network link service should be created on main thread");
return NS_ERROR_FAILURE;
}
// 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);
}
if (mNetworkLinkService) {
mNetworkLinkServiceInitialized = true;
}
@@ -903,17 +903,17 @@ nsIOService::SetOffline(bool offline)
mSettingOffline = true;
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
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 ?
MOZ_UTF16("true") :
MOZ_UTF16("false"));
}
}
@@ -992,17 +992,17 @@ nsIOService::GetConnectivity(bool *aConn
return NS_OK;
}
NS_IMETHODIMP
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);
}
nsresult
nsIOService::SetConnectivityInternal(bool aConnectivity)
@@ -1014,17 +1014,17 @@ nsIOService::SetConnectivityInternal(boo
mConnectivity = aConnectivity;
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (!observerService) {
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") :
MOZ_UTF16("false"));
}
if (mOffline) {
// We don't need to send any notifications if we're offline
--- a/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp
+++ b/netwerk/dns/mdns/libmdns/nsDNSServiceDiscovery.cpp
@@ -21,17 +21,17 @@ StartService()
property_get("init.svc.mdnsd", value, "");
if (strcmp(value, "running") == 0) {
return;
}
property_set("ctl.start", "mdnsd");
}
-void
+inline void
StopService()
{
char value[PROPERTY_VALUE_MAX] = { '\0' };
property_get("init.svc.mdnsd", value, "");
if (strcmp(value, "stopped") == 0) {
return;
}
--- a/netwerk/ipc/NeckoCommon.h
+++ b/netwerk/ipc/NeckoCommon.h
@@ -89,17 +89,17 @@ IsNeckoChild()
static bool amChild = false;
if (!didCheck) {
// This allows independent necko-stacks (instead of single stack in chrome)
// to still be run.
// 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;
}
namespace NeckoCommonInternal {
extern bool gSecurityDisabled;
extern bool gRegisteredBool;
--- a/netwerk/ipc/NeckoParent.cpp
+++ b/netwerk/ipc/NeckoParent.cpp
@@ -794,17 +794,17 @@ NeckoParent::NestedFrameAuthPrompt::Nest
NS_IMETHODIMP
NeckoParent::NestedFrameAuthPrompt::AsyncPromptAuth(
nsIChannel* aChannel, nsIAuthPromptCallback* callback,
nsISupports*, uint32_t,
nsIAuthInformation* aInfo, nsICancelable**)
{
static uint64_t callbackId = 0;
- MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default);
+ MOZ_ASSERT(XRE_IsParentProcess());
nsCOMPtr<nsIURI> uri;
nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsAutoCString spec;
if (uri) {
rv = uri->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
}
--- a/netwerk/protocol/app/AppProtocolHandler.cpp
+++ b/netwerk/protocol/app/AppProtocolHandler.cpp
@@ -441,17 +441,17 @@ AppProtocolHandler::NewChannel2(nsIURI*
dummyChannel->SetLoadInfo(aLoadInfo);
dummyChannel.forget(aResult);
return NS_OK;
}
mAppInfoCache.Put(host, appInfo);
}
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://"
: "jar:remoteopenfile://");
jarSpec += NS_ConvertUTF16toUTF8(appInfo->mPath) +
NS_LITERAL_CSTRING("/application.zip!") +
fileSpec;
--- a/netwerk/protocol/data/nsDataHandler.cpp
+++ b/netwerk/protocol/data/nsDataHandler.cpp
@@ -105,17 +105,17 @@ nsDataHandler::NewURI(const nsACString &
NS_IMETHODIMP
nsDataHandler::NewChannel2(nsIURI* uri,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
{
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);
}
NS_ADDREF(channel);
nsresult rv = channel->Init();
if (NS_FAILED(rv)) {
--- a/netwerk/protocol/device/AndroidCaptureProvider.cpp
+++ b/netwerk/protocol/device/AndroidCaptureProvider.cpp
@@ -33,17 +33,17 @@ AndroidCameraInputStream::~AndroidCamera
free(mFrameQueue->PopFront());
}
delete mFrameQueue;
}
NS_IMETHODIMP
AndroidCameraInputStream::Init(nsACString& aContentType, nsCaptureParams* aParams)
{
- if (XRE_GetProcessType() != GeckoProcessType_Default)
+ if (!XRE_IsParentProcess())
return NS_ERROR_NOT_IMPLEMENTED;
mContentType = aContentType;
mWidth = aParams->width;
mHeight = aParams->height;
mCamera = aParams->camera;
CameraStreamImpl *impl = CameraStreamImpl::GetInstance(0);
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -1533,17 +1533,17 @@ HttpBaseChannel::RedirectTo(nsIURI *newU
//-----------------------------------------------------------------------------
// HttpBaseChannel::nsIHttpChannelInternal
//-----------------------------------------------------------------------------
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;
}
NS_IMETHODIMP
HttpBaseChannel::GetTopWindowURI(nsIURI **aTopWindowURI)
{
@@ -2187,17 +2187,17 @@ HttpBaseChannel::DoNotifyListener()
void
HttpBaseChannel::AddCookiesToRequest()
{
if (mLoadFlags & LOAD_ANONYMOUS) {
return;
}
bool useCookieService =
- (XRE_GetProcessType() == GeckoProcessType_Default);
+ (XRE_IsParentProcess());
nsXPIDLCString cookie;
if (useCookieService) {
nsICookieService *cs = gHttpHandler->GetCookieService();
if (cs) {
cs->GetCookieStringFromHttp(mURI,
nullptr,
this, getter_Copies(cookie));
}
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -222,17 +222,17 @@ HttpChannelParent::GetInterface(const ns
if (aIID.Equals(NS_GET_IID(nsIAuthPromptProvider)) ||
aIID.Equals(NS_GET_IID(nsISecureBrowserUI))) {
if (mTabParent) {
return mTabParent->QueryInterface(aIID, 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;
}
// Only support nsILoadContext if child channel's callbacks did too
if (aIID.Equals(NS_GET_IID(nsILoadContext)) && mLoadContext) {
nsCOMPtr<nsILoadContext> copy = mLoadContext;
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -942,17 +942,17 @@ nsHtml5StreamParser::OnStartRequest(nsIR
do_QueryInterface(mRequest, &rv);
if (threadRetargetableRequest) {
rv = threadRetargetableRequest->RetargetDeliveryTo(mThread);
}
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.");
}
}
if (mCharsetSource == kCharsetFromParentFrame) {
// Remember this in case chardet overwrites mCharsetSource
mInitialEncodingWasFromParentFrame = true;
}
--- a/security/manager/ssl/PSMContentListener.cpp
+++ b/security/manager/ssl/PSMContentListener.cpp
@@ -397,17 +397,17 @@ PSMContentListener::DoContent(const nsAC
{
uint32_t type;
type = getPSMContentType(PromiseFlatCString(aContentType).get());
if (gPIPNSSLog) {
MOZ_LOG(gPIPNSSLog, LogLevel::Debug, ("PSMContentListener::DoContent\n"));
}
if (type != UNKNOWN_TYPE) {
nsCOMPtr<nsIStreamListener> downloader;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
downloader = new PSMContentStreamListener(type);
} else {
downloader = static_cast<PSMContentDownloaderChild*>(
dom::ContentChild::GetSingleton()->SendPPSMContentDownloaderConstructor(type));
}
downloader.forget(aContentHandler);
return NS_OK;
--- a/security/manager/ssl/TransportSecurityInfo.cpp
+++ b/security/manager/ssl/TransportSecurityInfo.cpp
@@ -234,17 +234,17 @@ TransportSecurityInfo::formatErrorMessag
bool wantsHtml, bool suppressPort443,
nsString &result)
{
result.Truncate();
if (errorCode == 0) {
return NS_OK;
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return NS_ERROR_UNEXPECTED;
}
nsresult rv;
NS_ConvertASCIItoUTF16 hostNameU(mHostName);
NS_ASSERTION(errorMessageType != OverridableCertErrorMessage ||
(mSSLStatus && mSSLStatus->HasServerCert() &&
mSSLStatus->mHaveCertErrorBits),
--- a/security/manager/ssl/nsNSSComponent.cpp
+++ b/security/manager/ssl/nsNSSComponent.cpp
@@ -65,17 +65,17 @@ int nsNSSComponent::mInstanceCount = 0;
bool nsPSMInitPanic::isPanic = false;
// This function can be called from chrome or content processes
// to ensure that NSS is initialized.
bool EnsureNSSInitializedChromeOrContent()
{
nsresult rv;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsCOMPtr<nsISupports> nss = do_GetService(PSM_COMPONENT_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return false;
}
return true;
}
--- a/security/manager/ssl/nsSiteSecurityService.cpp
+++ b/security/manager/ssl/nsSiteSecurityService.cpp
@@ -223,17 +223,17 @@ nsSiteSecurityService::~nsSiteSecuritySe
NS_IMPL_ISUPPORTS(nsSiteSecurityService,
nsIObserver,
nsISiteSecurityService)
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");
}
// Don't access Preferences off the main thread.
if (!NS_IsMainThread()) {
NS_NOTREACHED("nsSiteSecurityService initialized off main thread");
return NS_ERROR_NOT_SAME_THREAD;
}
--- a/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h
+++ b/security/sandbox/chromium-shim/sandbox/win/loggingCallbacks.h
@@ -118,17 +118,17 @@ InitLoggingIfRequired()
if (Preferences::GetBool("security.sandbox.windows.log") ||
PR_GetEnv("MOZ_WIN_SANDBOX_LOGGING")) {
sProvideLogFunctionCb(Log);
#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");
}
#endif
}
}
#endif
} // sandboxing
--- a/startupcache/StartupCache.cpp
+++ b/startupcache/StartupCache.cpp
@@ -82,17 +82,17 @@ StartupCache::CollectReports(nsIHandleRe
}
#define STARTUP_CACHE_NAME "startupCache." SC_WORDSIZE "." SC_ENDIAN
StartupCache*
StartupCache::GetSingleton()
{
if (!gStartupCache) {
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
#ifdef MOZ_DISABLE_STARTUPCACHE
return nullptr;
#endif
StartupCache::InitSingleton();
}
--- a/storage/VacuumManager.cpp
+++ b/storage/VacuumManager.cpp
@@ -310,17 +310,17 @@ NS_IMPL_ISUPPORTS(
VacuumManager *
VacuumManager::gVacuumManager = nullptr;
VacuumManager *
VacuumManager::getSingleton()
{
//Don't allocate it in the child Process.
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
if (gVacuumManager) {
NS_ADDREF(gVacuumManager);
return gVacuumManager;
}
gVacuumManager = new VacuumManager();
--- a/toolkit/components/alerts/nsAlertsService.cpp
+++ b/toolkit/components/alerts/nsAlertsService.cpp
@@ -67,17 +67,17 @@ NS_IMETHODIMP nsAlertsService::ShowAlert
nsIObserver * aAlertListener,
const nsAString & aAlertName,
const nsAString & aBidi,
const nsAString & aLang,
const nsAString & aData,
nsIPrincipal * aPrincipal,
bool aInPrivateBrowsing)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
ContentChild* cpc = ContentChild::GetSingleton();
if (aAlertListener)
cpc->AddRemoteAlertObserver(PromiseFlatString(aAlertCookie), aAlertListener);
cpc->SendShowAlertNotification(PromiseFlatString(aImageUrl),
PromiseFlatString(aAlertTitle),
PromiseFlatString(aAlertText),
@@ -123,17 +123,17 @@ NS_IMETHODIMP nsAlertsService::ShowAlert
aBidi, aLang, aInPrivateBrowsing);
return rv;
#endif // !MOZ_WIDGET_ANDROID
}
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;
}
#ifdef MOZ_WIDGET_ANDROID
widget::GeckoAppShell::CloseNotification(aAlertName);
return NS_OK;
--- a/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
+++ b/toolkit/components/diskspacewatcher/DiskSpaceWatcher.cpp
@@ -32,17 +32,17 @@ DiskSpaceWatcher::DiskSpaceWatcher()
DiskSpaceWatcher::~DiskSpaceWatcher()
{
MOZ_ASSERT(!gDiskSpaceWatcher);
}
already_AddRefed<DiskSpaceWatcher>
DiskSpaceWatcher::FactoryCreate()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return nullptr;
}
MOZ_ASSERT(NS_IsMainThread());
if (!Preferences::GetBool("disk_space_watcher.enabled", false)) {
return nullptr;
}
--- a/toolkit/components/places/Database.cpp
+++ b/toolkit/components/places/Database.cpp
@@ -576,17 +576,17 @@ Database::Database()
: mMainThreadStatements(mMainConn)
, mMainThreadAsyncStatements(mMainConn)
, mAsyncThreadStatements(mMainConn)
, mDBPageSize(0)
, mDatabaseStatus(nsINavHistoryService::DATABASE_STATUS_OK)
, 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);
gDatabase = this;
// Prepare async shutdown
nsCOMPtr<nsIAsyncShutdownClient> shutdownPhase = GetShutdownPhase();
MOZ_ASSERT(shutdownPhase);
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -474,17 +474,17 @@ public:
static nsresult Start(nsIURI* aURI,
mozIVisitedStatusCallback* aCallback=nullptr)
{
NS_PRECONDITION(aURI, "Null URI");
// 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);
mozilla::dom::ContentChild* cpc =
mozilla::dom::ContentChild::GetSingleton();
NS_ASSERTION(cpc, "Content Protocol is NULL!");
(void)cpc->SendStartVisitedQuery(uri);
return NS_OK;
@@ -1994,17 +1994,17 @@ History::InitMemoryReporter()
NS_IMETHODIMP
History::NotifyVisited(nsIURI* aURI)
{
NS_ENSURE_ARG(aURI);
nsAutoScriptBlocker scriptBlocker;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
nsTArray<ContentParent*> cplist;
ContentParent::GetAll(cplist);
if (!cplist.IsEmpty()) {
URIParams uri;
SerializeURI(aURI, uri);
for (uint32_t i = 0; i < cplist.Length(); ++i) {
unused << cplist[i]->SendNotifyVisited(uri);
@@ -2429,17 +2429,17 @@ History::VisitURI(nsIURI* aURI,
nsIURI* aLastVisitedURI,
uint32_t aFlags)
{
NS_PRECONDITION(aURI, "URI should not be NULL.");
if (mShuttingDown) {
return NS_OK;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
URIParams uri;
SerializeURI(aURI, uri);
OptionalURIParams lastVisitedURI;
SerializeURI(aLastVisitedURI, lastVisitedURI);
mozilla::dom::ContentChild* cpc =
mozilla::dom::ContentChild::GetSingleton();
@@ -2546,17 +2546,17 @@ History::VisitURI(nsIURI* aURI,
return NS_OK;
}
NS_IMETHODIMP
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!");
}
// Obtain our array of observers for this URI.
#ifdef DEBUG
bool keyAlreadyExists = !!mObservers.GetEntry(aURI);
#endif
KeyClass* key = mObservers.PutEntry(aURI);
@@ -2581,17 +2581,17 @@ History::RegisterVisitedCallback(nsIURI*
mObservers.RemoveEntry(aURI);
return rv;
}
}
// In IPC builds, we are passed a nullptr Link from
// 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;
}
// Sanity check that Links are not registered more than once for a given URI.
// This will not catch a case where it is registered for two different URIs.
NS_ASSERTION(!observers.Contains(aLink),
"Already tracking this Link object!");
@@ -2636,17 +2636,17 @@ History::UnregisterVisitedCallback(nsIUR
NS_IMETHODIMP
History::SetURITitle(nsIURI* aURI, const nsAString& aTitle)
{
NS_PRECONDITION(aURI, "Must pass a non-null URI!");
if (mShuttingDown) {
return NS_OK;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
URIParams uri;
SerializeURI(aURI, uri);
mozilla::dom::ContentChild * cpc =
mozilla::dom::ContentChild::GetSingleton();
NS_ASSERTION(cpc, "Content Protocol is NULL!");
(void)cpc->SendSetURITitle(uri, PromiseFlatString(aTitle));
return NS_OK;
@@ -2695,17 +2695,17 @@ History::AddDownload(nsIURI* aSource, ns
{
MOZ_ASSERT(NS_IsMainThread());
NS_ENSURE_ARG(aSource);
if (mShuttingDown) {
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;
}
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
// Silently return if URI is something we shouldn't add to DB.
@@ -2751,17 +2751,17 @@ NS_IMETHODIMP
History::RemoveAllDownloads()
{
MOZ_ASSERT(NS_IsMainThread());
if (mShuttingDown) {
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;
}
// Ensure navHistory is initialized.
nsNavHistory* navHistory = nsNavHistory::GetHistoryService();
NS_ENSURE_TRUE(navHistory, NS_ERROR_OUT_OF_MEMORY);
mozIStorageConnection* dbConn = GetDBConn();
--- a/toolkit/components/satchel/nsFormFillController.cpp
+++ b/toolkit/components/satchel/nsFormFillController.cpp
@@ -734,17 +734,17 @@ private:
};
void nsFormFillController::RevalidateDataList()
{
if (!mLastListener) {
return;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
nsCOMPtr<nsIAutoCompleteController> controller(do_QueryInterface(mLastListener));
if (!controller) {
return;
}
controller->StartSearch(mLastSearchString);
return;
}
--- a/toolkit/components/telemetry/Telemetry.cpp
+++ b/toolkit/components/telemetry/Telemetry.cpp
@@ -1843,20 +1843,18 @@ TelemetryImpl::AsyncFetchTelemetryData(n
profileDir);
targetThread->Dispatch(event, NS_DISPATCH_NORMAL);
return NS_OK;
}
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"),
mCachedTelemetryData(false),
mLastShutdownTime(0),
mFailedLockCount(0)
{
// Populate the static histogram name->id cache.
--- a/toolkit/crashreporter/nsExceptionHandler.cpp
+++ b/toolkit/crashreporter/nsExceptionHandler.cpp
@@ -1769,17 +1769,17 @@ nsresult AnnotateCrashReport(const nsACS
if (!GetEnabled())
return NS_ERROR_NOT_INITIALIZED;
nsCString escapedData;
nsresult rv = EscapeAnnotation(key, data, escapedData);
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;
}
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
if (!reporter) {
EnqueueDelayedNote(new DelayedNote(key, data));
return NS_OK;
@@ -1824,17 +1824,17 @@ void SetEventloopNestingLevel(uint32_t l
nsresult AppendAppNotesToCrashReport(const nsACString& data)
{
if (!GetEnabled())
return NS_ERROR_NOT_INITIALIZED;
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;
}
PCrashReporterChild* reporter = CrashReporterChild::GetCrashReporter();
if (!reporter) {
EnqueueDelayedNote(new DelayedNote(data));
return NS_OK;
--- a/toolkit/mozapps/extensions/AddonPathService.cpp
+++ b/toolkit/mozapps/extensions/AddonPathService.cpp
@@ -188,17 +188,17 @@ ResolveURI(nsIURI* aURI, nsAString& out)
return file->GetPath(out);
}
return NS_ERROR_FAILURE;
}
JSAddonId*
MapURIToAddonID(nsIURI* aURI)
{
- if (!NS_IsMainThread() || XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!NS_IsMainThread() || !XRE_IsParentProcess()) {
return nullptr;
}
nsAutoString filePath;
nsresult rv = ResolveURI(aURI, filePath);
if (NS_FAILED(rv))
return nullptr;
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -793,17 +793,17 @@ NS_INTERFACE_MAP_BEGIN(nsXULAppInfo)
#ifdef XP_WIN
NS_INTERFACE_MAP_ENTRY(nsIWinAppHelper)
#endif
#ifdef MOZ_CRASHREPORTER
NS_INTERFACE_MAP_ENTRY(nsICrashReporter)
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)
nsXULAppInfo::AddRef()
{
return 1;
}
@@ -811,56 +811,56 @@ NS_IMETHODIMP_(MozExternalRefCountType)
nsXULAppInfo::Release()
{
return 1;
}
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;
}
aResult.Assign(gAppData->vendor);
return NS_OK;
}
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;
}
aResult.Assign(gAppData->name);
return NS_OK;
}
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;
}
aResult.Assign(gAppData->ID);
return NS_OK;
}
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;
}
aResult.Assign(gAppData->version);
return NS_OK;
}
@@ -871,17 +871,17 @@ nsXULAppInfo::GetPlatformVersion(nsACStr
aResult.Assign(gToolkitVersion);
return NS_OK;
}
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;
}
aResult.Assign(gAppData->buildID);
return NS_OK;
}
@@ -892,17 +892,17 @@ nsXULAppInfo::GetPlatformBuildID(nsACStr
aResult.Assign(gToolkitBuildID);
return NS_OK;
}
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;
}
aResult.Assign(gAppData->UAName);
return NS_OK;
}
@@ -1054,17 +1054,17 @@ nsXULAppInfo::GetIs64Bit(bool* aResult)
*aResult = false;
#endif
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::EnsureContentProcess()
{
- if (XRE_GetProcessType() != GeckoProcessType_Default)
+ if (!XRE_IsParentProcess())
return NS_ERROR_NOT_AVAILABLE;
nsRefPtr<ContentParent> unused = ContentParent::GetNewOrUsedBrowserProcess();
return NS_OK;
}
NS_IMETHODIMP
nsXULAppInfo::InvalidateCachesOnRestart()
@@ -4542,16 +4542,22 @@ XRE_GetProcessType()
}
bool
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) {
gBrowserTabsRemoteDisabledReason.Assign(NS_ConvertASCIItoUTF16(reason));
nsAutoString msg(NS_LITERAL_STRING("==================\nE10s has been blocked from running because:\n"));
msg.Append(gBrowserTabsRemoteDisabledReason);
msg.AppendLiteral("\n==================\n");
--- a/toolkit/xre/nsSigHandlers.cpp
+++ b/toolkit/xre/nsSigHandlers.cpp
@@ -254,17 +254,17 @@ void InstallSignalHandlers(const char *P
/* Install a handler for floating point exceptions and disable them if they occur. */
struct sigaction sa, osa;
sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO;
sa.sa_sigaction = fpehandler;
sigemptyset(&sa.sa_mask);
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
* so the child isn't killed.
*/
signal(SIGINT, SIG_IGN);
}
--- a/tools/profiler/ProfileEntry.cpp
+++ b/tools/profiler/ProfileEntry.cpp
@@ -1008,17 +1008,17 @@ void ThreadProfile::StreamJSON(Spliceabl
void ThreadProfile::StreamSamplesAndMarkers(SpliceableJSONWriter& aWriter, double aSinceTime,
UniqueStacks& aUniqueStacks)
{
#ifndef SPS_STANDALONE
// Thread meta data
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");
} else {
aWriter.StringProperty("name", Name());
}
#else
aWriter.StringProperty("name", Name());
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -680,17 +680,17 @@ nsExternalHelperAppService::DoContentCon
NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeContentType,
nsIRequest *aRequest,
nsIInterfaceRequestor *aContentContext,
bool aForceSave,
nsIInterfaceRequestor *aWindowContext,
nsIStreamListener ** aStreamListener)
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return DoContentContentProcessHelper(aMimeContentType, aRequest, aContentContext,
aForceSave, aWindowContext, aStreamListener);
}
nsAutoString fileName;
nsAutoCString fileExtension;
uint32_t reason = nsIHelperAppLauncherDialog::REASON_CANTHANDLE;
uint32_t contentDisposition = -1;
@@ -936,17 +936,17 @@ static const char kExternalProtocolPrefP
static const char kExternalProtocolDefaultPref[] = "network.protocol-handler.external-default";
NS_IMETHODIMP
nsExternalHelperAppService::LoadURI(nsIURI *aURI,
nsIInterfaceRequestor *aWindowContext)
{
NS_ENSURE_ARG_POINTER(aURI);
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
URIParams uri;
SerializeURI(aURI, uri);
mozilla::dom::ContentChild::GetSingleton()->SendLoadURIExternal(uri);
return NS_OK;
}
nsAutoCString spec;
@@ -1240,17 +1240,17 @@ nsExternalAppHandler::nsExternalAppHandl
nsExternalAppHandler::~nsExternalAppHandler()
{
MOZ_ASSERT(!mSaver, "Saver should hold a reference to us until deleted");
}
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();
}
NS_IMETHODIMP nsExternalAppHandler::SetWebProgressListener(nsIWebProgressListener2 * aWebProgressListener)
{
// This is always called by nsHelperDlg.js. Go ahead and register the
@@ -1594,17 +1594,17 @@ NS_IMETHODIMP nsExternalAppHandler::OnSt
// still forward the decoded (uncompressed) data back to the parent.
// Con: Uncompressed data means more IPC overhead.
// Pros: ExternalHelperAppParent doesn't need to implement nsIEncodedChannel.
// Parent process doesn't need to expect CPU time on decompression.
MaybeApplyDecodingForExtension(aChannel);
// 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;
}
rv = SetUpTempFile(aChannel);
if (NS_FAILED(rv)) {
nsresult transferError = rv;
rv = CreateFailedTransfer(aChannel && NS_UsePrivateBrowsing(aChannel));
@@ -1833,17 +1833,17 @@ void nsExternalAppHandler::SendStatusCha
const char16_t *strings[] = { path.get() };
if (NS_SUCCEEDED(bundle->FormatStringFromName(msgId.get(), strings, 1,
getter_Copies(msgText)))) {
if (mDialogProgressListener) {
// We have a listener, let it handle the error.
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<nsIPrompt> prompter(do_GetInterface(GetDialogParent(), &qiRv));
nsXPIDLString title;
bundle->FormatStringFromName(MOZ_UTF16("title"),
strings,
1,
getter_Copies(title));
--- a/widget/GfxInfoBase.cpp
+++ b/widget/GfxInfoBase.cpp
@@ -677,17 +677,17 @@ GfxInfoBase::GetFeatureStatus(int32_t aF
gfxCriticalErrorOnce(gfxCriticalError::DefaultOptions(false)) << "Ignoring any feature blocklisting.";
*aStatus = FEATURE_STATUS_OK;
return NS_OK;
}
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;
cc->SendGetGraphicsFeatureStatus(aFeature, aStatus, &success);
return success ? NS_OK : NS_ERROR_FAILURE;
}
nsString version;
--- a/widget/PuppetWidget.cpp
+++ b/widget/PuppetWidget.cpp
@@ -983,17 +983,17 @@ PuppetWidget::MemoryPressureObserver::Ob
const char16_t* aData)
{
if (!mWidget) {
return NS_OK;
}
if (strcmp("memory-pressure", aTopic) == 0) {
if (!mWidget->mVisible && mWidget->mLayerManager &&
- XRE_GetProcessType() == GeckoProcessType_Content) {
+ XRE_IsContentProcess()) {
mWidget->mLayerManager->ClearCachedResources();
}
}
return NS_OK;
}
void
PuppetWidget::MemoryPressureObserver::Remove()
@@ -1004,17 +1004,17 @@ PuppetWidget::MemoryPressureObserver::Re
}
mWidget = nullptr;
}
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!");
return false;
}
return mVisible;
}
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -128,17 +128,17 @@ StaticRefPtr<WakeLockListener> sWakeLock
nsAppShell::nsAppShell()
: mQueueLock("nsAppShell.mQueueLock"),
mCondLock("nsAppShell.mCondLock"),
mQueueCond(mCondLock, "nsAppShell.mQueueCond"),
mQueuedViewportEvent(nullptr)
{
gAppShell = this;
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
return;
}
sPowerManagerService = do_GetService(POWERMANAGERSERVICE_CONTRACTID);
if (sPowerManagerService) {
sWakeLockListener = new WakeLockListener();
} else {
--- a/widget/android/nsLookAndFeel.cpp
+++ b/widget/android/nsLookAndFeel.cpp
@@ -82,17 +82,17 @@ nsLookAndFeel::CallRemoteGetSystemColors
}
nsresult
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();
NS_ENSURE_SUCCESS(rv, rv);
}
// XXX we'll want to use context.obtainStyledAttributes on the java side to
// get all of these; see TextView.java for a good exmaple.
@@ -464,17 +464,17 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
return true;
}
/*virtual*/
bool
nsLookAndFeel::GetEchoPasswordImpl()
{
if (!mInitializedShowPassword) {
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
mShowPassword = widget::GeckoAppShell::GetShowPasswordSetting();
} else {
ContentChild::GetSingleton()->SendGetShowPasswordSetting(&mShowPassword);
}
mInitializedShowPassword = true;
}
return mShowPassword;
}
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -780,17 +780,17 @@ nsWindow::OnGlobalAndroidEvent(AndroidGe
if (newScreenWidth == gAndroidScreenBounds.width &&
newScreenHeight == gAndroidScreenBounds.height)
break;
gAndroidScreenBounds.width = newScreenWidth;
gAndroidScreenBounds.height = newScreenHeight;
- if (XRE_GetProcessType() != GeckoProcessType_Default &&
+ if (!XRE_IsParentProcess() &&
!Preferences::GetBool("browser.tabs.remote.desktopbehavior", false)) {
break;
}
// Tell the content process the new screen size.
nsTArray<ContentParent*> cplist;
ContentParent::GetAll(cplist);
for (uint32_t i = 0; i < cplist.Length(); ++i)
@@ -926,17 +926,17 @@ nsWindow::InitEvent(WidgetGUIEvent& even
}
event.time = PR_Now() / 1000;
}
gfxIntSize
nsWindow::GetAndroidScreenBounds()
{
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
return ContentChild::GetSingleton()->GetScreenSize();
}
return gAndroidScreenBounds;
}
void *
nsWindow::GetNativeData(uint32_t aDataType)
{
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -685,13 +685,13 @@ nsLookAndFeel::SetIntCacheImpl(const nsT
}
void
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;
}
}
\ No newline at end of file
--- a/widget/gonk/nsAppShell.cpp
+++ b/widget/gonk/nsAppShell.cpp
@@ -879,17 +879,17 @@ nsAppShell::Init()
int ret = pipe2(signalfds, O_NONBLOCK);
NS_ENSURE_FALSE(ret, NS_ERROR_UNEXPECTED);
rv = AddFdHandler(signalfds[0], pipeHandler, "");
NS_ENSURE_SUCCESS(rv, rv);
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");
printf("***\n");
printf("*****************************************************************\n");
#ifdef MOZ_OMX_DECODER
android::MediaResourceManagerService::instantiate();
#endif
--- a/widget/gonk/nsClipboard.cpp
+++ b/widget/gonk/nsClipboard.cpp
@@ -26,17 +26,17 @@ nsClipboard::nsClipboard()
NS_IMETHODIMP
nsClipboard::SetData(nsITransferable *aTransferable,
nsIClipboardOwner *anOwner, int32_t aWhichClipboard)
{
if (aWhichClipboard != kGlobalClipboard) {
return NS_ERROR_NOT_IMPLEMENTED;
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
// Re-direct to the clipboard proxy.
nsRefPtr<nsClipboardProxy> clipboardProxy = new nsClipboardProxy();
return clipboardProxy->SetData(aTransferable, anOwner, aWhichClipboard);
}
nsCOMPtr<nsISupports> tmp;
uint32_t len;
nsresult rv = aTransferable->GetTransferData(kUnicodeMime, getter_AddRefs(tmp),
@@ -59,17 +59,17 @@ nsClipboard::SetData(nsITransferable *aT
NS_IMETHODIMP
nsClipboard::GetData(nsITransferable *aTransferable, int32_t aWhichClipboard)
{
if (aWhichClipboard != kGlobalClipboard) {
return NS_ERROR_NOT_IMPLEMENTED;
}
- if (XRE_GetProcessType() != GeckoProcessType_Default) {
+ if (!XRE_IsParentProcess()) {
// Re-direct to the clipboard proxy.
nsRefPtr<nsClipboardProxy> clipboardProxy = new nsClipboardProxy();
return clipboardProxy->GetData(aTransferable, aWhichClipboard);
}
nsAutoString buffer(mClipboard);
nsresult rv;
@@ -99,17 +99,17 @@ nsClipboard::GetData(nsITransferable *aT
}
NS_IMETHODIMP
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);
}
return NS_OK;
}
@@ -117,17 +117,17 @@ NS_IMETHODIMP
nsClipboard::HasDataMatchingFlavors(const char **aFlavorList,
uint32_t aLength, int32_t aWhichClipboard,
bool *aHasType)
{
*aHasType = false;
if (aWhichClipboard != kGlobalClipboard) {
return NS_ERROR_NOT_IMPLEMENTED;
}
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
*aHasType = !mClipboard.IsEmpty();
} else {
nsRefPtr<nsClipboardProxy> clipboardProxy = new nsClipboardProxy();
return clipboardProxy->HasDataMatchingFlavors(aFlavorList, aLength, aWhichClipboard, aHasType);
}
return NS_OK;
}
--- a/widget/gonk/nsWidgetFactory.cpp
+++ b/widget/gonk/nsWidgetFactory.cpp
@@ -67,17 +67,17 @@ NS_DEFINE_NAMED_CID(NS_IDLE_SERVICE_CID)
NS_DEFINE_NAMED_CID(NS_TRANSFERABLE_CID);
NS_DEFINE_NAMED_CID(NS_GFXINFO_CID);
NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID);
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);
}
static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
{ &kNS_WINDOW_CID, false, nullptr, nsWindowConstructor },
{ &kNS_CHILD_CID, false, nullptr, nsWindowConstructor },
{ &kNS_APPSHELL_CID, false, nullptr, nsAppShellConstructor },
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -2310,17 +2310,17 @@ public:
* Return true if this process shouldn't use platform widgets, and
* so should use PuppetWidgets instead. If this returns true, the
* result of creating and using a platform widget is undefined,
* and likely to end in crashes or other buggy behavior.
*/
static bool
UsePuppetWidgets()
{
- return XRE_GetProcessType() == GeckoProcessType_Content;
+ return XRE_IsContentProcess();
}
/**
* Allocate and return a "puppet widget" that doesn't directly
* correlate to a platform widget; platform events and data must
* be fed to it. Currently used in content processes. NULL is
* returned if puppet widgets aren't supported in this build
* config, on this platform, or for this process type.
--- a/widget/nsIdleService.cpp
+++ b/widget/nsIdleService.cpp
@@ -393,17 +393,17 @@ nsIdleService::nsIdleService() : mCurren
mIdleObserverCount(0),
mDeltaToNextIdleSwitchInS(UINT32_MAX),
mLastUserInteraction(TimeStamp::Now())
{
if (sLog == nullptr)
sLog = PR_NewLogModule("idleService");
MOZ_ASSERT(!gIdleService);
gIdleService = this;
- if (XRE_GetProcessType() == GeckoProcessType_Default) {
+ if (XRE_IsParentProcess()) {
mDailyIdle = new nsIdleServiceDaily(this);
mDailyIdle->Init();
}
}
nsIdleService::~nsIdleService()
{
if(mTimer) {
@@ -420,17 +420,17 @@ NS_IMPL_ISUPPORTS(nsIdleService, nsIIdle
NS_IMETHODIMP
nsIdleService::AddIdleObserver(nsIObserver* aObserver, uint32_t aIdleTimeInS)
{
NS_ENSURE_ARG_POINTER(aObserver);
// We don't accept idle time at 0, and we can't handle idle time that are too
// 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;
}
MOZ_LOG(sLog, LogLevel::Debug,
("idleService: Register idle observer %p for %d seconds",
aObserver, aIdleTimeInS));
@@ -479,17 +479,17 @@ nsIdleService::AddIdleObserver(nsIObserv
NS_IMETHODIMP
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;
}
IdleListener listener(aObserver, aTimeInS);
// Find the entry and remove it, if it was the last entry, we just let the
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -451,17 +451,17 @@ nsXPLookAndFeel::Init()
InitColorFromPref(i);
}
bool val;
if (NS_SUCCEEDED(Preferences::GetBool("ui.use_native_colors", &val))) {
sUseNativeColors = val;
}
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
mozilla::dom::ContentChild* cc =
mozilla::dom::ContentChild::GetSingleton();
nsTArray<LookAndFeelInt> lookAndFeelIntCache;
cc->SendGetLookAndFeelCache(lookAndFeelIntCache);
LookAndFeel::SetIntCache(lookAndFeelIntCache);
}
}
--- a/widget/windows/AudioSession.cpp
+++ b/widget/windows/AudioSession.cpp
@@ -188,20 +188,20 @@ AudioSession::Start()
// Don't check for errors in case something already initialized COM
// on this thread.
CoInitialize(nullptr);
if (mState == UNINITIALIZED) {
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<nsIStringBundleService> bundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID);
NS_ENSURE_TRUE(bundleService, NS_ERROR_FAILURE);
nsCOMPtr<nsIStringBundle> bundle;
bundleService->CreateBundle("chrome://branding/locale/brand.properties",
getter_AddRefs(bundle));
@@ -310,17 +310,17 @@ AudioSession::Stop()
mState == UNINITIALIZED || // XXXremove this
mState == FAILED,
"State invariants violated");
mState = STOPPED;
nsRefPtr<AudioSession> kungFuDeathGrip;
kungFuDeathGrip.swap(sService);
- if (XRE_GetProcessType() != GeckoProcessType_Content)
+ if (!XRE_IsContentProcess())
StopInternal();
// At this point kungFuDeathGrip should be the only reference to AudioSession
::CoUninitialize();
return NS_OK;
}
@@ -357,17 +357,17 @@ AudioSession::GetSessionData(nsID& aID,
nsresult
AudioSession::SetSessionData(const nsID& aID,
const nsString& aSessionName,
const nsString& aIconPath)
{
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;
CopynsID(mSessionGroupingParameter, aID);
mDisplayName = aSessionName;
mIconPath = aIconPath;
return NS_OK;
}
--- a/widget/windows/nsNativeThemeWin.cpp
+++ b/widget/windows/nsNativeThemeWin.cpp
@@ -61,17 +61,17 @@ nsNativeThemeWin::~nsNativeThemeWin()
}
static int32_t
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
// until it finds a real window.
nsIWidget* widget = aFrame->GetNearestWidget();
nsWindowBase * window = static_cast<nsWindowBase*>(widget);
if (!window)
return mozilla::widget::themeconst::FS_INACTIVE;
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -401,17 +401,17 @@ NS_DebugBreak(uint32_t aSeverity, const
Break(buf.buffer);
return;
case NS_DEBUG_ABORT: {
#if defined(MOZ_CRASHREPORTER) && !defined(MOZILLA_XPCOMRT_API)
// 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 += ")";
CrashReporter::AppendAppNotesToCrashReport(note);
CrashReporter::AnnotateCrashReport(NS_LITERAL_CSTRING("AbortMessage"),
nsDependentCString(buf.buffer));
}
#endif // MOZ_CRASHREPORTER
--- a/xpcom/base/nsDumpUtils.cpp
+++ b/xpcom/base/nsDumpUtils.cpp
@@ -257,17 +257,17 @@ FifoWatcher::GetSingleton()
return sSingleton;
}
/* static */ bool
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;
}
if (!Preferences::GetBool(kPrefName, false)) {
LOG("Fifo watcher disabled via pref.");
return false;
--- a/xpcom/base/nsMemoryInfoDumper.cpp
+++ b/xpcom/base/nsMemoryInfoDumper.cpp
@@ -479,17 +479,17 @@ public:
{
nsAutoCString process;
if (aProcess.IsEmpty()) {
// If the process is empty, the report originated with the process doing
// the dumping. In that case, generate the process identifier, which is
// 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()) {
// Try to get the process name from ContentChild.
cc->GetProcessName(process);
}
ContentChild::AppendProcessId(process);
--- a/xpcom/base/nsTraceRefcnt.cpp
+++ b/xpcom/base/nsTraceRefcnt.cpp
@@ -637,17 +637,17 @@ InitLog(const char* aEnvVar, const char*
} else if (nsCRT::strcmp(value, "2") == 0) {
*aResult = stderr;
fprintf(stdout, "### %s defined -- logging %s to stderr\n",
aEnvVar, aMsg);
return true;
} 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) {
fname.Cut(fname.Length() - 4, 4);
}
fname.Append('_');
fname.Append((char*)XRE_ChildProcessTypeToString(XRE_GetProcessType()));
fname.AppendLiteral("_pid");
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -530,17 +530,17 @@ NS_InitXPCOM2(nsIServiceManager** aResul
if (!MessageLoop::current()) {
sMessageLoop = new MessageLoopForUI(MessageLoop::TYPE_MOZILLA_UI);
sMessageLoop->set_thread_name("Gecko");
// Set experimental values for main thread hangs:
// 128ms for transient hangs and 8192ms for permanent hangs
sMessageLoop->set_hang_timeouts(128, 8192);
}
- if (XRE_GetProcessType() == GeckoProcessType_Default &&
+ if (XRE_IsParentProcess() &&
!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
UniquePtr<BrowserProcessSubThread> ioThread = MakeUnique<BrowserProcessSubThread>(BrowserProcessSubThread::IO);
base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
if (NS_WARN_IF(!ioThread->StartWithOptions(options))) {
return NS_ERROR_FAILURE;
}
@@ -728,17 +728,17 @@ NS_InitXPCOM2(nsIServiceManager** aResul
NS_XPCOM_STARTUP_OBSERVER_ID);
#ifdef XP_WIN
CreateAnonTempFileRemover();
#endif
// 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();
}
// The memory reporter manager is up and running -- register our reporters.
RegisterStrongMemoryReporter(new ICUReporter());
RegisterStrongMemoryReporter(new OggReporter());
#ifdef MOZ_VPX
RegisterStrongMemoryReporter(new VPXReporter());
@@ -959,17 +959,17 @@ ShutdownXPCOM(nsIServiceManager* aServMg
#endif
#if defined(XP_WIN)
// This exit(0) call is intended to be temporary, to get shutdown leak
// checking working on Linux.
// 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);
}
#endif
// Shutdown xpcom. This will release all loaders and cause others holding
// a refcount to the component manager to release it.
if (nsComponentManagerImpl::gComponentManager) {
@@ -1043,17 +1043,17 @@ ShutdownXPCOM(nsIServiceManager* aServMg
NS_LogTerm();
#if defined(MOZ_WIDGET_GONK)
// This exit(0) call is intended to be temporary, to get shutdown leak
// 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);
}
#endif
return NS_OK;
}
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -402,16 +402,19 @@ XRE_API(nsresult,
mozilla::gmp::GMPLoader* aGMPLoader))
XRE_API(GeckoProcessType,
XRE_GetProcessType, ())
XRE_API(bool,
XRE_IsParentProcess, ())
+XRE_API(bool,
+ XRE_IsContentProcess, ())
+
typedef void (*MainFunction)(void* aData);
XRE_API(nsresult,
XRE_InitParentProcess, (int aArgc,
char* aArgv[],
MainFunction aMainFunction,
void* aMainFunctionExtraData))
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -584,17 +584,17 @@ ParseManifest(NSLocationType aType, File
if (mozilla::AndroidBridge::Bridge()) {
mozilla::AndroidBridge::Bridge()->GetStaticStringField("android/os/Build$VERSION",
"RELEASE",
osVersion);
isTablet = mozilla::widget::GeckoAppShell::IsTablet();
}
#endif
- if (XRE_GetProcessType() == GeckoProcessType_Content) {
+ if (XRE_IsContentProcess()) {
process = kContent;
} else {
process = kMain;
}
// Because contracts must be registered after CIDs, we save and process them
// at the end.
nsTArray<CachedDirective> contracts;
--- a/xpcom/io/nsAnonymousTemporaryFile.cpp
+++ b/xpcom/io/nsAnonymousTemporaryFile.cpp
@@ -298,17 +298,17 @@ NS_IMPL_ISUPPORTS(nsAnonTempFileRemover,
nsresult
CreateAnonTempFileRemover()
{
// Create a temp file remover. If Init() succeeds, the temp file remover is kept
// alive by a reference held by the observer service, since the temp file remover
// 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<nsAnonTempFileRemover> tempRemover = new nsAnonTempFileRemover();
return tempRemover->Init();
}
#endif
--- a/xpcom/libxpcomrt/XPCOMRTStubs.cpp
+++ b/xpcom/libxpcomrt/XPCOMRTStubs.cpp
@@ -9,16 +9,28 @@
GeckoProcessType
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;
class nsCString;
namespace base {
class Histogram;
}
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -697,17 +697,17 @@ public:
{
if (sCanaryOutputFD != 0 && EventLatencyIsImportant()) {
ualarm(0, 0);
}
}
static bool EventLatencyIsImportant()
{
- return NS_IsMainThread() && XRE_GetProcessType() == GeckoProcessType_Default;
+ return NS_IsMainThread() && XRE_IsParentProcess();
}
};
void canary_alarm_handler(int signum)
{
void* array[30];
const char msg[29] = "event took too long to run:\n";
// use write to be safe in the signal handler