diff options
Diffstat (limited to 'dom/performance')
-rw-r--r-- | dom/performance/Performance.cpp | 20 | ||||
-rw-r--r-- | dom/performance/PerformanceStorageWorker.cpp | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/dom/performance/Performance.cpp b/dom/performance/Performance.cpp index ce2557100d..070bca9ec4 100644 --- a/dom/performance/Performance.cpp +++ b/dom/performance/Performance.cpp @@ -33,6 +33,7 @@ #include "mozilla/dom/PerformanceObserverBinding.h" #include "mozilla/dom/PerformanceNavigationTiming.h" #include "mozilla/IntegerPrintfMacros.h" +#include "mozilla/Perfetto.h" #include "mozilla/Preferences.h" #include "mozilla/TimeStamp.h" #include "mozilla/dom/WorkerPrivate.h" @@ -764,6 +765,25 @@ already_AddRefed<PerformanceMeasure> Performance::Measure( detail.setNull(); } +#ifdef MOZ_PERFETTO + // Perfetto requires that events are properly nested within each category. + // Since this is not a guarantee here, we need to define a dynamic category + // for each measurement so it's not prematurely ended by another measurement + // that overlaps. We also use the usertiming category to guard these markers + // so it's easy to toggle. + if (TRACE_EVENT_CATEGORY_ENABLED("usertiming")) { + NS_ConvertUTF16toUTF8 str(aName); + perfetto::DynamicCategory category{str.get()}; + TimeStamp startTimeStamp = + CreationTimeStamp() + TimeDuration::FromMilliseconds(startTime); + TimeStamp endTimeStamp = + CreationTimeStamp() + TimeDuration::FromMilliseconds(endTime); + PERFETTO_TRACE_EVENT_BEGIN(category, perfetto::DynamicString{str.get()}, + startTimeStamp); + PERFETTO_TRACE_EVENT_END(category, endTimeStamp); + } +#endif + RefPtr<PerformanceMeasure> performanceMeasure = new PerformanceMeasure( GetParentObject(), aName, startTime, endTime, detail); InsertUserEntry(performanceMeasure); diff --git a/dom/performance/PerformanceStorageWorker.cpp b/dom/performance/PerformanceStorageWorker.cpp index 4fb4815121..3649a6270b 100644 --- a/dom/performance/PerformanceStorageWorker.cpp +++ b/dom/performance/PerformanceStorageWorker.cpp @@ -39,8 +39,7 @@ class PerformanceEntryAdder final : public WorkerControlRunnable { PerformanceEntryAdder(WorkerPrivate* aWorkerPrivate, PerformanceStorageWorker* aStorage, UniquePtr<PerformanceProxyData>&& aData) - : WorkerControlRunnable(aWorkerPrivate, "PerformanceEntryAdder", - WorkerThread), + : WorkerControlRunnable("PerformanceEntryAdder"), mStorage(aStorage), mData(std::move(aData)) {} @@ -119,7 +118,7 @@ void PerformanceStorageWorker::AddEntry(nsIHttpChannel* aChannel, RefPtr<PerformanceEntryAdder> r = new PerformanceEntryAdder(workerPrivate, this, std::move(data)); - Unused << NS_WARN_IF(!r->Dispatch()); + Unused << NS_WARN_IF(!r->Dispatch(workerPrivate)); } void PerformanceStorageWorker::AddEntry( |