Bug 1417976 - Part 3: Stream the DocShell list and DocShellId marker data to profile data r?mstange draft
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 24 Jul 2018 14:53:01 +0200
changeset 825818 7e16830c97bcbbb271aba5879aa48dd63e107421
parent 825817 b6670234c07a8fa0e9c55171a3fd71510c9270b4
push id118183
push userbmo:canaltinova@gmail.com
push dateThu, 02 Aug 2018 13:16:45 +0000
reviewersmstange
bugs1417976
milestone63.0a1
Bug 1417976 - Part 3: Stream the DocShell list and DocShellId marker data to profile data r?mstange MozReview-Commit-ID: G2s5H8i4p6E
tools/profiler/core/ProfilerMarkerPayload.cpp
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/ProfilerMarkerPayload.cpp
+++ b/tools/profiler/core/ProfilerMarkerPayload.cpp
@@ -31,16 +31,19 @@ ProfilerMarkerPayload::StreamCommonProps
                                          SpliceableJSONWriter& aWriter,
                                          const TimeStamp& aProcessStartTime,
                                          UniqueStacks& aUniqueStacks)
 {
   MOZ_ASSERT(aMarkerType);
   aWriter.StringProperty("type", aMarkerType);
   WriteTime(aWriter, aProcessStartTime, mStartTime, "startTime");
   WriteTime(aWriter, aProcessStartTime, mEndTime, "endTime");
+  if (mDocShellId) {
+    aWriter.StringProperty("docshellId", mDocShellId->ToString());
+  }
   if (mStack) {
     aWriter.StartObjectProperty("stack");
     {
       mStack->StreamJSON(aWriter, aProcessStartTime, aUniqueStacks);
     }
     aWriter.EndObject();
   }
 }
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -1827,16 +1827,30 @@ StreamMetaJSCustomObject(PSLockRef aLock
         }
       }
       aWriter.EndArray();
     }
   }
   aWriter.EndObject();
 }
 
+static void
+StreamDocshell(PSLockRef aLock, SpliceableJSONWriter& aWriter)
+{
+  MOZ_RELEASE_ASSERT(CorePS::Exists());
+
+  aWriter.StartObjectElement();
+  {
+    for (auto& docshell : CorePS::GetRegisteredDocShells(aLock)) {
+      docshell->AppendElement(aWriter);
+    }
+  }
+  aWriter.EndObject();
+}
+
 #if defined(GP_OS_android)
 static UniquePtr<ProfileBuffer>
 CollectJavaThreadProfileData()
 {
   // locked_profiler_start uses sample count is 1000 for Java thread.
   // This entry size is enough now, but we might have to estimate it
   // if we can customize it
   auto buffer = MakeUnique<ProfileBuffer>(1000 * 1000);
@@ -1887,16 +1901,23 @@ locked_profiler_stream_json_for_this_pro
 
   // Put meta data
   aWriter.StartObjectProperty("meta");
   {
     StreamMetaJSCustomObject(aLock, aWriter, aIsShuttingDown);
   }
   aWriter.EndObject();
 
+  // Put docshell data
+  aWriter.StartArrayProperty("docshells");
+  {
+    StreamDocshell(aLock, aWriter);
+  }
+  aWriter.EndArray();
+
   // Data of TaskTracer doesn't belong in the circular buffer.
   if (ActivePS::FeatureTaskTracer(aLock)) {
     aWriter.StartObjectProperty("tasktracer");
     StreamTaskTracer(aLock, aWriter);
     aWriter.EndObject();
   }
 
   // Lists the samples for each thread profile