From 5ea5fccd2943eef08e4ec05b4c4597a79d1b360b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Fri, 2 Nov 2018 20:27:16 +0000 Subject: [PATCH] Bug 1417976 - Part 3: Stream the DocShell list and DocShellId marker data to profile data r=mstange MozReview-Commit-ID: G2s5H8i4p6E Depends on D4915 Differential Revision: https://phabricator.services.mozilla.com/D4916 --HG-- extra : moz-landing-system : lando --- tools/profiler/core/PageInformation.cpp | 11 +++++++++++ tools/profiler/core/PageInformation.h | 1 + tools/profiler/core/ProfilerMarkerPayload.cpp | 6 ++++++ tools/profiler/core/platform.cpp | 17 +++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/tools/profiler/core/PageInformation.cpp b/tools/profiler/core/PageInformation.cpp index 563740e3a755..daa8c83cc1f0 100644 --- a/tools/profiler/core/PageInformation.cpp +++ b/tools/profiler/core/PageInformation.cpp @@ -25,6 +25,17 @@ return DocShellHistoryId() == aOtherPageInfo->DocShellHistoryId() && IsSubFrame() == aOtherPageInfo->IsSubFrame(); } +void +PageInformation::StreamJSON(SpliceableJSONWriter& aWriter) +{ + aWriter.StartObjectElement(); + aWriter.StringProperty("docshellId", nsIDToCString(DocShellId()).get()); + aWriter.DoubleProperty("historyId", DocShellHistoryId()); + aWriter.StringProperty("url", Url().get()); + aWriter.BoolProperty("isSubFrame", IsSubFrame()); + aWriter.EndObject(); +} + size_t PageInformation::SizeOfIncludingThis( mozilla::MallocSizeOf aMallocSizeOf) const diff --git a/tools/profiler/core/PageInformation.h b/tools/profiler/core/PageInformation.h index 30cf07c2d1ae..f20f416bb2cd 100644 --- a/tools/profiler/core/PageInformation.h +++ b/tools/profiler/core/PageInformation.h @@ -30,6 +30,7 @@ public: size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const; bool Equals(PageInformation* aOtherDocShellInfo); + void StreamJSON(SpliceableJSONWriter& aWriter); uint32_t DocShellHistoryId() { return mDocShellHistoryId; } const nsID& DocShellId() { return mDocShellId; } diff --git a/tools/profiler/core/ProfilerMarkerPayload.cpp b/tools/profiler/core/ProfilerMarkerPayload.cpp index af299c82e848..5ebe542515d1 100644 --- a/tools/profiler/core/ProfilerMarkerPayload.cpp +++ b/tools/profiler/core/ProfilerMarkerPayload.cpp @@ -43,6 +43,12 @@ ProfilerMarkerPayload::StreamCommonProps(const char* aMarkerType, StreamType(aMarkerType, aWriter); WriteTime(aWriter, aProcessStartTime, mStartTime, "startTime"); WriteTime(aWriter, aProcessStartTime, mEndTime, "endTime"); + if (mDocShellId) { + aWriter.StringProperty("docShellId", nsIDToCString(*mDocShellId).get()); + } + if (mDocShellHistoryId) { + aWriter.DoubleProperty("docshellHistoryId", mDocShellHistoryId.ref()); + } if (mStack) { aWriter.StartObjectProperty("stack"); { diff --git a/tools/profiler/core/platform.cpp b/tools/profiler/core/platform.cpp index 0fe334645916..72767677de53 100644 --- a/tools/profiler/core/platform.cpp +++ b/tools/profiler/core/platform.cpp @@ -1890,6 +1890,16 @@ StreamMetaJSCustomObject(PSLockRef aLock, SpliceableJSONWriter& aWriter, } } +static void +StreamPages(PSLockRef aLock, SpliceableJSONWriter& aWriter) +{ + MOZ_RELEASE_ASSERT(CorePS::Exists()); + ActivePS::DiscardExpiredPages(aLock); + for (const auto& page : ActivePS::ProfiledPages(aLock)) { + page->StreamJSON(aWriter); + } +} + #if defined(GP_OS_android) static UniquePtr CollectJavaThreadProfileData() @@ -1966,6 +1976,13 @@ locked_profiler_stream_json_for_this_process(PSLockRef aLock, } aWriter.EndObject(); + // Put page data + aWriter.StartArrayProperty("pages"); + { + StreamPages(aLock, aWriter); + } + aWriter.EndArray(); + buffer.StreamCountersToJSON(aWriter, CorePS::ProcessStartTime(), aSinceTime); buffer.StreamMemoryToJSON(aWriter, CorePS::ProcessStartTime(), aSinceTime);