Bug 1566643 - Part 5: Remove CPM::GetBrowserParentsByProcessId, r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D39261

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nika Layzell 2019-08-08 16:07:34 +00:00
parent 18bb5b9f08
commit 17c3e69cbb
3 changed files with 5 additions and 35 deletions

View File

@ -757,14 +757,12 @@ void ContentParent::ReleaseCachedProcesses() {
// 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->GetBrowserParentsByProcessId(cp->mChildID);
if (!tabIds.Length()) {
if (cp->ManagedPBrowserParent().Count() == 0) {
toRelease.AppendElement(cp);
}
}
@ -1787,8 +1785,8 @@ void ContentParent::NotifyTabDestroying(const TabId& aTabId,
return;
}
++cp->mNumDestroyingTabs;
nsTArray<TabId> tabIds = cpm->GetBrowserParentsByProcessId(aCpId);
if (static_cast<size_t>(cp->mNumDestroyingTabs) != tabIds.Length()) {
uint32_t tabCount = cpm->GetBrowserParentCountByProcessId(aCpId);
if (uint32_t(cp->mNumDestroyingTabs) != tabCount) {
return;
}
@ -1843,10 +1841,8 @@ void ContentParent::NotifyTabDestroyed(const TabId& aTabId,
// There can be more than one PBrowser for a given app process
// because of popup windows. When the last one closes, shut
// us down.
ContentProcessManager* cpm = ContentProcessManager::GetSingleton();
nsTArray<TabId> tabIds = cpm->GetBrowserParentsByProcessId(this->ChildID());
if (tabIds.Length() == 1 && !ShouldKeepProcessAlive() && !TryToRecycle()) {
if (ManagedPBrowserParent().Count() == 1 && !ShouldKeepProcessAlive() &&
!TryToRecycle()) {
// In the case of normal shutdown, send a shutdown message to child to
// allow it to perform shutdown tasks.
MessageLoop::current()->PostTask(NewRunnableMethod<ShutDownMethod>(

View File

@ -94,25 +94,6 @@ ContentParentId ContentProcessManager::GetTabProcessId(
return ContentParentId(0);
}
nsTArray<TabId> ContentProcessManager::GetBrowserParentsByProcessId(
const ContentParentId& aChildCpId) {
MOZ_ASSERT(NS_IsMainThread());
nsTArray<TabId> tabIdList;
ContentParent* contentParent = mContentParentMap.Get(aChildCpId);
if (!contentParent) {
ASSERT_UNLESS_FUZZING();
return tabIdList;
}
const auto& browsers = contentParent->ManagedPBrowserParent();
for (auto iter = browsers.ConstIter(); !iter.Done(); iter.Next()) {
BrowserParent* tab = BrowserParent::GetFrom(iter.Get()->GetKey());
tabIdList.AppendElement(tab->GetTabId());
}
return tabIdList;
}
uint32_t ContentProcessManager::GetBrowserParentCountByProcessId(
const ContentParentId& aChildCpId) {
MOZ_ASSERT(NS_IsMainThread());

View File

@ -52,13 +52,6 @@ class ContentProcessManager final {
*/
ContentParentId GetTabProcessId(const TabId& aChildTabId);
/**
* Get all BrowserParents' Ids managed by the givent content process.
* Return empty array when ContentParent couldn't be found via aChildCpId.
*/
nsTArray<TabId> GetBrowserParentsByProcessId(
const ContentParentId& aChildCpId);
/**
* Get the number of BrowserParents managed by the givent content process.
* Return 0 when ContentParent couldn't be found via aChildCpId.