зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1618236 - Make CollectPerformanceInfo use BrowsingContextGroup to find DocGroups. r=tarek,peterv
By having CollectPerformanceInfo traverse the BrowsingContextGroup and tree of BrowsingContexts we can hide the task of getting the DocGroups befind an API in BrowsingContextGroup and ease the removal of TabGroups. Differential Revision: https://phabricator.services.mozilla.com/D64390 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
18161bb12a
Коммит
3b813ea957
|
@ -18,6 +18,8 @@ namespace dom {
|
|||
BrowsingContextGroup::BrowsingContextGroup() {
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild::GetSingleton()->HoldBrowsingContextGroup(this);
|
||||
} else {
|
||||
ContentParent::HoldBrowsingContextGroup(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,10 +42,12 @@ void BrowsingContextGroup::Unregister(BrowsingContext* aBrowsingContext) {
|
|||
UnsubscribeAllContentParents();
|
||||
if (XRE_IsContentProcess()) {
|
||||
ContentChild::GetSingleton()->ReleaseBrowsingContextGroup(this);
|
||||
// We may have been deleted here as the ContentChild may have held the
|
||||
// last references to `this`.
|
||||
// Do not access any members at this point.
|
||||
} else {
|
||||
ContentParent::ReleaseBrowsingContextGroup(this);
|
||||
}
|
||||
// We may have been deleted here as the ContentChild/Parent may
|
||||
// have held the last references to `this`.
|
||||
// Do not access any members at this point.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,6 +218,26 @@ BrowsingContextGroup* BrowsingContextGroup::GetChromeGroup() {
|
|||
return sChromeGroup;
|
||||
}
|
||||
|
||||
void BrowsingContextGroup::GetDocGroups(nsTArray<DocGroup*>& aDocGroups) {
|
||||
nsTHashtable<nsRefPtrHashKey<DocGroup>> docGroups;
|
||||
for (auto& toplevel : mToplevels) {
|
||||
toplevel->PreOrderWalk([&](BrowsingContext* aContext) {
|
||||
if (nsDocShell* docShell = nsDocShell::Cast(aContext->GetDocShell())) {
|
||||
if (!docShell->HasContentViewer()) {
|
||||
return;
|
||||
}
|
||||
if (Document* document = docShell->GetDocument()) {
|
||||
docGroups.PutEntry(document->GetDocGroup());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (auto iter = docGroups.ConstIter(); !iter.Done(); iter.Next()) {
|
||||
aDocGroups.AppendElement(iter.Get()->GetKey());
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(BrowsingContextGroup, mContexts,
|
||||
mToplevels, mSubscribers, mCachedContexts)
|
||||
|
||||
|
|
|
@ -117,6 +117,8 @@ class BrowsingContextGroup final : public nsWrapperCache {
|
|||
|
||||
static BrowsingContextGroup* GetChromeGroup();
|
||||
|
||||
void GetDocGroups(nsTArray<DocGroup*>& aDocGroups);
|
||||
|
||||
private:
|
||||
friend class CanonicalBrowsingContext;
|
||||
|
||||
|
|
|
@ -529,6 +529,8 @@ class nsDocShell final : public nsDocLoader,
|
|||
static void ExtractLastVisit(nsIChannel* aChannel, nsIURI** aURI,
|
||||
uint32_t* aChannelRedirectFlags);
|
||||
|
||||
bool HasContentViewer() const { return !!mContentViewer; }
|
||||
|
||||
static uint32_t ComputeURILoaderFlags(
|
||||
mozilla::dom::BrowsingContext* aBrowsingContext, uint32_t aLoadType);
|
||||
|
||||
|
|
|
@ -697,6 +697,10 @@ class ContentChild final
|
|||
PFileDescriptorSetChild* SendPFileDescriptorSetConstructor(
|
||||
const FileDescriptor& aFD) override;
|
||||
|
||||
const nsTArray<RefPtr<BrowsingContextGroup>>& BrowsingContextGroups() const {
|
||||
return mBrowsingContextGroupHolder;
|
||||
}
|
||||
|
||||
private:
|
||||
static void ForceKillTimerCallback(nsITimer* aTimer, void* aClosure);
|
||||
void StartForceKillTimer();
|
||||
|
|
|
@ -588,6 +588,8 @@ UniquePtr<SandboxBrokerPolicyFactory>
|
|||
uint64_t ContentParent::sNextRemoteTabId = 0;
|
||||
nsDataHashtable<nsUint64HashKey, BrowserParent*>
|
||||
ContentParent::sNextBrowserParents;
|
||||
StaticAutoPtr<nsTArray<RefPtr<BrowsingContextGroup>>>
|
||||
ContentParent::sBrowsingContextGroupHolder;
|
||||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
StaticAutoPtr<std::vector<std::string>> ContentParent::sMacSandboxParams;
|
||||
#endif
|
||||
|
@ -650,6 +652,9 @@ void ContentParent::StartUp() {
|
|||
// child process
|
||||
sCanLaunchSubprocesses = true;
|
||||
|
||||
sBrowsingContextGroupHolder = new nsTArray<RefPtr<BrowsingContextGroup>>();
|
||||
ClearOnShutdown(&sBrowsingContextGroupHolder);
|
||||
|
||||
if (!XRE_IsParentProcess()) {
|
||||
return;
|
||||
}
|
||||
|
@ -6384,6 +6389,18 @@ mozilla::ipc::IPCResult ContentParent::RecvWindowPostMessage(
|
|||
return IPC_OK();
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ContentParent::HoldBrowsingContextGroup(BrowsingContextGroup* aBCG) {
|
||||
sBrowsingContextGroupHolder->AppendElement(aBCG);
|
||||
}
|
||||
|
||||
/* static */
|
||||
void ContentParent::ReleaseBrowsingContextGroup(BrowsingContextGroup* aBCG) {
|
||||
if (sBrowsingContextGroupHolder) {
|
||||
sBrowsingContextGroupHolder->RemoveElement(aBCG);
|
||||
}
|
||||
}
|
||||
|
||||
void ContentParent::OnBrowsingContextGroupSubscribe(
|
||||
BrowsingContextGroup* aGroup) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(aGroup);
|
||||
|
|
|
@ -1289,6 +1289,9 @@ class ContentParent final
|
|||
const bool& aMinimizeMemoryUsage,
|
||||
const Maybe<FileDescriptor>& aDMDFile) override;
|
||||
|
||||
static void HoldBrowsingContextGroup(BrowsingContextGroup* aBCG);
|
||||
static void ReleaseBrowsingContextGroup(BrowsingContextGroup* aBCG);
|
||||
|
||||
void OnBrowsingContextGroupSubscribe(BrowsingContextGroup* aGroup);
|
||||
void OnBrowsingContextGroupUnsubscribe(BrowsingContextGroup* aGroup);
|
||||
|
||||
|
@ -1303,6 +1306,10 @@ class ContentParent final
|
|||
|
||||
NS_IMETHOD GetChildID(uint64_t* aChildID) override;
|
||||
|
||||
static const nsTArray<RefPtr<BrowsingContextGroup>>& BrowsingContextGroups() {
|
||||
return *sBrowsingContextGroupHolder;
|
||||
}
|
||||
|
||||
private:
|
||||
// Return an existing ContentParent if possible. Otherwise, `nullptr`.
|
||||
static already_AddRefed<ContentParent> GetUsedBrowserProcess(
|
||||
|
@ -1452,6 +1459,9 @@ class ContentParent final
|
|||
static uint64_t sNextRemoteTabId;
|
||||
static nsDataHashtable<nsUint64HashKey, BrowserParent*> sNextBrowserParents;
|
||||
|
||||
static StaticAutoPtr<nsTArray<RefPtr<BrowsingContextGroup>>>
|
||||
sBrowsingContextGroupHolder;
|
||||
|
||||
#if defined(XP_MACOSX) && defined(MOZ_SANDBOX)
|
||||
// When set to true, indicates that content processes should
|
||||
// initialize their sandbox during startup instead of waiting
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "mozilla/ResultExtensions.h"
|
||||
#include "mozilla/dom/DocGroup.h"
|
||||
#include "mozilla/dom/BrowserChild.h"
|
||||
#include "mozilla/dom/BrowsingContextGroup.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/WorkerDebugger.h"
|
||||
#include "mozilla/dom/WorkerDebuggerManager.h"
|
||||
|
||||
|
@ -38,25 +40,23 @@ nsTArray<RefPtr<PerformanceInfoPromise>> CollectPerformanceInfo() {
|
|||
promises.AppendElement(debugger->ReportPerformanceInfo());
|
||||
}
|
||||
|
||||
// collecting ReportPerformanceInfo from all DocGroup instances
|
||||
LinkedList<TabGroup>* tabGroups = TabGroup::GetTabGroupList();
|
||||
|
||||
// if GetTabGroupList() returns null, we don't have any tab group
|
||||
if (tabGroups) {
|
||||
// Per Bug 1519038, we want to collect DocGroup objects
|
||||
// and use them outside the iterator, to avoid a read-write conflict.
|
||||
nsTArray<RefPtr<DocGroup>> docGroups;
|
||||
for (TabGroup* tabGroup = tabGroups->getFirst(); tabGroup;
|
||||
tabGroup =
|
||||
static_cast<LinkedListElement<TabGroup>*>(tabGroup)->getNext()) {
|
||||
for (auto iter = tabGroup->Iter(); !iter.Done(); iter.Next()) {
|
||||
docGroups.AppendElement(iter.Get()->mDocGroup);
|
||||
}
|
||||
}
|
||||
for (DocGroup* docGroup : docGroups) {
|
||||
promises.AppendElement(docGroup->ReportPerformanceInfo());
|
||||
}
|
||||
nsTArray<RefPtr<BrowsingContextGroup>> groups;
|
||||
if (XRE_IsContentProcess()) {
|
||||
groups.AppendElements(
|
||||
ContentChild::GetSingleton()->BrowsingContextGroups());
|
||||
} else {
|
||||
groups.AppendElements(ContentParent::BrowsingContextGroups());
|
||||
}
|
||||
|
||||
nsTArray<DocGroup*> docGroups;
|
||||
for (auto& browsingContextGroup : groups) {
|
||||
browsingContextGroup->GetDocGroups(docGroups);
|
||||
}
|
||||
|
||||
for (DocGroup* docGroup : docGroups) {
|
||||
promises.AppendElement(docGroup->ReportPerformanceInfo());
|
||||
}
|
||||
|
||||
return promises;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче