Skip to content

Commit 702a59d

Browse files
committed
Bug 1171931 - Refactor duplicated code using XRE_IsParent/ContentProcess. r=froydnj
--HG-- extra : rebase_source : 2ecbe6c1dd8a7ad8dc529b53349ad431cf1116c9
1 parent 6abe462 commit 702a59d

File tree

201 files changed

+506
-579
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

201 files changed

+506
-579
lines changed

accessible/base/nsAccessibilityService.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,7 @@ nsAccessibilityService::Init()
12601260
logging::CheckEnv();
12611261
#endif
12621262

1263-
if (XRE_GetProcessType() == GeckoProcessType_Default)
1263+
if (XRE_IsParentProcess())
12641264
gApplicationAccessible = new ApplicationAccessibleWrap();
12651265
else
12661266
gApplicationAccessible = new ApplicationAccessible();
@@ -1281,7 +1281,7 @@ nsAccessibilityService::Init()
12811281
gIsShutdown = false;
12821282

12831283
// Now its safe to start platform accessibility.
1284-
if (XRE_GetProcessType() == GeckoProcessType_Default)
1284+
if (XRE_IsParentProcess())
12851285
PlatformInit();
12861286

12871287
return true;
@@ -1324,7 +1324,7 @@ nsAccessibilityService::Shutdown()
13241324

13251325
gIsShutdown = true;
13261326

1327-
if (XRE_GetProcessType() == GeckoProcessType_Default)
1327+
if (XRE_IsParentProcess())
13281328
PlatformShutdown();
13291329

13301330
gApplicationAccessible->Shutdown();

accessible/base/nsAccessibilityService.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ IPCAccessibilityActive()
282282
#ifdef MOZ_B2G
283283
return false;
284284
#else
285-
return XRE_GetProcessType() == GeckoProcessType_Content &&
285+
return XRE_IsContentProcess() &&
286286
mozilla::Preferences::GetBool("accessibility.ipc_architecture.enabled", true);
287287
#endif
288288
}

accessible/base/nsCoreUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ nsCoreUtils::IsTabDocument(nsIDocument* aDocumentNode)
425425
treeItem->GetParent(getter_AddRefs(parentTreeItem));
426426

427427
// Tab document running in own process doesn't have parent.
428-
if (XRE_GetProcessType() == GeckoProcessType_Content)
428+
if (XRE_IsContentProcess())
429429
return !parentTreeItem;
430430

431431
// Parent of docshell for tab document running in chrome process is root.

accessible/windows/msaa/nsWinUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ nsWinUtils::MaybeStartWindowEmulation()
6464

6565
if (Compatibility::IsJAWS() || Compatibility::IsWE() ||
6666
Compatibility::IsDolphin() ||
67-
XRE_GetProcessType() == GeckoProcessType_Content) {
67+
XRE_IsContentProcess()) {
6868
RegisterNativeWindow(kClassNameTabContent);
6969
sHWNDCache = new nsRefPtrHashtable<nsPtrHashKey<void>, DocAccessible>(2);
7070
return true;

caps/DomainPolicy.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static nsresult
2222
BroadcastDomainSetChange(DomainSetType aSetType, DomainSetChangeType aChangeType,
2323
nsIURI* aDomain = nullptr)
2424
{
25-
MOZ_ASSERT(XRE_GetProcessType() == GeckoProcessType_Default,
25+
MOZ_ASSERT(XRE_IsParentProcess(),
2626
"DomainPolicy should only be exposed to the chrome process.");
2727

2828
nsTArray<ContentParent*> parents;
@@ -45,7 +45,7 @@ DomainPolicy::DomainPolicy() : mBlacklist(new DomainSet(BLACKLIST))
4545
, mWhitelist(new DomainSet(WHITELIST))
4646
, mSuperWhitelist(new DomainSet(SUPER_WHITELIST))
4747
{
48-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
48+
if (XRE_IsParentProcess()) {
4949
BroadcastDomainSetChange(NO_TYPE, ACTIVATE_POLICY);
5050
}
5151
}
@@ -112,7 +112,7 @@ DomainPolicy::Deactivate()
112112
if (ssm) {
113113
ssm->DeactivateDomainPolicy();
114114
}
115-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
115+
if (XRE_IsParentProcess()) {
116116
BroadcastDomainSetChange(NO_TYPE, DEACTIVATE_POLICY);
117117
}
118118
return NS_OK;
@@ -170,7 +170,7 @@ DomainSet::Add(nsIURI* aDomain)
170170
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
171171
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
172172
mHashTable.PutEntry(clone);
173-
if (XRE_GetProcessType() == GeckoProcessType_Default)
173+
if (XRE_IsParentProcess())
174174
return BroadcastDomainSetChange(mType, ADD_DOMAIN, aDomain);
175175

176176
return NS_OK;
@@ -182,7 +182,7 @@ DomainSet::Remove(nsIURI* aDomain)
182182
nsCOMPtr<nsIURI> clone = GetCanonicalClone(aDomain);
183183
NS_ENSURE_TRUE(clone, NS_ERROR_FAILURE);
184184
mHashTable.RemoveEntry(clone);
185-
if (XRE_GetProcessType() == GeckoProcessType_Default)
185+
if (XRE_IsParentProcess())
186186
return BroadcastDomainSetChange(mType, REMOVE_DOMAIN, aDomain);
187187

188188
return NS_OK;
@@ -192,7 +192,7 @@ NS_IMETHODIMP
192192
DomainSet::Clear()
193193
{
194194
mHashTable.Clear();
195-
if (XRE_GetProcessType() == GeckoProcessType_Default)
195+
if (XRE_IsParentProcess())
196196
return BroadcastDomainSetChange(mType, CLEAR_DOMAINS);
197197

198198
return NS_OK;

caps/nsScriptSecurityManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ nsScriptSecurityManager::~nsScriptSecurityManager(void)
12851285
// ContentChild might hold a reference to the domain policy,
12861286
// and it might release it only after the security manager is
12871287
// gone. But we can still assert this for the main process.
1288-
MOZ_ASSERT_IF(XRE_GetProcessType() == GeckoProcessType_Default,
1288+
MOZ_ASSERT_IF(XRE_IsParentProcess(),
12891289
!mDomainPolicy);
12901290
}
12911291

@@ -1502,7 +1502,7 @@ nsScriptSecurityManager::GetDomainPolicyActive(bool *aRv)
15021502
NS_IMETHODIMP
15031503
nsScriptSecurityManager::ActivateDomainPolicy(nsIDomainPolicy** aRv)
15041504
{
1505-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
1505+
if (!XRE_IsParentProcess()) {
15061506
return NS_ERROR_SERVICE_NOT_AVAILABLE;
15071507
}
15081508

docshell/base/nsDefaultURIFixup.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ nsDefaultURIFixup::KeywordToURI(const nsACString& aKeyword,
416416
}
417417
keyword.Trim(" ");
418418

419-
if (XRE_GetProcessType() == GeckoProcessType_Content) {
419+
if (XRE_IsContentProcess()) {
420420
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
421421
if (!contentChild) {
422422
return NS_ERROR_NOT_AVAILABLE;

docshell/base/nsDocShell.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ IncreasePrivateDocShellCount()
824824
{
825825
gNumberOfPrivateDocShells++;
826826
if (gNumberOfPrivateDocShells > 1 ||
827-
XRE_GetProcessType() != GeckoProcessType_Content) {
827+
!XRE_IsContentProcess()) {
828828
return;
829829
}
830830

@@ -838,7 +838,7 @@ DecreasePrivateDocShellCount()
838838
MOZ_ASSERT(gNumberOfPrivateDocShells > 0);
839839
gNumberOfPrivateDocShells--;
840840
if (!gNumberOfPrivateDocShells) {
841-
if (XRE_GetProcessType() == GeckoProcessType_Content) {
841+
if (XRE_IsContentProcess()) {
842842
dom::ContentChild* cc = dom::ContentChild::GetSingleton();
843843
cc->SendPrivateDocShellsExist(false);
844844
return;
@@ -5021,7 +5021,7 @@ nsDocShell::DisplayLoadError(nsresult aError, nsIURI* aURI,
50215021
mInPrivateBrowsing ? nsISocketProvider::NO_PERMANENT_STORAGE : 0;
50225022
bool isStsHost = false;
50235023
bool isPinnedHost = false;
5024-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
5024+
if (XRE_IsParentProcess()) {
50255025
nsCOMPtr<nsISiteSecurityService> sss =
50265026
do_GetService(NS_SSSERVICE_CONTRACTID, &rv);
50275027
NS_ENSURE_SUCCESS(rv, rv);
@@ -9449,7 +9449,7 @@ nsDocShell::CopyFavicon(nsIURI* aOldURI,
94499449
nsIURI* aNewURI,
94509450
bool aInPrivateBrowsing)
94519451
{
9452-
if (XRE_GetProcessType() == GeckoProcessType_Content) {
9452+
if (XRE_IsContentProcess()) {
94539453
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
94549454
if (contentChild) {
94559455
mozilla::ipc::URIParams oldURI, newURI;
@@ -13991,7 +13991,7 @@ nsDocShell::MaybeNotifyKeywordSearchLoading(const nsString& aProvider,
1399113991
return;
1399213992
}
1399313993

13994-
if (XRE_GetProcessType() == GeckoProcessType_Content) {
13994+
if (XRE_IsContentProcess()) {
1399513995
dom::ContentChild* contentChild = dom::ContentChild::GetSingleton();
1399613996
if (contentChild) {
1399713997
contentChild->SendNotifyKeywordSearchLoading(aProvider, aKeyword);

dom/asmjscache/AsmJSCache.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ namespace asmjscache {
5959

6060
namespace {
6161

62-
bool
63-
IsMainProcess()
64-
{
65-
return XRE_GetProcessType() == GeckoProcessType_Default;
66-
}
67-
6862
// Anything smaller should compile fast enough that caching will just add
6963
// overhead.
7064
static const size_t sMinCachedModuleLength = 10000;
@@ -503,7 +497,7 @@ class MainProcessRunnable : public virtual FileDescriptorHolder
503497
mIsApp(false),
504498
mEnforcingQuota(true)
505499
{
506-
MOZ_ASSERT(IsMainProcess());
500+
MOZ_ASSERT(XRE_IsParentProcess());
507501
}
508502

509503
virtual ~MainProcessRunnable()
@@ -1133,7 +1127,7 @@ class SingleProcessRunnable final : public File,
11331127
: MainProcessRunnable(aPrincipal, aOpenMode, aWriteParams),
11341128
mReadParams(aReadParams)
11351129
{
1136-
MOZ_ASSERT(IsMainProcess());
1130+
MOZ_ASSERT(XRE_IsParentProcess());
11371131
MOZ_ASSERT(!NS_IsMainThread());
11381132
MOZ_COUNT_CTOR(SingleProcessRunnable);
11391133
}
@@ -1211,7 +1205,7 @@ class ParentProcessRunnable final : public PAsmJSCacheEntryParent,
12111205
mOpened(false),
12121206
mFinished(false)
12131207
{
1214-
MOZ_ASSERT(IsMainProcess());
1208+
MOZ_ASSERT(XRE_IsParentProcess());
12151209
MOZ_ASSERT(NS_IsMainThread());
12161210
MOZ_COUNT_CTOR(ParentProcessRunnable);
12171211
}
@@ -1388,7 +1382,7 @@ class ChildProcessRunnable final : public File,
13881382
mActorDestroyed(false),
13891383
mState(eInitial)
13901384
{
1391-
MOZ_ASSERT(!IsMainProcess());
1385+
MOZ_ASSERT(!XRE_IsParentProcess());
13921386
MOZ_ASSERT(!NS_IsMainThread());
13931387
MOZ_COUNT_CTOR(ChildProcessRunnable);
13941388
}
@@ -1584,7 +1578,7 @@ OpenFile(nsIPrincipal* aPrincipal,
15841578
// parent process to open the file and interact with the QuotaManager. The
15851579
// child can then map the file into its address space to perform I/O.
15861580
nsRefPtr<File> file;
1587-
if (IsMainProcess()) {
1581+
if (XRE_IsParentProcess()) {
15881582
file = new SingleProcessRunnable(aPrincipal, aOpenMode, aWriteParams,
15891583
aReadParams);
15901584
} else {

dom/audiochannel/AudioChannelService.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ AudioChannelService::GetAudioChannelService()
7070
{
7171
MOZ_ASSERT(NS_IsMainThread());
7272

73-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
73+
if (!XRE_IsParentProcess()) {
7474
return AudioChannelServiceChild::GetAudioChannelService();
7575
}
7676

@@ -84,7 +84,7 @@ AudioChannelService::GetOrCreateAudioChannelService()
8484
{
8585
MOZ_ASSERT(NS_IsMainThread());
8686

87-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
87+
if (!XRE_IsParentProcess()) {
8888
return AudioChannelServiceChild::GetOrCreateAudioChannelService();
8989
}
9090

@@ -104,7 +104,7 @@ AudioChannelService::GetOrCreateAudioChannelService()
104104
void
105105
AudioChannelService::Shutdown()
106106
{
107-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
107+
if (!XRE_IsParentProcess()) {
108108
return AudioChannelServiceChild::Shutdown();
109109
}
110110

@@ -122,7 +122,7 @@ AudioChannelService::AudioChannelService()
122122
, mDisabled(false)
123123
, mDefChannelChildID(CONTENT_PROCESS_ID_UNKNOWN)
124124
{
125-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
125+
if (XRE_IsParentProcess()) {
126126
nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
127127
if (obs) {
128128
obs->AddObserver(this, "ipc:content-shutdown", false);
@@ -180,7 +180,7 @@ AudioChannelService::RegisterType(AudioChannel aChannel, uint64_t aChildID,
180180
AudioChannelInternalType type = GetInternalType(aChannel, true);
181181
mChannelCounters[type].AppendElement(aChildID);
182182

183-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
183+
if (XRE_IsParentProcess()) {
184184

185185
// We must keep the childIds in order to decide which app is allowed to play
186186
// with then telephony channel.
@@ -272,7 +272,7 @@ AudioChannelService::UnregisterType(AudioChannel aChannel,
272272
// There are two reasons to defer the decrease of telephony channel.
273273
// 1. User can have time to remove device from his ear before music resuming.
274274
// 2. Give BT SCO to be disconnected before starting to connect A2DP.
275-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
275+
if (XRE_IsParentProcess()) {
276276

277277
if (aChannel == AudioChannel::Telephony) {
278278
UnregisterTelephonyChild(aChildID);
@@ -306,7 +306,7 @@ AudioChannelService::UnregisterTypeInternal(AudioChannel aChannel,
306306

307307
// In order to avoid race conditions, it's safer to notify any existing
308308
// agent any time a new one is registered.
309-
if (XRE_GetProcessType() == GeckoProcessType_Default) {
309+
if (XRE_IsParentProcess()) {
310310
// No hidden content channel is playable if the original playable hidden
311311
// process does not need to play audio from background anymore.
312312
if (aChannel == AudioChannel::Content &&
@@ -547,7 +547,7 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel,
547547
bool aVisible,
548548
uint64_t aChildID)
549549
{
550-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
550+
if (!XRE_IsParentProcess()) {
551551
return;
552552
}
553553

@@ -590,7 +590,7 @@ AudioChannelService::SetDefaultVolumeControlChannelInternal(int32_t aChannel,
590590
void
591591
AudioChannelService::SendAudioChannelChangedNotification(uint64_t aChildID)
592592
{
593-
if (XRE_GetProcessType() != GeckoProcessType_Default) {
593+
if (!XRE_IsParentProcess()) {
594594
return;
595595
}
596596

0 commit comments

Comments
 (0)