Bug 1429898: Add active extension details to profiler metadata. r?mstange draft
authorKris Maglione <maglione.k@gmail.com>
Thu, 11 Jan 2018 12:38:31 -0800
changeset 719327 c1bcfc0be1b483edad475327053585b287cb3b70
parent 718728 c3d412499e827193d743600c4046e90be5e12492
child 745765 a4fc48065749c160c9b29a4f174453a588ae67a4
push id95224
push usermaglione.k@gmail.com
push dateThu, 11 Jan 2018 23:20:39 +0000
reviewersmstange
bugs1429898
milestone59.0a1
Bug 1429898: Add active extension details to profiler metadata. r?mstange MozReview-Commit-ID: CR64i73B4ys
tools/profiler/core/platform.cpp
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -37,22 +37,24 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Atomics.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/Vector.h"
 #include "GeckoProfiler.h"
 #include "GeckoProfilerReporter.h"
 #include "ProfilerIOInterposeObserver.h"
 #include "mozilla/AutoProfilerLabel.h"
+#include "mozilla/ExtensionPolicyService.h"
 #include "mozilla/Scheduler.h"
 #include "mozilla/StackWalk.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/ThreadLocal.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/extensions/WebExtensionPolicy.h"
 #include "ThreadInfo.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIObserverService.h"
 #include "nsIXULAppInfo.h"
 #include "nsIXULRuntime.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsJSPrincipals.h"
@@ -1539,16 +1541,51 @@ StreamMetaJSCustomObject(PSLockRef aLock
     do_GetService("@mozilla.org/xre/app-info;1");
 
   if (appInfo) {
     nsAutoCString string;
     res = appInfo->GetName(string);
     if (!NS_FAILED(res))
       aWriter.StringProperty("product", string.Data());
   }
+
+  aWriter.StartObjectProperty("extensions");
+  {
+    {
+      JSONSchemaWriter schema(aWriter);
+      schema.WriteField("id");
+      schema.WriteField("name");
+      schema.WriteField("baseURL");
+    }
+
+    aWriter.StartArrayProperty("data");
+    {
+      nsTArray<RefPtr<WebExtensionPolicy>> exts;
+      ExtensionPolicyService::GetSingleton().GetAll(exts);
+
+      for (auto& ext : exts) {
+        aWriter.StartArrayElement(JSONWriter::SingleLineStyle);
+
+        nsAutoString id;
+        ext->GetId(id);
+        aWriter.StringElement(NS_ConvertUTF16toUTF8(id).get());
+
+        aWriter.StringElement(NS_ConvertUTF16toUTF8(ext->Name()).get());
+
+        auto url = ext->GetURL(NS_LITERAL_STRING(""));
+        if (url.isOk()) {
+          aWriter.StringElement(NS_ConvertUTF16toUTF8(url.unwrap()).get());
+        }
+
+        aWriter.EndArray();
+      }
+    }
+    aWriter.EndArray();
+  }
+  aWriter.EndObject();
 }
 
 #if defined(GP_OS_android)
 static void
 BuildJavaThreadJSObject(SpliceableJSONWriter& aWriter)
 {
   aWriter.StringProperty("name", "Java Main Thread");