Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2024-11-21 21:09:29 +08:00
commit 310c05b97a
177 changed files with 514 additions and 4888 deletions

View file

@ -25,7 +25,6 @@
#include "HandlerServiceParent.h"
#include "IHistory.h"
#include "imgIContainer.h"
#include "mozIApplication.h"
#if defined(XP_WIN) && defined(ACCESSIBILITY)
#include "mozilla/a11y/AccessibleWrap.h"
#endif
@ -95,7 +94,6 @@
#include "nsFrameMessageManager.h"
#include "nsHashPropertyBag.h"
#include "nsIAlertsService.h"
#include "nsIAppsService.h"
#include "nsIClipboard.h"
#include "nsContentPermissionHelper.h"
#include "nsICycleCollectorListener.h"
@ -143,7 +141,6 @@
#include "nsThreadUtils.h"
#include "nsToolkitCompsCID.h"
#include "nsWidgetsCID.h"
#include "PreallocatedProcessManager.h"
#include "ProcessPriorityManager.h"
#include "SandboxHal.h"
#include "ScreenManagerParent.h"
@ -456,8 +453,7 @@ ContentParentsMemoryReporter::CollectReports(
return NS_OK;
}
nsDataHashtable<nsStringHashKey, ContentParent*>* ContentParent::sAppContentParents;
nsTArray<ContentParent*>* ContentParent::sNonAppContentParents;
nsTArray<ContentParent*>* ContentParent::sBrowserContentParents;
nsTArray<ContentParent*>* ContentParent::sLargeAllocationContentParents;
nsTArray<ContentParent*>* ContentParent::sPrivateContent;
StaticAutoPtr<LinkedList<ContentParent> > ContentParent::sContentParents;
@ -473,11 +469,6 @@ static bool sDisableUnsafeCPOWWarnings = false;
// The first content child has ID 1, so the chrome process can have ID 0.
static uint64_t gContentChildID = 1;
// We want the prelaunched process to know that it's for apps, but not
// actually for any app in particular. Use a magic manifest URL.
// Can't be a static constant.
#define MAGIC_PREALLOCATED_APP_MANIFEST_URL NS_LITERAL_STRING("{{template}}")
static const char* sObserverTopics[] = {
"xpcom-shutdown",
"profile-before-change",
@ -496,77 +487,6 @@ static const char* sObserverTopics[] = {
"cacheservice:empty-cache",
};
// PreallocateAppProcess is called by the PreallocatedProcessManager.
// ContentParent then takes this process back within
// GetNewOrPreallocatedAppProcess.
/*static*/ already_AddRefed<ContentParent>
ContentParent::PreallocateAppProcess()
{
RefPtr<ContentParent> process =
new ContentParent(/* app = */ nullptr,
/* aOpener = */ nullptr,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ true);
if (!process->LaunchSubprocess(PROCESS_PRIORITY_PREALLOC)) {
return nullptr;
}
process->Init();
return process.forget();
}
/*static*/ already_AddRefed<ContentParent>
ContentParent::GetNewOrPreallocatedAppProcess(mozIApplication* aApp,
ProcessPriority aInitialPriority,
ContentParent* aOpener,
/*out*/ bool* aTookPreAllocated)
{
MOZ_ASSERT(aApp);
RefPtr<ContentParent> process = PreallocatedProcessManager::Take();
if (process) {
if (!process->SetPriorityAndCheckIsAlive(aInitialPriority)) {
// Kill the process just in case it's not actually dead; we don't want
// to "leak" this process!
process->KillHard("GetNewOrPreallocatedAppProcess");
}
else {
nsAutoString manifestURL;
if (NS_FAILED(aApp->GetManifestURL(manifestURL))) {
NS_ERROR("Failed to get manifest URL");
return nullptr;
}
process->TransformPreallocatedIntoApp(aOpener, manifestURL);
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = true;
}
return process.forget();
}
}
NS_WARNING("Unable to use pre-allocated app process");
process = new ContentParent(aApp,
/* aOpener = */ aOpener,
/* isForBrowserElement = */ false,
/* isForPreallocated = */ false);
if (!process->LaunchSubprocess(aInitialPriority)) {
return nullptr;
}
process->Init();
process->ForwardKnownInfo();
if (aTookPreAllocated) {
*aTookPreAllocated = false;
}
return process.forget();
}
/*static*/ void
ContentParent::StartUp()
{
@ -588,9 +508,6 @@ ContentParent::StartUp()
BackgroundChild::Startup();
// Try to preallocate a process that we can transform into an app later.
PreallocatedProcessManager::AllocateAfterDelay();
sDisableUnsafeCPOWWarnings = PR_GetEnv("DISABLE_UNSAFE_CPOW_WARNINGS");
}
@ -668,10 +585,10 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
maxContentParents = Preferences::GetInt("dom.ipc.dedicatedProcessCount", 2);
} else {
if (!sNonAppContentParents) {
sNonAppContentParents = new nsTArray<ContentParent*>();
if (!sBrowserContentParents) {
sBrowserContentParents = new nsTArray<ContentParent*>();
}
contentParents = sNonAppContentParents;
contentParents = sBrowserContentParents;
maxContentParents = Preferences::GetInt("dom.ipc.processCount", 1);
}
@ -687,7 +604,7 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
uint32_t currIdx = startIdx;
do {
RefPtr<ContentParent> p = (*contentParents)[currIdx];
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sNonAppContntParents?");
NS_ASSERTION(p->IsAlive(), "Non-alive contentparent in sBrowserContntParents?");
if (p->mOpener == aOpener) {
return p.forget();
}
@ -695,24 +612,14 @@ ContentParent::GetNewOrUsedBrowserProcess(bool aForBrowserElement,
} while (currIdx != startIdx);
}
// Try to take and transform the preallocated process into browser.
RefPtr<ContentParent> p = PreallocatedProcessManager::Take();
if (p) {
p->TransformPreallocatedIntoBrowser(aOpener);
} else {
// Failed in using the preallocated process: fork from the chrome process.
p = new ContentParent(/* app = */ nullptr,
aOpener,
aForBrowserElement,
/* isForPreallocated = */ false);
RefPtr<ContentParent> p = new ContentParent(aOpener, aForBrowserElement);
if (!p->LaunchSubprocess(aPriority)) {
return nullptr;
}
p->Init();
if (!p->LaunchSubprocess(aPriority)) {
return nullptr;
}
p->Init();
p->mLargeAllocationProcess = aLargeAllocationProcess;
p->ForwardKnownInfo();
@ -767,18 +674,11 @@ ContentParent::SendAsyncUpdate(nsIWidget* aWidget)
}
#endif // defined(XP_WIN)
bool
ContentParent::PreallocatedProcessReady()
{
return true;
}
bool
ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
const hal::ProcessPriority& aPriority,
const TabId& aOpenerTabId,
ContentParentId* aCpId,
bool* aIsForApp,
bool* aIsForBrowser,
TabId* aTabId)
{
@ -796,24 +696,16 @@ ContentParent::RecvCreateChildProcess(const IPCTabContext& aContext,
return false;
}
nsCOMPtr<mozIApplication> ownApp = tc.GetTabContext().GetOwnApp();
if (ownApp) {
cp = GetNewOrPreallocatedAppProcess(ownApp, aPriority, this);
}
else {
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
aPriority, this);
}
cp = GetNewOrUsedBrowserProcess(/* isBrowserElement = */ true,
aPriority, this);
if (!cp) {
*aCpId = 0;
*aIsForApp = false;
*aIsForBrowser = false;
return true;
}
*aCpId = cp->ChildID();
*aIsForApp = cp->IsForApp();
*aIsForBrowser = cp->IsForBrowser();
ContentProcessManager *cpm = ContentProcessManager::GetSingleton();
@ -944,10 +836,10 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
}
/*static*/ TabParent*
ContentParent::CreateBrowserOrApp(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess)
ContentParent::CreateBrowser(const TabContext& aContext,
Element* aFrameElement,
ContentParent* aOpenerContentParent,
bool aFreshProcess)
{
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
@ -970,222 +862,74 @@ ContentParent::CreateBrowserOrApp(const TabContext& aContext,
openerTabId = TabParent::GetTabIdFrom(docShell);
}
if (aContext.IsMozBrowserElement() || !aContext.HasOwnApp()) {
RefPtr<nsIContentParent> constructorSender;
if (isInContentProcess) {
MOZ_ASSERT(aContext.IsMozBrowserElement());
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
openerTabId, &tabId);
} else {
if (aOpenerContentParent) {
constructorSender = aOpenerContentParent;
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
initialPriority,
nullptr,
aFreshProcess);
if (!constructorSender) {
return nullptr;
}
}
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
}
if (constructorSender) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner) {
return nullptr;
}
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
if (!wbc) {
return nullptr;
}
uint32_t chromeFlags = 0;
wbc->GetChromeFlags(&chromeFlags);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
if (docShell->GetAffectPrivateSessionLifetime()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
if (tabId == 0) {
return nullptr;
}
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
aContext, chromeFlags));
tp->SetInitedByParent();
PBrowserParent* browser =
constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
tp.forget().take(), tabId,
aContext.AsIPCTabContext(),
chromeFlags,
constructorSender->ChildID(),
constructorSender->IsForApp(),
constructorSender->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
return constructedTabParent;
}
}
return nullptr;
}
// If we got here, we have an app and we're not a browser element. ownApp
// shouldn't be null, because we otherwise would have gone into the
// !HasOwnApp() branch above.
RefPtr<nsIContentParent> parent;
bool reused = false;
bool tookPreallocated = false;
nsAutoString manifestURL;
RefPtr<nsIContentParent> constructorSender;
if (isInContentProcess) {
parent = CreateContentBridgeParent(aContext,
initialPriority,
openerTabId,
&tabId);
}
else {
nsCOMPtr<mozIApplication> ownApp = aContext.GetOwnApp();
if (!sAppContentParents) {
sAppContentParents =
new nsDataHashtable<nsStringHashKey, ContentParent*>();
MOZ_ASSERT(aContext.IsMozBrowserElement());
constructorSender = CreateContentBridgeParent(aContext, initialPriority,
openerTabId, &tabId);
} else {
constructorSender =
GetNewOrUsedBrowserProcess(aContext.IsMozBrowserElement(),
initialPriority, nullptr, aFreshProcess);
if (!constructorSender) {
return nullptr;
}
tabId = AllocateTabId(openerTabId,
aContext.AsIPCTabContext(),
constructorSender->ChildID());
}
// Each app gets its own ContentParent instance unless it shares it with
// a parent app.
if (NS_FAILED(ownApp->GetManifestURL(manifestURL))) {
NS_ERROR("Failed to get manifest URL");
if (constructorSender) {
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
if (!treeOwner) {
return nullptr;
}
RefPtr<ContentParent> p = sAppContentParents->Get(manifestURL);
if (!p && Preferences::GetBool("dom.ipc.reuse_parent_app")) {
nsAutoString parentAppManifestURL;
aFrameElement->GetAttr(kNameSpaceID_None,
nsGkAtoms::parentapp, parentAppManifestURL);
nsAdoptingString systemAppManifestURL =
Preferences::GetString("b2g.system_manifest_url");
nsCOMPtr<nsIAppsService> appsService =
do_GetService(APPS_SERVICE_CONTRACTID);
if (!parentAppManifestURL.IsEmpty() &&
!parentAppManifestURL.Equals(systemAppManifestURL) &&
appsService) {
nsCOMPtr<mozIApplication> parentApp;
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(parentAppManifestURL,
getter_AddRefs(parentApp));
appsService->GetAppByManifestURL(manifestURL,
getter_AddRefs(app));
// Only let certified apps re-use the same process.
unsigned short parentAppStatus = 0;
unsigned short appStatus = 0;
if (app &&
NS_SUCCEEDED(app->GetAppStatus(&appStatus)) &&
appStatus == nsIPrincipal::APP_STATUS_CERTIFIED &&
parentApp &&
NS_SUCCEEDED(parentApp->GetAppStatus(&parentAppStatus)) &&
parentAppStatus == nsIPrincipal::APP_STATUS_CERTIFIED) {
// Check if we can re-use the process of the parent app.
p = sAppContentParents->Get(parentAppManifestURL);
}
}
nsCOMPtr<nsIWebBrowserChrome> wbc = do_GetInterface(treeOwner);
if (!wbc) {
return nullptr;
}
if (p) {
// Check that the process is still alive and set its priority.
// Hopefully the process won't die after this point, if this call
// succeeds.
if (!p->SetPriorityAndCheckIsAlive(initialPriority)) {
p = nullptr;
}
uint32_t chromeFlags = 0;
wbc->GetChromeFlags(&chromeFlags);
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(docShell);
if (loadContext && loadContext->UsePrivateBrowsing()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_WINDOW;
}
reused = !!p;
if (!p) {
p = GetNewOrPreallocatedAppProcess(ownApp, initialPriority, nullptr,
&tookPreallocated);
MOZ_ASSERT(p);
sAppContentParents->Put(manifestURL, p);
}
tabId = AllocateTabId(openerTabId, aContext.AsIPCTabContext(),
p->ChildID());
parent = static_cast<nsIContentParent*>(p);
}
if (!parent || (tabId == 0)) {
return nullptr;
}
uint32_t chromeFlags = 0;
RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
tp->SetInitedByParent();
PBrowserParent* browser = parent->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
RefPtr<TabParent>(tp).forget().take(),
tabId,
aContext.AsIPCTabContext(),
chromeFlags,
parent->ChildID(),
parent->IsForApp(),
parent->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
}
if (isInContentProcess) {
// Just return directly without the following check in content process.
return TabParent::GetFrom(browser);
}
if (!browser) {
// We failed to actually start the PBrowser. This can happen if the
// other process has already died.
if (!reused) {
// Don't leave a broken ContentParent in the hashtable.
parent->AsContentParent()->KillHard("CreateBrowserOrApp");
sAppContentParents->Remove(manifestURL);
parent = nullptr;
if (docShell->GetAffectPrivateSessionLifetime()) {
chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
}
// If we took the preallocated process and it was already dead, try
// again with a non-preallocated process. We can be sure this won't
// loop forever, because the next time through there will be no
// preallocated process to take.
if (tookPreallocated) {
return ContentParent::CreateBrowserOrApp(aContext, aFrameElement,
aOpenerContentParent);
if (tabId == 0) {
return nullptr;
}
RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
aContext, chromeFlags));
tp->SetInitedByParent();
PBrowserParent* browser =
constructorSender->SendPBrowserConstructor(
// DeallocPBrowserParent() releases this ref.
tp.forget().take(), tabId,
aContext.AsIPCTabContext(),
chromeFlags,
constructorSender->ChildID(),
constructorSender->IsForBrowser());
if (aFreshProcess) {
Unused << browser->SendSetFreshProcess();
}
// Otherwise just give up.
return nullptr;
if (browser) {
RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
constructedTabParent->SetOwnerElement(aFrameElement);
return constructedTabParent;
}
}
return TabParent::GetFrom(browser);
return nullptr;
}
/*static*/ ContentBridgeParent*
@ -1198,13 +942,11 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
ContentChild* child = ContentChild::GetSingleton();
ContentParentId cpId;
bool isForApp;
bool isForBrowser;
if (!child->SendCreateChildProcess(aContext.AsIPCTabContext(),
aPriority,
aOpenerTabId,
&cpId,
&isForApp,
&isForBrowser,
aTabId)) {
return nullptr;
@ -1217,7 +959,6 @@ ContentParent::CreateContentBridgeParent(const TabContext& aContext,
}
ContentBridgeParent* parent = child->GetLastBridge();
parent->SetChildID(cpId);
parent->SetIsForApp(isForApp);
parent->SetIsForBrowser(isForBrowser);
return parent;
}
@ -1336,51 +1077,6 @@ ContentParent::SetPriorityAndCheckIsAlive(ProcessPriority aPriority)
return true;
}
// Helper for ContentParent::TransformPreallocatedIntoApp.
static void
TryGetNameFromManifestURL(const nsAString& aManifestURL,
nsAString& aName)
{
aName.Truncate();
if (aManifestURL.IsEmpty() ||
aManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL) {
return;
}
nsCOMPtr<nsIAppsService> appsService = do_GetService(APPS_SERVICE_CONTRACTID);
NS_ENSURE_TRUE_VOID(appsService);
nsCOMPtr<mozIApplication> app;
appsService->GetAppByManifestURL(aManifestURL, getter_AddRefs(app));
if (!app) {
return;
}
app->GetName(aName);
}
void
ContentParent::TransformPreallocatedIntoApp(ContentParent* aOpener,
const nsAString& aAppManifestURL)
{
MOZ_ASSERT(IsPreallocated());
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL = aAppManifestURL;
TryGetNameFromManifestURL(aAppManifestURL, mAppName);
}
void
ContentParent::TransformPreallocatedIntoBrowser(ContentParent* aOpener)
{
// Reset mAppManifestURL, mIsForBrowser and mOSPrivileges for browser.
mMetamorphosed = true;
mOpener = aOpener;
mAppManifestURL.Truncate();
mIsForBrowser = true;
}
void
ContentParent::ShutDownProcess(ShutDownMethod aMethod)
{
@ -1464,29 +1160,19 @@ ContentParent::ShutDownMessageManager()
void
ContentParent::MarkAsDead()
{
if (!mAppManifestURL.IsEmpty()) {
if (sAppContentParents) {
sAppContentParents->Remove(mAppManifestURL);
if (!sAppContentParents->Count()) {
delete sAppContentParents;
sAppContentParents = nullptr;
}
}
} else {
if (sNonAppContentParents) {
sNonAppContentParents->RemoveElement(this);
if (!sNonAppContentParents->Length()) {
delete sNonAppContentParents;
sNonAppContentParents = nullptr;
}
if (sBrowserContentParents) {
sBrowserContentParents->RemoveElement(this);
if (!sBrowserContentParents->Length()) {
delete sBrowserContentParents;
sBrowserContentParents = nullptr;
}
}
if (sLargeAllocationContentParents) {
sLargeAllocationContentParents->RemoveElement(this);
if (!sLargeAllocationContentParents->Length()) {
delete sLargeAllocationContentParents;
sLargeAllocationContentParents = nullptr;
}
if (sLargeAllocationContentParents) {
sLargeAllocationContentParents->RemoveElement(this);
if (!sLargeAllocationContentParents->Length()) {
delete sLargeAllocationContentParents;
sLargeAllocationContentParents = nullptr;
}
}
@ -1789,7 +1475,7 @@ ContentParent::NotifyTabDestroying(const TabId& aTabId,
return;
}
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
if (!cp->mLargeAllocationProcess && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive) {
return;
@ -1846,7 +1532,7 @@ ContentParent::NotifyTabDestroyed(const TabId& aTabId,
// We might want to keep alive some content processes for testing, because of performance
// reasons, but we don't want to alter behavior if the pref is not set.
uint32_t numberOfParents = sNonAppContentParents ? sNonAppContentParents->Length() : 0;
uint32_t numberOfParents = sBrowserContentParents ? sBrowserContentParents->Length() : 0;
int32_t processesToKeepAlive = Preferences::GetInt("dom.ipc.keepProcessesAlive", 0);
bool shouldKeepAliveAny = !mLargeAllocationProcess && processesToKeepAlive > 0;
bool shouldKeepAliveThis = shouldKeepAliveAny && static_cast<int32_t>(numberOfParents) <= processesToKeepAlive;
@ -1940,10 +1626,8 @@ ContentParent::LaunchSubprocess(ProcessPriority aInitialPriority /* = PROCESS_PR
return true;
}
ContentParent::ContentParent(mozIApplication* aApp,
ContentParent* aOpener,
bool aIsForBrowser,
bool aIsForPreallocated)
ContentParent::ContentParent(ContentParent* aOpener,
bool aIsForBrowser)
: nsIContentParent()
, mOpener(aOpener)
, mIsForBrowser(aIsForBrowser)
@ -1951,10 +1635,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
{
InitializeMembers(); // Perform common initialization.
// No more than one of !!aApp, aIsForBrowser, aIsForPreallocated should be
// true.
MOZ_ASSERT(!!aApp + aIsForBrowser + aIsForPreallocated <= 1);
mMetamorphosed = true;
// Insert ourselves into the global linked list of ContentParent objects.
@ -1963,13 +1643,6 @@ ContentParent::ContentParent(mozIApplication* aApp,
}
sContentParents->insertBack(this);
if (aApp) {
aApp->GetManifestURL(mAppManifestURL);
aApp->GetName(mAppName);
} else if (aIsForPreallocated) {
mAppManifestURL = MAGIC_PREALLOCATED_APP_MANIFEST_URL;
}
// From this point on, NS_WARNING, NS_ASSERTION, etc. should print out the
// PID along with the warning.
nsDebugImpl::SetMultiprocessMode("Parent");
@ -1996,19 +1669,10 @@ ContentParent::~ContentParent()
// We should be removed from all these lists in ActorDestroy.
MOZ_ASSERT(!sPrivateContent || !sPrivateContent->Contains(this));
if (mAppManifestURL.IsEmpty()) {
MOZ_ASSERT((!sNonAppContentParents ||
!sNonAppContentParents->Contains(this)) &&
(!sLargeAllocationContentParents ||
!sLargeAllocationContentParents->Contains(this)));
} else {
// In general, we expect sAppContentParents->Get(mAppManifestURL) to be
// nullptr. But it could be that we created another ContentParent for
// this app after we did this->ActorDestroy(), so the right check is
// that sAppContentParents->Get(mAppManifestURL) != this.
MOZ_ASSERT(!sAppContentParents ||
sAppContentParents->Get(mAppManifestURL) != this);
}
MOZ_ASSERT((!sBrowserContentParents ||
!sBrowserContentParents->Contains(this)) &&
(!sLargeAllocationContentParents ||
!sLargeAllocationContentParents->Contains(this)));
}
void
@ -2080,11 +1744,6 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority,
}
}
if (gAppData) {
// Sending all information to content process.
Unused << SendAppInit();
}
nsStyleSheetService *sheetService = nsStyleSheetService::GetInstance();
if (sheetService) {
// This looks like a lot of work, but in a normal browser session we just
@ -2144,12 +1803,6 @@ ContentParent::IsAlive() const
return mIsAlive;
}
bool
ContentParent::IsForApp() const
{
return !mAppManifestURL.IsEmpty();
}
int32_t
ContentParent::Pid() const
{
@ -2390,17 +2043,6 @@ ContentParent::RecvGetShowPasswordSetting(bool* showPassword)
return true;
}
bool
ContentParent::RecvFirstIdle()
{
// When the ContentChild goes idle, it sends us a FirstIdle message
// which we use as a good time to prelaunch another process. If we
// prelaunch any sooner than this, then we'll be competing with the
// child process and slowing it down.
PreallocatedProcessManager::AllocateAfterDelay();
return true;
}
bool
ContentParent::RecvAudioChannelChangeDefVolChannel(const int32_t& aChannel,
const bool& aHidden)
@ -2575,10 +2217,9 @@ ContentParent::AllocPProcessHangMonitorParent(Transport* aTransport,
bool
ContentParent::RecvGetProcessAttributes(ContentParentId* aCpId,
bool* aIsForApp, bool* aIsForBrowser)
bool* aIsForBrowser)
{
*aCpId = mChildID;
*aIsForApp = IsForApp();
*aIsForBrowser = mIsForBrowser;
return true;
@ -2687,14 +2328,12 @@ ContentParent::AllocPBrowserParent(const TabId& aTabId,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return nsIContentParent::AllocPBrowserParent(aTabId,
aContext,
aChromeFlags,
aCpId,
aIsForApp,
aIsForBrowser);
}
@ -2792,27 +2431,14 @@ ContentParent::KillHard(const char* aReason)
otherProcessHandle, /*force=*/true));
}
bool
ContentParent::IsPreallocated() const
{
return mAppManifestURL == MAGIC_PREALLOCATED_APP_MANIFEST_URL;
}
void
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
{
aName.Truncate();
if (IsPreallocated()) {
aName.AssignLiteral("(Preallocated)");
} else if (mIsForBrowser) {
if (mIsForBrowser) {
aName.AssignLiteral("Browser");
} else if (aAnonymize) {
aName.AssignLiteral("<anonymized-name>");
} else if (!mAppName.IsEmpty()) {
aName = mAppName;
} else if (!mAppManifestURL.IsEmpty()) {
aName.AssignLiteral("Unknown app: ");
aName.Append(mAppManifestURL);
} else {
aName.AssignLiteral("???");
}
@ -3649,7 +3275,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
const IPCTabContext& aContext,
const uint32_t& aChromeFlags,
const ContentParentId& aCpId,
const bool& aIsForApp,
const bool& aIsForBrowser)
{
return PContentParent::SendPBrowserConstructor(aActor,
@ -3657,7 +3282,6 @@ ContentParent::SendPBrowserConstructor(PBrowserParent* aActor,
aContext,
aChromeFlags,
aCpId,
aIsForApp,
aIsForBrowser);
}
@ -3775,12 +3399,9 @@ ContentParent::RecvRecordingDeviceEvents(const nsString& aRecordingStatus,
// recording-device-ipc-events needs to gather more information from content process
RefPtr<nsHashPropertyBag> props = new nsHashPropertyBag();
props->SetPropertyAsUint64(NS_LITERAL_STRING("childID"), ChildID());
props->SetPropertyAsBool(NS_LITERAL_STRING("isApp"), IsForApp());
props->SetPropertyAsBool(NS_LITERAL_STRING("isAudio"), aIsAudio);
props->SetPropertyAsBool(NS_LITERAL_STRING("isVideo"), aIsVideo);
nsString requestURL = IsForApp() ? AppManifestURL() : aPageURL;
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), requestURL);
props->SetPropertyAsAString(NS_LITERAL_STRING("requestURL"), aPageURL);
obs->NotifyObservers((nsIPropertyBag2*) props,
"recording-device-ipc-events",
@ -4235,7 +3856,7 @@ ContentParent::RecvCreateWindow(PBrowserParent* aThisTab,
thisTabParent = TabParent::GetFrom(aThisTab);
}
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowserOrApp())) {
if (NS_WARN_IF(thisTabParent && thisTabParent->IsMozBrowser())) {
return false;
}