Bug 1562663 - P1 - Have an agent cluster id for each DocGroup; r=nika

The purpose of this patch is to know if two different global objects are in the
same agent cluster.

To achieve this, the plan to to add an id for each DocGroup in this patch. And,
have an id on each workers. The final goal is to pass these ids to ClientInfo
so that we can check if two different global are in the same agent cluster group
by checking the AgentClusterId on their ClientInfos.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Tung 2019-09-23 09:57:23 +00:00
parent b61f7995be
commit f2b43fd60f
3 changed files with 15 additions and 4 deletions

View File

@ -49,8 +49,9 @@ void DocGroup::RemoveDocument(Document* aDocument) {
mDocuments.RemoveElement(aDocument);
}
DocGroup::DocGroup(TabGroup* aTabGroup, const nsACString& aKey)
: mKey(aKey), mTabGroup(aTabGroup) {
DocGroup::DocGroup(TabGroup* aTabGroup, const nsACString& aKey,
const nsID& aAgentClusterId)
: mKey(aKey), mTabGroup(aTabGroup), mAgentClusterId(aAgentClusterId) {
// This method does not add itself to mTabGroup->mDocGroups as the caller does
// it for us.
mPerformanceCounter =

View File

@ -112,8 +112,11 @@ class DocGroup final {
static bool TryToLoadIframesInBackground();
const nsID& AgentClusterId() const { return mAgentClusterId; }
private:
DocGroup(TabGroup* aTabGroup, const nsACString& aKey);
DocGroup(TabGroup* aTabGroup, const nsACString& aKey,
const nsID& aAgentClusterId);
~DocGroup();
void FlushIframePostMessageQueue();
@ -126,6 +129,9 @@ class DocGroup final {
RefPtr<mozilla::ThrottledEventQueue> mIframePostMessageQueue;
nsTHashtable<nsUint64HashKey> mIframesUsedPostMessageQueue;
// Each DocGroup has a persisted agent cluster ID.
const nsID mAgentClusterId;
};
} // namespace dom

View File

@ -150,7 +150,11 @@ already_AddRefed<DocGroup> TabGroup::AddDocument(const nsACString& aKey,
if (entry->mDocGroup) {
docGroup = entry->mDocGroup;
} else {
docGroup = new DocGroup(this, aKey);
nsID agentClusterId;
nsresult rv = nsContentUtils::GenerateUUIDInPlace(agentClusterId);
MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
docGroup = new DocGroup(this, aKey, agentClusterId);
entry->mDocGroup = docGroup;
}