Bug 1608217 - Add innerWindowID into network markers. r=gerald
authorNazım Can Altınova <canaltinova@gmail.com>
Tue, 11 Feb 2020 10:33:47 +0000
changeset 513351 94cb6116eea854380e1e2fe682dba97a57bd49f5
parent 513350 ca430d9d7ba100ed387ecba5afcc9daa6fb4105b
child 513352 681191363d89d91c0a8151dfc18894d5559e4816
push id37112
push userbtara@mozilla.com
push dateTue, 11 Feb 2020 21:47:36 +0000
treeherdermozilla-central@79d5ac0c4227 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1608217
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1608217 - Add innerWindowID into network markers. r=gerald Differential Revision: https://phabricator.services.mozilla.com/D62099
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/nsHttpChannel.cpp
tools/profiler/core/platform.cpp
tools/profiler/public/GeckoProfiler.h
tools/profiler/public/ProfilerMarkerPayload.h
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -1063,17 +1063,18 @@ void HttpChannelChild::OnStopRequest(
 
 #ifdef MOZ_GECKO_PROFILER
   if (profiler_can_accept_markers()) {
     int32_t priority = PRIORITY_NORMAL;
     GetPriority(&priority);
     profiler_add_network_marker(
         mURI, priority, mChannelId, NetworkLoadType::LOAD_STOP,
         mLastStatusReported, TimeStamp::Now(), mTransferSize, kCacheUnknown,
-        &mTransactionTimings, nullptr, std::move(mSource));
+        mLoadInfo->GetInnerWindowID(), &mTransactionTimings, nullptr,
+        std::move(mSource));
   }
 #endif
 
   mResponseTrailers = new nsHttpHeaderArray(aResponseTrailers);
 
   DoPreOnStopRequest(aChannelStatus);
 
   {  // We must flush the queue before we Send__delete__
@@ -1642,20 +1643,21 @@ void HttpChannelChild::Redirect1Begin(
 
   LOG(("HttpChannelChild::Redirect1Begin [this=%p]\n", this));
 
   ipc::MergeParentLoadInfoForwarder(loadInfoForwarder, mLoadInfo);
 
   nsCOMPtr<nsIURI> uri = DeserializeURI(newOriginalURI);
 
   ResourceTimingStructArgsToTimingsStruct(timing, mTransactionTimings);
-  PROFILER_ADD_NETWORK_MARKER(
-      mURI, mPriority, mChannelId, NetworkLoadType::LOAD_REDIRECT,
-      mLastStatusReported, TimeStamp::Now(), 0, kCacheUnknown,
-      &mTransactionTimings, uri, std::move(mSource));
+  PROFILER_ADD_NETWORK_MARKER(mURI, mPriority, mChannelId,
+                              NetworkLoadType::LOAD_REDIRECT,
+                              mLastStatusReported, TimeStamp::Now(), 0,
+                              kCacheUnknown, mLoadInfo->GetInnerWindowID(),
+                              &mTransactionTimings, uri, std::move(mSource));
 
   if (!securityInfoSerialization.IsEmpty()) {
     rv = NS_DeserializeObject(securityInfoSerialization,
                               getter_AddRefs(mSecurityInfo));
     MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv),
                           "Deserializing security info should not fail");
   }
 
@@ -2091,20 +2093,20 @@ HttpChannelChild::CompleteRedirectSetup(
   /*
    * No need to check for cancel: we don't get here if nsHttpChannel canceled
    * before AsyncOpen(); if it's canceled after that, OnStart/Stop will just
    * get called with error code as usual.  So just setup mListener and make the
    * channel reflect AsyncOpen'ed state.
    */
 
   mLastStatusReported = TimeStamp::Now();
-  PROFILER_ADD_NETWORK_MARKER(mURI, mPriority, mChannelId,
-                              NetworkLoadType::LOAD_START,
-                              mChannelCreationTimestamp, mLastStatusReported, 0,
-                              kCacheUnknown, nullptr, nullptr);
+  PROFILER_ADD_NETWORK_MARKER(
+      mURI, mPriority, mChannelId, NetworkLoadType::LOAD_START,
+      mChannelCreationTimestamp, mLastStatusReported, 0, kCacheUnknown,
+      mLoadInfo->GetInnerWindowID(), nullptr, nullptr);
   mIsPending = true;
   mWasOpened = true;
   mListener = aListener;
 
   // add ourselves to the load group.
   if (mLoadGroup) mLoadGroup->AddRequest(this, nullptr);
 
   // We already have an open IPDL connection to the parent. If on-modify-request
@@ -2469,20 +2471,20 @@ nsresult HttpChannelChild::AsyncOpenInte
 
   // We notify "http-on-opening-request" observers in the child
   // process so that devtools can capture a stack trace at the
   // appropriate spot.  See bug 806753 for some information about why
   // other http-* notifications are disabled in child processes.
   gHttpHandler->OnOpeningRequest(this);
 
   mLastStatusReported = TimeStamp::Now();
-  PROFILER_ADD_NETWORK_MARKER(mURI, mPriority, mChannelId,
-                              NetworkLoadType::LOAD_START,
-                              mChannelCreationTimestamp, mLastStatusReported, 0,
-                              kCacheUnknown, nullptr, nullptr);
+  PROFILER_ADD_NETWORK_MARKER(
+      mURI, mPriority, mChannelId, NetworkLoadType::LOAD_START,
+      mChannelCreationTimestamp, mLastStatusReported, 0, kCacheUnknown,
+      mLoadInfo->GetInnerWindowID(), nullptr, nullptr);
 
   mIsPending = true;
   mWasOpened = true;
   mListener = listener;
 
   // add ourselves to the load group.
   if (mLoadGroup) mLoadGroup->AddRequest(this, nullptr);
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -6037,17 +6037,18 @@ nsresult nsHttpChannel::ContinueProcessR
     TimingStruct timings;
     if (mTransaction) {
       timings = mTransaction->Timings();
     }
 
     profiler_add_network_marker(
         mURI, priority, mChannelId, NetworkLoadType::LOAD_REDIRECT,
         mLastStatusReported, TimeStamp::Now(), mLogicalOffset,
-        mCacheDisposition, &timings, mRedirectURI, std::move(mSource));
+        mCacheDisposition, mLoadInfo->GetInnerWindowID(), &timings,
+        mRedirectURI, std::move(mSource));
   }
 #endif
 
   nsCOMPtr<nsIIOService> ioService;
   rv = gHttpHandler->GetIOService(getter_AddRefs(ioService));
   if (NS_FAILED(rv)) return rv;
 
   uint32_t redirectFlags;
@@ -6473,20 +6474,20 @@ nsHttpChannel::AsyncOpen(nsIStreamListen
     tasktracer::AddLabel("nsHttpChannel::AsyncOpen %s", urispec.get());
   }
 #endif
 
 #ifdef MOZ_GECKO_PROFILER
   mLastStatusReported =
       TimeStamp::Now();  // in case we enable the profiler after AsyncOpen()
   if (profiler_can_accept_markers()) {
-    profiler_add_network_marker(mURI, mPriority, mChannelId,
-                                NetworkLoadType::LOAD_START,
-                                mChannelCreationTimestamp, mLastStatusReported,
-                                0, mCacheDisposition, nullptr, nullptr);
+    profiler_add_network_marker(
+        mURI, mPriority, mChannelId, NetworkLoadType::LOAD_START,
+        mChannelCreationTimestamp, mLastStatusReported, 0, mCacheDisposition,
+        mLoadInfo->GetInnerWindowID(), nullptr, nullptr);
   }
 #endif
 
   NS_CompareLoadInfoAndLoadContext(this);
 
 #ifdef DEBUG
   AssertPrivateBrowsingId();
 #endif
@@ -8408,17 +8409,18 @@ nsresult nsHttpChannel::ContinueOnStopRe
     // These do allocations/frees/etc; avoid if not active
     nsCOMPtr<nsIURI> uri;
     GetURI(getter_AddRefs(uri));
     int32_t priority = PRIORITY_NORMAL;
     GetPriority(&priority);
     profiler_add_network_marker(
         uri, priority, mChannelId, NetworkLoadType::LOAD_STOP,
         mLastStatusReported, TimeStamp::Now(), mLogicalOffset,
-        mCacheDisposition, &mTransactionTimings, nullptr, std::move(mSource));
+        mCacheDisposition, mLoadInfo->GetInnerWindowID(), &mTransactionTimings,
+        nullptr, std::move(mSource));
   }
 #endif
 
   if (mListener) {
     LOG(("nsHttpChannel %p calling OnStopRequest\n", this));
     MOZ_ASSERT(mOnStartRequestCalled,
                "OnStartRequest should be called before OnStopRequest");
     MOZ_ASSERT(!mOnStopRequestCalled, "We should not call OnStopRequest twice");
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -4840,17 +4840,17 @@ bool profiler_add_native_allocation_mark
           TimeStamp::Now(), aSize, aMemoryAddress, profiler_current_thread_id(),
           profiler_get_backtrace()));
   return true;
 }
 
 void profiler_add_network_marker(
     nsIURI* aURI, int32_t aPriority, uint64_t aChannelId, NetworkLoadType aType,
     mozilla::TimeStamp aStart, mozilla::TimeStamp aEnd, int64_t aCount,
-    mozilla::net::CacheDisposition aCacheDisposition,
+    mozilla::net::CacheDisposition aCacheDisposition, uint64_t aInnerWindowID,
     const mozilla::net::TimingStruct* aTimings, nsIURI* aRedirectURI,
     UniqueProfilerBacktrace aSource) {
   if (!profiler_can_accept_markers()) {
     return;
   }
   // These do allocations/frees/etc; avoid if not active
   nsAutoCString spec;
   nsAutoCString redirect_spec;
@@ -4862,20 +4862,21 @@ void profiler_add_network_marker(
   }
   // top 32 bits are process id of the load
   uint32_t id = static_cast<uint32_t>(aChannelId & 0xFFFFFFFF);
   char name[2048];
   SprintfLiteral(name, "Load %d: %s", id, PromiseFlatCString(spec).get());
   AUTO_PROFILER_STATS(add_marker_with_NetworkMarkerPayload);
   profiler_add_marker(
       name, JS::ProfilingCategoryPair::NETWORK,
-      NetworkMarkerPayload(
-          static_cast<int64_t>(aChannelId), PromiseFlatCString(spec).get(),
-          aType, aStart, aEnd, aPriority, aCount, aCacheDisposition, aTimings,
-          PromiseFlatCString(redirect_spec).get(), std::move(aSource)));
+      NetworkMarkerPayload(static_cast<int64_t>(aChannelId),
+                           PromiseFlatCString(spec).get(), aType, aStart, aEnd,
+                           aPriority, aCount, aCacheDisposition, aInnerWindowID,
+                           aTimings, PromiseFlatCString(redirect_spec).get(),
+                           std::move(aSource)));
 }
 
 void profiler_add_marker_for_thread(int aThreadId,
                                     JS::ProfilingCategoryPair aCategoryPair,
                                     const char* aMarkerName,
                                     UniquePtr<ProfilerMarkerPayload> aPayload) {
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -55,18 +55,19 @@
 #  define AUTO_PROFILER_LABEL_DYNAMIC_LOSSY_NSSTRING(label, categoryPair, nsStr)
 #  define AUTO_PROFILER_LABEL_FAST(label, categoryPair, ctx)
 #  define AUTO_PROFILER_LABEL_DYNAMIC_FAST(label, dynamicString, categoryPair, \
                                            ctx, flags)
 
 #  define PROFILER_ADD_MARKER(markerName, categoryPair)
 #  define PROFILER_ADD_MARKER_WITH_PAYLOAD(markerName, categoryPair, \
                                            PayloadType, payloadArgs)
-#  define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end, \
-                                      count, cache, timings, redirect, ...)
+#  define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end,  \
+                                      count, cache, innerWindowID, timings, \
+                                      redirect, ...)
 
 #  define PROFILER_TRACING_MARKER(categoryString, markerName, categoryPair, \
                                   kind)
 #  define PROFILER_TRACING_MARKER_DOCSHELL(categoryString, markerName, \
                                            categoryPair, kind, docshell)
 #  define AUTO_PROFILER_TRACING_MARKER(categoryString, markerName, categoryPair)
 #  define AUTO_PROFILER_TRACING_MARKER_DOCSHELL(categoryString, markerName, \
                                                 categoryPair, docShell)
@@ -828,24 +829,26 @@ bool profiler_is_locked_on_current_threa
 void profiler_add_marker_for_thread(
     int aThreadId, JS::ProfilingCategoryPair aCategoryPair,
     const char* aMarkerName,
     mozilla::UniquePtr<ProfilerMarkerPayload> aPayload);
 
 enum class NetworkLoadType { LOAD_START, LOAD_STOP, LOAD_REDIRECT };
 
 #  define PROFILER_ADD_NETWORK_MARKER(uri, pri, channel, type, start, end,  \
-                                      count, cache, timings, redirect, ...) \
+                                      count, cache, innerWindowID, timings, \
+                                      redirect, ...)                        \
     profiler_add_network_marker(uri, pri, channel, type, start, end, count, \
-                                cache, timings, redirect, ##__VA_ARGS__)
+                                cache, innerWindowID, timings, redirect,    \
+                                ##__VA_ARGS__)
 
 void profiler_add_network_marker(
     nsIURI* aURI, int32_t aPriority, uint64_t aChannelId, NetworkLoadType aType,
     mozilla::TimeStamp aStart, mozilla::TimeStamp aEnd, int64_t aCount,
-    mozilla::net::CacheDisposition aCacheDisposition,
+    mozilla::net::CacheDisposition aCacheDisposition, uint64_t aInnerWindowID,
     const mozilla::net::TimingStruct* aTimings = nullptr,
     nsIURI* aRedirectURI = nullptr, UniqueProfilerBacktrace aSource = nullptr);
 
 enum TracingKind {
   TRACING_EVENT,
   TRACING_INTERVAL_START,
   TRACING_INTERVAL_END,
 };
--- a/tools/profiler/public/ProfilerMarkerPayload.h
+++ b/tools/profiler/public/ProfilerMarkerPayload.h
@@ -393,20 +393,22 @@ class VsyncMarkerPayload : public Profil
 
 class NetworkMarkerPayload : public ProfilerMarkerPayload {
  public:
   NetworkMarkerPayload(int64_t aID, const char* aURI, NetworkLoadType aType,
                        const mozilla::TimeStamp& aStartTime,
                        const mozilla::TimeStamp& aEndTime, int32_t aPri,
                        int64_t aCount,
                        mozilla::net::CacheDisposition aCacheDisposition,
+                       uint64_t aInnerWindowID,
                        const mozilla::net::TimingStruct* aTimings = nullptr,
                        const char* aRedirectURI = nullptr,
                        UniqueProfilerBacktrace aSource = nullptr)
-      : ProfilerMarkerPayload(aStartTime, aEndTime, mozilla::Nothing(),
+      : ProfilerMarkerPayload(aStartTime, aEndTime,
+                              mozilla::Some(aInnerWindowID),
                               std::move(aSource)),
         mID(aID),
         mURI(aURI ? strdup(aURI) : nullptr),
         mRedirectURI(aRedirectURI && (strlen(aRedirectURI) > 0)
                          ? strdup(aRedirectURI)
                          : nullptr),
         mType(aType),
         mPri(aPri),