зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1337730 - part1: releaseCachedProcesses API for testing. r=mrbkap
This commit is contained in:
Родитель
a498797697
Коммит
770c47f73c
|
@ -35,7 +35,7 @@
|
|||
#include "mozilla/Telemetry.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
#include "mozilla/dom/MessagePort.h"
|
||||
#include "mozilla/dom/nsIContentParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/PermissionMessageUtils.h"
|
||||
#include "mozilla/dom/ProcessGlobal.h"
|
||||
#include "mozilla/dom/SameProcessMessageQueue.h"
|
||||
|
@ -778,6 +778,12 @@ nsFrameMessageManager::GetChildAt(uint32_t aIndex,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameMessageManager::ReleaseCachedProcesses()
|
||||
{
|
||||
ContentParent::ReleaseCachedProcesses();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIContentFrameMessageManager
|
||||
|
||||
|
|
|
@ -327,6 +327,12 @@ interface nsIMessageBroadcaster : nsIMessageListenerManager
|
|||
* Return a single subordinate message manager.
|
||||
*/
|
||||
nsIMessageListenerManager getChildAt(in unsigned long aIndex);
|
||||
|
||||
/**
|
||||
* Some processes are kept alive after their last tab/window are closed for testing
|
||||
* (see dom.ipc.keepProcessesAlive). This function releases those.
|
||||
*/
|
||||
void releaseCachedProcesses();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(0e602c9e-1977-422a-a8e4-fe0d4a4f78d0)]
|
||||
|
|
|
@ -650,6 +650,32 @@ ContentParent::IsMaxProcessCountReached(const nsAString& aContentProcessType)
|
|||
return GetPoolSize(aContentProcessType) >= GetMaxProcessCount(aContentProcessType);
|
||||
}
|
||||
|
||||
/*static*/ void
|
||||
ContentParent::ReleaseCachedProcesses()
|
||||
{
|
||||
// We might want to extend this for other process types as well in the future...
|
||||
nsTArray<ContentParent*>& contentParents = GetOrCreatePool(NS_LITERAL_STRING(DEFAULT_REMOTE_TYPE));
|
||||
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
|
||||
nsTArray<ContentParent*> toRelease;
|
||||
|
||||
// Shuting down these processes will change the array so let's use another array for the removal.
|
||||
for (auto* cp : contentParents) {
|
||||
nsTArray<TabId> tabIds = cpm->GetTabParentsByProcessId(cp->mChildID);
|
||||
if (!tabIds.Length()) {
|
||||
toRelease.AppendElement(cp);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto* cp : toRelease) {
|
||||
// Start a soft shutdown.
|
||||
cp->ShutDownProcess(SEND_SHUTDOWN_MESSAGE);
|
||||
// Make sure we don't select this process for new tabs.
|
||||
cp->MarkAsDead();
|
||||
// Make sure that this process is no longer accessible from JS by its message manager.
|
||||
cp->ShutDownMessageManager();
|
||||
}
|
||||
}
|
||||
|
||||
/*static*/ already_AddRefed<ContentParent>
|
||||
ContentParent::RandomSelect(const nsTArray<ContentParent*>& aContentParents,
|
||||
ContentParent* aOpener, int32_t aMaxContentParents)
|
||||
|
|
|
@ -153,6 +153,8 @@ public:
|
|||
|
||||
static bool IsMaxProcessCountReached(const nsAString& aContentProcessType);
|
||||
|
||||
static void ReleaseCachedProcesses();
|
||||
|
||||
/**
|
||||
* Picks a random content parent from |aContentParents| with a given |aOpener|
|
||||
* respecting the index limit set by |aMaxContentParents|.
|
||||
|
|
Загрузка…
Ссылка в новой задаче