moebius#157: The Performance Observer (improvements)

https://github.com/MoonchildProductions/moebius/pull/157
This commit is contained in:
janekptacijarabaci 2018-04-22 04:25:34 +02:00 committed by Roy Tam
commit 6a97ee9379
13 changed files with 107 additions and 150 deletions

View file

@ -114,12 +114,13 @@ PerformanceObserver::Notify()
RefPtr<PerformanceObserverEntryList> list =
new PerformanceObserverEntryList(this, mQueuedEntries);
mQueuedEntries.Clear();
ErrorResult rv;
mCallback->Call(this, *list, *this, rv);
if (NS_WARN_IF(rv.Failed())) {
rv.SuppressException();
}
mQueuedEntries.Clear();
}
void
@ -170,6 +171,17 @@ PerformanceObserver::Observe(const PerformanceObserverInit& aOptions,
mEntryTypes.SwapElements(validEntryTypes);
mPerformance->AddObserver(this);
if (aOptions.mBuffered) {
for (auto entryType : mEntryTypes) {
nsTArray<RefPtr<PerformanceEntry>> existingEntries;
mPerformance->GetEntriesByType(entryType, existingEntries);
if (!existingEntries.IsEmpty()) {
mQueuedEntries.AppendElements(existingEntries);
}
}
}
mConnected = true;
}