Bug 1702795, part 2 - Be lazier about creating a ParticularProcessPriorityManager. r=gsvelto

The only reason to immediate create a ParticularProcessPriorityManager
when a ContentParent is created is to ensure that the test only
observer notification for process-created is accurate, but no test
actually listens for it, so we can delete the test notification
and then stop observing ipc:content-created.

Differential Revision: https://phabricator.services.mozilla.com/D110708
This commit is contained in:
Andrew McCreight 2021-04-05 20:17:58 +00:00
Родитель 963e338e74
Коммит 68c232e988
1 изменённых файлов: 1 добавлений и 16 удалений

Просмотреть файл

@ -163,7 +163,6 @@ class ProcessPriorityManagerImpl final : public nsIObserver,
already_AddRefed<ParticularProcessPriorityManager>
GetParticularProcessPriorityManager(ContentParent* aContentParent);
void ObserveContentParentCreated(nsISupports* aContentParent);
void ObserveContentParentDestroyed(nsISupports* aSubject);
nsTHashMap<uint64_t, RefPtr<ParticularProcessPriorityManager> >
@ -382,7 +381,6 @@ void ProcessPriorityManagerImpl::Init() {
nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) {
os->AddObserver(this, "ipc:content-created", /* ownsWeak */ true);
os->AddObserver(this, "ipc:content-shutdown", /* ownsWeak */ true);
}
}
@ -391,9 +389,7 @@ NS_IMETHODIMP
ProcessPriorityManagerImpl::Observe(nsISupports* aSubject, const char* aTopic,
const char16_t* aData) {
nsDependentCString topic(aTopic);
if (topic.EqualsLiteral("ipc:content-created")) {
ObserveContentParentCreated(aSubject);
} else if (topic.EqualsLiteral("ipc:content-shutdown")) {
if (topic.EqualsLiteral("ipc:content-shutdown")) {
ObserveContentParentDestroyed(aSubject);
} else {
MOZ_ASSERT(false);
@ -410,8 +406,6 @@ ProcessPriorityManagerImpl::GetParticularProcessPriorityManager(
if (!entry) {
entry.Insert(new ParticularProcessPriorityManager(aContentParent));
entry.Data()->Init();
FireTestOnlyObserverNotification("process-created",
nsPrintfCString("%" PRIu64, cpId));
}
return do_AddRef(entry.Data());
});
@ -427,15 +421,6 @@ void ProcessPriorityManagerImpl::SetProcessPriority(
}
}
void ProcessPriorityManagerImpl::ObserveContentParentCreated(
nsISupports* aContentParent) {
// Do nothing; it's sufficient to get the PPPM. But assign to nsRefPtr so we
// don't leak the already_AddRefed object.
RefPtr<ContentParent> cp = do_QueryObject(aContentParent);
RefPtr<ParticularProcessPriorityManager> pppm =
GetParticularProcessPriorityManager(cp);
}
void ProcessPriorityManagerImpl::ObserveContentParentDestroyed(
nsISupports* aSubject) {
nsCOMPtr<nsIPropertyBag2> props = do_QueryInterface(aSubject);