Bug 1365400 - Add nsIProfiler::GetAllFeatures. r=njn
authorMarkus Stange <mstange@themasta.com>
Wed, 14 Jun 2017 00:20:35 -0400
changeset 364441 2573b20f6f90c721ab776b4d083b46fdc4f01c02
parent 364440 f22f7f42d2d4ecaadb447fcbd636a455c3465665
child 364442 6ac2d61a3904bbc52d0027ff4e12a6f94f1ce585
push id32042
push userarchaeopteryx@coole-files.de
push dateSat, 17 Jun 2017 19:33:32 +0000
treeherdermozilla-central@24012764504b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1365400
milestone56.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 1365400 - Add nsIProfiler::GetAllFeatures. r=njn MozReview-Commit-ID: EfjiUYvfIgM
tools/profiler/gecko/nsIProfiler.idl
tools/profiler/gecko/nsProfiler.cpp
--- a/tools/profiler/gecko/nsIProfiler.idl
+++ b/tools/profiler/gecko/nsIProfiler.idl
@@ -60,19 +60,30 @@ interface nsIProfiler : nsISupports
 
   [implicit_jscontext]
   nsISupports getProfileDataAsArrayBuffer([optional] in double aSinceTime);
 
   void dumpProfileToFileAsync(in ACString aFilename,
                               [optional] in double aSinceTime);
 
   boolean IsActive();
+
+  /**
+   * Returns an array of the features that are supported in this build.
+   * Features may vary depending on platform and build flags.
+   */
   void GetFeatures(out uint32_t aCount, [retval, array, size_is(aCount)] out string aFeatures);
 
   /**
+   * Returns an array of all features that are supported by the profiler.
+   * The array may contain features that are not supported in this build.
+   */
+  void GetAllFeatures(out uint32_t aCount, [retval, array, size_is(aCount)] out string aFeatures);
+
+  /**
    * The starting parameters that were sent to the profiler for sampling.
    * If the profiler is not currently sampling, this will return null.
    */
   [noscript] readonly attribute nsIProfilerStartParams startParams;
 
   void GetBufferInfo(out uint32_t aCurrentPosition, out uint32_t aTotalSize,
                      out uint32_t aGeneration);
 
--- a/tools/profiler/gecko/nsProfiler.cpp
+++ b/tools/profiler/gecko/nsProfiler.cpp
@@ -413,50 +413,63 @@ nsProfiler::GetElapsedTime(double* aElap
 
 NS_IMETHODIMP
 nsProfiler::IsActive(bool *aIsActive)
 {
   *aIsActive = profiler_is_active();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsProfiler::GetFeatures(uint32_t* aCount, char*** aFeatureList)
+static void
+GetArrayOfStringsForFeatures(uint32_t aFeatures,
+                             uint32_t* aCount, char*** aFeatureList)
 {
-  uint32_t features = profiler_get_available_features();
-
   #define COUNT_IF_SET(n_, str_, Name_) \
-    if (ProfilerFeature::Has##Name_(features)) { \
+    if (ProfilerFeature::Has##Name_(aFeatures)) { \
       len++; \
     }
 
   // Count the number of features in use.
   uint32_t len = 0;
   PROFILER_FOR_EACH_FEATURE(COUNT_IF_SET)
 
   #undef COUNT_IF_SET
 
   auto featureList = static_cast<char**>(moz_xmalloc(len * sizeof(char*)));
 
   #define DUP_IF_SET(n_, str_, Name_) \
-    if (ProfilerFeature::Has##Name_(features)) { \
+    if (ProfilerFeature::Has##Name_(aFeatures)) { \
       size_t strLen = strlen(str_); \
       featureList[i] = static_cast<char*>( \
         nsMemory::Clone(str_, (strLen + 1) * sizeof(char))); \
       i++; \
     }
 
   // Insert the strings for the features in use.
   size_t i = 0;
   PROFILER_FOR_EACH_FEATURE(DUP_IF_SET)
 
-  #undef STRDUP_IF_SET
+  #undef DUP_IF_SET
 
   *aFeatureList = featureList;
   *aCount = len;
+}
+
+NS_IMETHODIMP
+nsProfiler::GetFeatures(uint32_t* aCount, char*** aFeatureList)
+{
+  uint32_t features = profiler_get_available_features();
+  GetArrayOfStringsForFeatures(features, aCount, aFeatureList);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsProfiler::GetAllFeatures(uint32_t* aCount, char*** aFeatureList)
+{
+  GetArrayOfStringsForFeatures((uint32_t)-1, aCount, aFeatureList);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsProfiler::GetStartParams(nsIProfilerStartParams** aRetVal)
 {
   if (!profiler_is_active()) {
     *aRetVal = nullptr;