Bug 1159003 - setResourceTimingBufferSize shouldn't affect user timing, but we should clean user markers if we have memory pressure, r=bz

This commit is contained in:
roytam1 2023-04-13 16:42:19 +08:00
commit bc3eb89dee
5 changed files with 40 additions and 17 deletions

View file

@ -262,11 +262,6 @@ already_AddRefed<PerformanceMark> Performance::Mark(
const PerformanceMarkOptions& aMarkOptions,
ErrorResult& aRv)
{
// Don't add the entry if the buffer is full. XXX should be removed by bug 1159003.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
return nullptr;
}
nsCOMPtr<nsIGlobalObject> parent = GetParentObject();
if (!parent || parent->IsDying() || !parent->GetGlobalJSObject()) {
aRv.Throw(NS_ERROR_DOM_UT_UNAVAILABLE_GLOBAL_OBJECT);
@ -490,12 +485,6 @@ Performance::Measure(JSContext* aCx,
const Optional<nsAString>& aEndMark,
ErrorResult& aRv)
{
// Don't add the entry if the buffer is full. XXX should be removed by bug
// 1159003.
if (mUserEntries.Length() >= mResourceTimingBufferSize) {
return nullptr;
}
const PerformanceMeasureOptions* options = nullptr;
if (aStartOrMeasureOptions.IsPerformanceMeasureOptions()) {
options = &aStartOrMeasureOptions.GetAsPerformanceMeasureOptions();
@ -753,5 +742,11 @@ Performance::IsObserverEnabled(JSContext* aCx, JSObject* aGlobal)
return runnable->Dispatch() && runnable->IsEnabled();
}
void
Performance::MemoryPressure()
{
mUserEntries.Clear();
}
} // dom namespace
} // mozilla namespace