/* static */ TabGroup* TabGroup::GetFromActor(TabChild* aTabChild) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); // Middleman processes do not assign event targets to their tab children. if (recordreplay::IsMiddleman()) { return GetChromeTabGroup(); } nsCOMPtr<nsIEventTarget> target = aTabChild->Manager()->GetEventTargetFor(aTabChild); if (!target) { return nullptr; } // We have an event target. We assume the IPC code created it via // TabGroup::CreateEventTarget. RefPtr<SchedulerGroup> group = SchedulerGroup::FromEventTarget(target); MOZ_RELEASE_ASSERT(group); auto tabGroup = group->AsTabGroup(); MOZ_RELEASE_ASSERT(tabGroup); // We delay creating the event targets until now since the TabGroup // constructor ran off the main thread. tabGroup->EnsureThrottledEventQueues(); return tabGroup; }
TabGroup::TabGroup(bool aIsChrome) : mLastWindowLeft(false), mThrottledQueuesInitialized(false), mNumOfIndexedDBTransactions(0), mNumOfIndexedDBDatabases(0), mIsChrome(aIsChrome), mForegroundCount(0) { if (!sTabGroups) { sTabGroups = new LinkedList<TabGroup>(); } sTabGroups->insertBack(this); CreateEventTargets(/* aNeedValidation = */ !aIsChrome); // Do not throttle runnables from chrome windows. In theory we should // not have abuse issues from these windows and many browser chrome // tests have races that fail if we do throttle chrome runnables. if (aIsChrome) { MOZ_ASSERT(!sChromeTabGroup); return; } // This constructor can be called from the IPC I/O thread. In that case, we // won't actually use the TabGroup on the main thread until GetFromWindowActor // is called, so we initialize the throttled queues there. if (NS_IsMainThread()) { EnsureThrottledEventQueues(); } }