Bug 1396227 - Sort performance entries by start time. r=baku
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Sat, 02 Sep 2017 21:39:19 +0900
changeset 428282 a2f3c1a002b3f206f812a73e1845f57d5b517fcb
parent 428281 d3021ff5ea6ae59624c5559be2e357a61da1b774
child 428283 eca4feb8acd2b71cee854ab8ba1f6853cbeefe18
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1396227
milestone57.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 1396227 - Sort performance entries by start time. r=baku MozReview-Commit-ID: 7m4MLlOJmFZ
dom/performance/Performance.cpp
dom/performance/PerformanceEntry.h
dom/performance/PerformanceObserverEntryList.cpp
testing/web-platform/meta/performance-timeline/po-entries-sort.any.js.ini
--- a/dom/performance/Performance.cpp
+++ b/dom/performance/Performance.cpp
@@ -31,37 +31,16 @@
 
 namespace mozilla {
 namespace dom {
 
 using namespace workers;
 
 namespace {
 
-// Helper classes
-class MOZ_STACK_CLASS PerformanceEntryComparator final
-{
-public:
-  bool Equals(const PerformanceEntry* aElem1,
-              const PerformanceEntry* aElem2) const
-  {
-    MOZ_ASSERT(aElem1 && aElem2,
-               "Trying to compare null performance entries");
-    return aElem1->StartTime() == aElem2->StartTime();
-  }
-
-  bool LessThan(const PerformanceEntry* aElem1,
-                const PerformanceEntry* aElem2) const
-  {
-    MOZ_ASSERT(aElem1 && aElem2,
-               "Trying to compare null performance entries");
-    return aElem1->StartTime() < aElem2->StartTime();
-  }
-};
-
 class PrefEnabledRunnable final
   : public WorkerCheckAPIExposureOnMainThreadRunnable
 {
 public:
   PrefEnabledRunnable(WorkerPrivate* aWorkerPrivate,
                       const nsCString& aPrefName)
     : WorkerCheckAPIExposureOnMainThreadRunnable(aWorkerPrivate)
     , mEnabled(false)
--- a/dom/performance/PerformanceEntry.h
+++ b/dom/performance/PerformanceEntry.h
@@ -89,12 +89,33 @@ public:
 protected:
   virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
 
   nsCOMPtr<nsISupports> mParent;
   nsString mName;
   nsString mEntryType;
 };
 
+// Helper classes
+class MOZ_STACK_CLASS PerformanceEntryComparator final
+{
+public:
+  bool Equals(const PerformanceEntry* aElem1,
+              const PerformanceEntry* aElem2) const
+  {
+    MOZ_ASSERT(aElem1 && aElem2,
+               "Trying to compare null performance entries");
+    return aElem1->StartTime() == aElem2->StartTime();
+  }
+
+  bool LessThan(const PerformanceEntry* aElem1,
+                const PerformanceEntry* aElem2) const
+  {
+    MOZ_ASSERT(aElem1 && aElem2,
+               "Trying to compare null performance entries");
+    return aElem1->StartTime() < aElem2->StartTime();
+  }
+};
+
 } // namespace dom
 } // namespace mozilla
 
 #endif /* mozilla_dom_PerformanceEntry_h___ */
--- a/dom/performance/PerformanceObserverEntryList.cpp
+++ b/dom/performance/PerformanceObserverEntryList.cpp
@@ -61,36 +61,39 @@ PerformanceObserverEntryList::GetEntries
     }
     if (aFilter.mEntryType.WasPassed() &&
         !entry->GetEntryType().Equals(aFilter.mEntryType.Value())) {
       continue;
     }
 
     aRetval.AppendElement(entry);
   }
+  aRetval.Sort(PerformanceEntryComparator());
 }
 
 void
 PerformanceObserverEntryList::GetEntriesByType(
   const nsAString& aEntryType,
   nsTArray<RefPtr<PerformanceEntry>>& aRetval)
 {
   aRetval.Clear();
   for (const RefPtr<PerformanceEntry>& entry : mEntries) {
     if (entry->GetEntryType().Equals(aEntryType)) {
       aRetval.AppendElement(entry);
     }
   }
+  aRetval.Sort(PerformanceEntryComparator());
 }
 
 void
 PerformanceObserverEntryList::GetEntriesByName(
   const nsAString& aName,
   const Optional<nsAString>& aEntryType,
   nsTArray<RefPtr<PerformanceEntry>>& aRetval)
 {
   aRetval.Clear();
   for (const RefPtr<PerformanceEntry>& entry : mEntries) {
     if (entry->GetName().Equals(aName)) {
       aRetval.AppendElement(entry);
     }
   }
+  aRetval.Sort(PerformanceEntryComparator());
 }
deleted file mode 100644
--- a/testing/web-platform/meta/performance-timeline/po-entries-sort.any.js.ini
+++ /dev/null
@@ -1,11 +0,0 @@
-[po-entries-sort.any.worker.html]
-  type: testharness
-  [getEntries, getEntriesByType, getEntriesByName sort order]
-    expected: FAIL
-
-
-[po-entries-sort.any.html]
-  type: testharness
-  [getEntries, getEntriesByType, getEntriesByName sort order]
-    expected: FAIL
-