Bug 1431483 - Add a pseudo stack frame with the image URL to ImageLoader::Notify. r?aosmond draft
authorMarkus Stange <mstange@themasta.com>
Thu, 18 Jan 2018 14:02:30 -0500
changeset 722279 3053b8bf7e81fca025b0a450e4144a58f46b581e
parent 722278 62b746255086c83e282ea79c7d7e4f2d1cb19f61
child 746581 166d5bb9fcee32fcbcfc7c621b04cb8bfcc439cd
push id96113
push userbmo:mstange@themasta.com
push dateThu, 18 Jan 2018 19:02:58 +0000
reviewersaosmond
bugs1431483
milestone59.0a1
Bug 1431483 - Add a pseudo stack frame with the image URL to ImageLoader::Notify. r?aosmond MozReview-Commit-ID: F3KU0qpmHx6
layout/style/ImageLoader.cpp
--- a/layout/style/ImageLoader.cpp
+++ b/layout/style/ImageLoader.cpp
@@ -13,16 +13,17 @@
 #include "nsContentUtils.h"
 #include "nsLayoutUtils.h"
 #include "nsError.h"
 #include "nsDisplayList.h"
 #include "FrameLayerBuilder.h"
 #include "SVGObserverUtils.h"
 #include "imgIContainer.h"
 #include "Image.h"
+#include "GeckoProfiler.h"
 
 namespace mozilla {
 namespace css {
 
 void
 ImageLoader::DropDocumentReference()
 {
   // It's okay if GetPresContext returns null here (due to the presshell pointer
@@ -389,16 +390,29 @@ NS_IMPL_RELEASE(ImageLoader)
 
 NS_INTERFACE_MAP_BEGIN(ImageLoader)
   NS_INTERFACE_MAP_ENTRY(imgINotificationObserver)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 ImageLoader::Notify(imgIRequest* aRequest, int32_t aType, const nsIntRect* aData)
 {
+#ifdef MOZ_GECKO_PROFILER
+  nsCString uriString;
+  if (profiler_is_active()) {
+    nsCOMPtr<nsIURI> uri;
+    aRequest->GetFinalURI(getter_AddRefs(uri));
+    if (uri) {
+      uri->GetSpec(uriString);
+    }
+  }
+
+  AUTO_PROFILER_LABEL_DYNAMIC_NSCSTRING("ImageLoader::Notify", OTHER, uriString);
+#endif
+
   if (aType == imgINotificationObserver::SIZE_AVAILABLE) {
     nsCOMPtr<imgIContainer> image;
     aRequest->GetImage(getter_AddRefs(image));
     return OnSizeAvailable(aRequest, image);
   }
 
   if (aType == imgINotificationObserver::IS_ANIMATED) {
     return OnImageIsAnimated(aRequest);