Bug 1722261 - Convert remaining uses of RegisteredThread's GetEventTarget and ResetMainThread - r=canaltinova

Differential Revision: https://phabricator.services.mozilla.com/D121971
This commit is contained in:
Gerald Squelart 2021-08-19 02:45:07 +00:00
Родитель 22cb733cca
Коммит 34aa8cf6dd
2 изменённых файлов: 11 добавлений и 13 удалений

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

@ -65,12 +65,6 @@ class RegisteredThread final {
const mozilla::profiler::ThreadRegistrationInfo& Info() const {
return mRacyRegisteredThread.mThreadRegistration.mData.mInfo;
}
nsCOMPtr<nsIEventTarget> GetEventTarget() const {
return mRacyRegisteredThread.mThreadRegistration.mData.mThread;
}
void ResetMainThread(nsIThread* aThread) {
mRacyRegisteredThread.mThreadRegistration.mData.mThread = aThread;
}
private:
class RacyRegisteredThread mRacyRegisteredThread;

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

@ -4129,7 +4129,8 @@ static ProfilingStack* locked_register_thread(
if (ActivePS::Exists(aLock) &&
ActivePS::ShouldProfileThread(
aLock, aOffThreadRef.UnlockedConstReaderCRef().Info())) {
nsCOMPtr<nsIEventTarget> eventTarget = registeredThread->GetEventTarget();
nsCOMPtr<nsIEventTarget> eventTarget =
lockedRWFromAnyThread->GetEventTarget();
ProfiledThreadData* profiledThreadData = ActivePS::AddLiveProfiledThread(
aLock, registeredThread.get(),
MakeUnique<ProfiledThreadData>(
@ -4257,12 +4258,15 @@ static Vector<const char*> SplitAtCommas(const char* aString,
void profiler_init_threadmanager() {
LOG("profiler_init_threadmanager");
PSAutoLock lock;
RegisteredThread* registeredThread =
TLSRegisteredThread::RegisteredThread(lock);
if (registeredThread && !registeredThread->GetEventTarget()) {
registeredThread->ResetMainThread(NS_GetCurrentThreadNoCreate());
}
ThreadRegistration::WithOnThreadRef(
[](ThreadRegistration::OnThreadRef aOnThreadRef) {
aOnThreadRef.WithLockedRWOnThread(
[](ThreadRegistration::LockedRWOnThread& aThreadData) {
if (!aThreadData.GetEventTarget()) {
aThreadData.ResetMainThread(NS_GetCurrentThreadNoCreate());
}
});
});
}
void profiler_init(void* aStackTop) {