No issue - add API to tell Profile Timeline Recording state to JS engine

Based-on: m-c 1342070/5
This commit is contained in:
Martok 2023-01-21 22:48:18 +01:00 committed by roytam1
commit 531906eb87
3 changed files with 37 additions and 0 deletions

View file

@ -6,6 +6,7 @@
#include "TimelineConsumers.h"
#include "mozilla/ClearOnShutdown.h"
#include "jsapi.h"
#include "nsAppRunner.h" // for XRE_IsContentProcess, XRE_IsParentProcess
#include "nsDocShell.h"
@ -125,6 +126,9 @@ TimelineConsumers::AddConsumer(nsDocShell* aDocShell)
UniquePtr<ObservedDocShell>& observed = aDocShell->mObserved;
MOZ_ASSERT(!observed);
if (mActiveConsumers == 0) {
JS::SetProfileTimelineRecordingEnabled(true);
}
mActiveConsumers++;
ObservedDocShell* obsDocShell = new ObservedDocShell(aDocShell);
@ -144,6 +148,9 @@ TimelineConsumers::RemoveConsumer(nsDocShell* aDocShell)
MOZ_ASSERT(observed);
mActiveConsumers--;
if (mActiveConsumers == 0) {
JS::SetProfileTimelineRecordingEnabled(false);
}
// Clear all markers from the `mTimelineMarkers` store.
observed.get()->ClearMarkers();