mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1338241 - Part 1: Use remoteType to propagate Large-Allocation status, r=mikedeboer
MozReview-Commit-ID: LfavqjMcZUq
This commit is contained in:
parent
bb033696f7
commit
3f762bbaf0
@ -1704,9 +1704,8 @@
|
||||
|
||||
// Abort if we're not going to change anything
|
||||
let currentRemoteType = aBrowser.getAttribute("remoteType");
|
||||
if (isRemote == aShouldBeRemote && !aOptions.newFrameloader && !aOptions.freshProcess &&
|
||||
(!isRemote || currentRemoteType == aOptions.remoteType) &&
|
||||
!aBrowser.frameLoader.isFreshProcess) {
|
||||
if (isRemote == aShouldBeRemote && !aOptions.newFrameloader &&
|
||||
(!isRemote || currentRemoteType == aOptions.remoteType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1765,18 +1764,8 @@
|
||||
aBrowser.presetOpenerWindow(aOptions.opener);
|
||||
}
|
||||
|
||||
// Set the freshProcess attribute so that the frameloader knows to
|
||||
// create a new process
|
||||
if (aOptions.freshProcess) {
|
||||
aBrowser.setAttribute("freshProcess", "true");
|
||||
}
|
||||
|
||||
parent.appendChild(aBrowser);
|
||||
|
||||
// Remove the freshProcess attribute if we set it, as we don't
|
||||
// want it to apply for the next time the frameloader is created
|
||||
aBrowser.removeAttribute("freshProcess");
|
||||
|
||||
aBrowser.userTypedValue = oldUserTypedValue;
|
||||
if (hadStartedLoad) {
|
||||
aBrowser.urlbarChangeTracker.startedLoad();
|
||||
@ -1850,15 +1839,23 @@
|
||||
if (!gMultiProcessBrowser)
|
||||
return this.updateBrowserRemoteness(aBrowser, false);
|
||||
|
||||
// If we're in a LargeAllocation process, we prefer switching back
|
||||
// into a normal content process, as that way we can clean up the
|
||||
// L-A process.
|
||||
let preferredRemoteType = aBrowser.remoteType;
|
||||
if (aBrowser.remoteType == E10SUtils.LARGE_ALLOCATION_REMOTE_TYPE) {
|
||||
preferredRemoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
|
||||
}
|
||||
aOptions.remoteType =
|
||||
E10SUtils.getRemoteTypeForURI(aURL,
|
||||
gMultiProcessBrowser,
|
||||
preferredRemoteType,
|
||||
aOptions.freshProcess);
|
||||
|
||||
// If this URL can't load in the current browser then flip it to the
|
||||
// correct type.
|
||||
let currentRemoteType = aBrowser.remoteType;
|
||||
aOptions.remoteType =
|
||||
E10SUtils.getRemoteTypeForURI(aURL, gMultiProcessBrowser,
|
||||
currentRemoteType);
|
||||
if (currentRemoteType != aOptions.remoteType ||
|
||||
aOptions.freshProcess || aOptions.newFrameloader ||
|
||||
aBrowser.frameLoader.isFreshProcess) {
|
||||
if (aBrowser.remoteType != aOptions.remoteType ||
|
||||
aOptions.newFrameloader) {
|
||||
let remote = aOptions.remoteType != E10SUtils.NOT_REMOTE;
|
||||
return this.updateBrowserRemoteness(aBrowser, remote, aOptions);
|
||||
}
|
||||
|
@ -39,6 +39,9 @@ const NOT_REMOTE = null;
|
||||
const WEB_REMOTE_TYPE = "web";
|
||||
const FILE_REMOTE_TYPE = "file";
|
||||
const EXTENSION_REMOTE_TYPE = "extension";
|
||||
|
||||
// This must start with the WEB_REMOTE_TYPE above.
|
||||
const LARGE_ALLOCATION_REMOTE_TYPE = "webLargeAllocation";
|
||||
const DEFAULT_REMOTE_TYPE = WEB_REMOTE_TYPE;
|
||||
|
||||
function validatedWebRemoteType(aPreferredRemoteType) {
|
||||
@ -52,6 +55,7 @@ this.E10SUtils = {
|
||||
WEB_REMOTE_TYPE,
|
||||
FILE_REMOTE_TYPE,
|
||||
EXTENSION_REMOTE_TYPE,
|
||||
LARGE_ALLOCATION_REMOTE_TYPE,
|
||||
|
||||
canLoadURIInProcess(aURL, aProcess) {
|
||||
let remoteType = aProcess == Ci.nsIXULRuntime.PROCESS_TYPE_CONTENT
|
||||
@ -60,11 +64,16 @@ this.E10SUtils = {
|
||||
},
|
||||
|
||||
getRemoteTypeForURI(aURL, aMultiProcess,
|
||||
aPreferredRemoteType = DEFAULT_REMOTE_TYPE) {
|
||||
aPreferredRemoteType = DEFAULT_REMOTE_TYPE,
|
||||
aLargeAllocation = false) {
|
||||
if (!aMultiProcess) {
|
||||
return NOT_REMOTE;
|
||||
}
|
||||
|
||||
if (aLargeAllocation) {
|
||||
return LARGE_ALLOCATION_REMOTE_TYPE;
|
||||
}
|
||||
|
||||
// loadURI in browser.xml treats null as about:blank
|
||||
if (!aURL) {
|
||||
aURL = "about:blank";
|
||||
|
@ -174,17 +174,10 @@ nsFrameLoader::nsFrameLoader(Element* aOwner, nsPIDOMWindowOuter* aOpener, bool
|
||||
, mClampScrollPosition(true)
|
||||
, mObservingOwnerContent(false)
|
||||
, mVisible(true)
|
||||
, mFreshProcess(false)
|
||||
{
|
||||
mRemoteFrame = ShouldUseRemoteProcess();
|
||||
MOZ_ASSERT(!mRemoteFrame || !aOpener,
|
||||
"Cannot pass aOpener for a remote frame!");
|
||||
|
||||
// Check if we are supposed to load into a fresh process
|
||||
mFreshProcess = mOwnerContent->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::freshProcess,
|
||||
nsGkAtoms::_true,
|
||||
eCaseMatters);
|
||||
}
|
||||
|
||||
nsFrameLoader::~nsFrameLoader()
|
||||
@ -2938,8 +2931,7 @@ nsFrameLoader::TryRemoteBrowser()
|
||||
NS_ENSURE_SUCCESS(rv, false);
|
||||
|
||||
nsCOMPtr<Element> ownerElement = mOwnerContent;
|
||||
mRemoteBrowser = ContentParent::CreateBrowser(context, ownerElement, openerContentParent,
|
||||
mFreshProcess);
|
||||
mRemoteBrowser = ContentParent::CreateBrowser(context, ownerElement, openerContentParent);
|
||||
if (!mRemoteBrowser) {
|
||||
return false;
|
||||
}
|
||||
@ -3676,13 +3668,6 @@ nsFrameLoader::GetIsDead(bool* aIsDead)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameLoader::GetIsFreshProcess(bool* aIsFreshProcess)
|
||||
{
|
||||
*aIsFreshProcess = mFreshProcess;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIMessageSender*
|
||||
nsFrameLoader::GetProcessMessageManager() const
|
||||
{
|
||||
|
@ -268,12 +268,6 @@ interface nsIFrameLoader : nsISupports
|
||||
* Is `true` if the frameloader is dead (destroy has been called on it)
|
||||
*/
|
||||
[infallible] readonly attribute boolean isDead;
|
||||
|
||||
/**
|
||||
* Is `true` if the <xul:browser> which created this frameloader had the
|
||||
* freshProcess attribute set when it was created.
|
||||
*/
|
||||
[infallible] readonly attribute boolean isFreshProcess;
|
||||
};
|
||||
|
||||
%{C++
|
||||
|
@ -673,21 +673,15 @@ ContentParent::RandomSelect(const nsTArray<ContentParent*>& aContentParents,
|
||||
ContentParent::GetNewOrUsedBrowserProcess(const nsAString& aRemoteType,
|
||||
ProcessPriority aPriority,
|
||||
ContentParent* aOpener,
|
||||
bool aLargeAllocationProcess,
|
||||
bool* aNew)
|
||||
{
|
||||
if (aNew) {
|
||||
*aNew = false;
|
||||
}
|
||||
// Decide which pool of content parents we are going to be pulling from based
|
||||
// on the aRemoteType and aLargeAllocationProcess flag.
|
||||
nsAutoString contentProcessType(aLargeAllocationProcess
|
||||
? NS_LITERAL_STRING(LARGE_ALLOCATION_REMOTE_TYPE)
|
||||
: aRemoteType);
|
||||
|
||||
nsTArray<ContentParent*>& contentParents = GetOrCreatePool(contentProcessType);
|
||||
nsTArray<ContentParent*>& contentParents = GetOrCreatePool(aRemoteType);
|
||||
|
||||
uint32_t maxContentParents = GetMaxProcessCount(contentProcessType);
|
||||
uint32_t maxContentParents = GetMaxProcessCount(aRemoteType);
|
||||
|
||||
RefPtr<ContentParent> p;
|
||||
if (contentParents.Length() >= uint32_t(maxContentParents) &&
|
||||
@ -696,12 +690,12 @@ ContentParent::GetNewOrUsedBrowserProcess(const nsAString& aRemoteType,
|
||||
}
|
||||
|
||||
// Try to take the preallocated process only for the default process type.
|
||||
if (contentProcessType.Equals(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)) &&
|
||||
if (aRemoteType.Equals(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE)) &&
|
||||
(p = PreallocatedProcessManager::Take())) {
|
||||
// For pre-allocated process we have not set the opener yet.
|
||||
p->mOpener = aOpener;
|
||||
} else {
|
||||
p = new ContentParent(aOpener, contentProcessType);
|
||||
p = new ContentParent(aOpener, aRemoteType);
|
||||
|
||||
if (aNew) {
|
||||
*aNew = true;
|
||||
@ -981,8 +975,7 @@ ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
|
||||
/*static*/ TabParent*
|
||||
ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess)
|
||||
ContentParent* aOpenerContentParent)
|
||||
{
|
||||
PROFILER_LABEL_FUNC(js::ProfileEntry::Category::OTHER);
|
||||
|
||||
@ -1005,6 +998,12 @@ ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
openerTabId = TabParent::GetTabIdFrom(docShell);
|
||||
}
|
||||
|
||||
nsAutoString remoteType;
|
||||
if (!aFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType,
|
||||
remoteType)) {
|
||||
remoteType.AssignLiteral(DEFAULT_REMOTE_TYPE);
|
||||
}
|
||||
|
||||
bool newProcess = false;
|
||||
RefPtr<nsIContentParent> constructorSender;
|
||||
if (isInContentProcess) {
|
||||
@ -1015,15 +1014,9 @@ ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
if (aOpenerContentParent) {
|
||||
constructorSender = aOpenerContentParent;
|
||||
} else {
|
||||
nsAutoString remoteType;
|
||||
if (!aFrameElement->GetAttr(kNameSpaceID_None, nsGkAtoms::RemoteType,
|
||||
remoteType)) {
|
||||
remoteType.AssignLiteral(DEFAULT_REMOTE_TYPE);
|
||||
}
|
||||
|
||||
constructorSender =
|
||||
GetNewOrUsedBrowserProcess(remoteType, initialPriority, nullptr,
|
||||
aFreshProcess, &newProcess);
|
||||
&newProcess);
|
||||
if (!constructorSender) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1070,7 +1063,7 @@ ContentParent::CreateBrowser(const TabContext& aContext,
|
||||
constructorSender->ChildID(),
|
||||
constructorSender->IsForBrowser());
|
||||
|
||||
if (aFreshProcess) {
|
||||
if (remoteType.EqualsLiteral(LARGE_ALLOCATION_REMOTE_TYPE)) {
|
||||
// Tell the TabChild object that it was created due to a Large-Allocation
|
||||
// request, and whether or not that Large-Allocation request succeeded at
|
||||
// creating a new content process.
|
||||
|
@ -174,7 +174,6 @@ public:
|
||||
hal::ProcessPriority aPriority =
|
||||
hal::ProcessPriority::PROCESS_PRIORITY_FOREGROUND,
|
||||
ContentParent* aOpener = nullptr,
|
||||
bool aLargeAllocationProcess = false,
|
||||
bool* anew = nullptr);
|
||||
|
||||
/**
|
||||
@ -185,8 +184,7 @@ public:
|
||||
static TabParent*
|
||||
CreateBrowser(const TabContext& aContext,
|
||||
Element* aFrameElement,
|
||||
ContentParent* aOpenerContentParent,
|
||||
bool aFreshProcess = false);
|
||||
ContentParent* aOpenerContentParent);
|
||||
|
||||
static void GetAll(nsTArray<ContentParent*>& aArray);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user