Bug 1652000 - A little lifetime documentation;r=nika

Differential Revision: https://phabricator.services.mozilla.com/D83337
This commit is contained in:
David Teller 2020-07-20 09:42:48 +00:00
parent 23a82b7187
commit 94b50d3de1
3 changed files with 14 additions and 0 deletions

View File

@ -800,6 +800,8 @@ already_AddRefed<Promise> ChromeUtils::RequestProcInfo(GlobalObject& aGlobal,
// Get all the content parents.
// Note that this array includes even the long dead content parents, so we
// might have some garbage, especially with Fission.
// SAFETY NOTE: `contentParents` is only valid if used synchronously.
// Anything else and you may end up dealing with dangling pointers.
nsTArray<ContentParent*> contentParents;
ContentParent::GetAll(contentParents);

View File

@ -238,6 +238,16 @@ class ContentParent final
const nsACString& aRemoteType, BrowsingContext* aBrowsingContext,
ContentParent* aOpenerContentParent);
/**
* Get all content parents.
*
* # Lifetime
*
* These pointers are ONLY valid for synchronous use from the main thread.
*
* Do NOT attempt to use them after the main thread has had a chance to handle
* messages or you could end up with dangling pointers.
*/
static void GetAll(nsTArray<ContentParent*>& aArray);
static void GetAllEvenIfDead(nsTArray<ContentParent*>& aArray);

View File

@ -180,6 +180,8 @@ class GeckoChildProcessHost : public ChildProcessHost,
// Iterates over all instances and calls aCallback with each one of them.
// This method will lock any addition/removal of new processes
// so you need to make sure the callback is as fast as possible.
//
// To reiterate: the callbacks are executed synchronously.
static void GetAll(const GeckoProcessCallback& aCallback);
friend class BaseProcessLauncher;