Bug 1492011 change CreateStartTimerValue and CreateLogOrEndTimerValue from instance to class method r=baku
authorKarl Tomlinson <karlt+@karlt.net>
Wed, 25 Mar 2020 00:51:50 +0000
changeset 520320 7f6291f3e3912dc663d8247ddef7717611852167
parent 520319 6427a6469f454ae46170a448b03b9edf7886a23c
child 520321 6c87d6b5244012f70f72bc3f625a6b5aeb92e0de
push id37247
push userbtara@mozilla.com
push dateWed, 25 Mar 2020 09:34:57 +0000
treeherdermozilla-central@2abd352490a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1492011
milestone76.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 1492011 change CreateStartTimerValue and CreateLogOrEndTimerValue from instance to class method r=baku Differential Revision: https://phabricator.services.mozilla.com/D67997
dom/console/Console.cpp
dom/console/Console.h
--- a/dom/console/Console.cpp
+++ b/dom/console/Console.cpp
@@ -2108,19 +2108,20 @@ Console::TimerStatus Console::StartTimer
     return eTimerAlreadyExists;
   }
   entry.OrInsert([&aTimestamp]() { return aTimestamp; });
 
   *aTimerValue = aTimestamp;
   return eTimerDone;
 }
 
+/* static */
 JS::Value Console::CreateStartTimerValue(JSContext* aCx,
                                          const nsAString& aTimerLabel,
-                                         TimerStatus aTimerStatus) const {
+                                         TimerStatus aTimerStatus) {
   MOZ_ASSERT(aTimerStatus != eTimerUnknown);
 
   if (aTimerStatus != eTimerDone) {
     return CreateTimerError(aCx, aTimerLabel, aTimerStatus);
   }
 
   RootedDictionary<ConsoleTimerStart> timer(aCx);
 
@@ -2170,38 +2171,40 @@ Console::TimerStatus Console::LogTimer(J
       return eTimerDoesntExist;
     }
   }
 
   *aTimerDuration = aTimestamp - value;
   return eTimerDone;
 }
 
+/* static */
 JS::Value Console::CreateLogOrEndTimerValue(JSContext* aCx,
                                             const nsAString& aLabel,
                                             double aDuration,
-                                            TimerStatus aStatus) const {
+                                            TimerStatus aStatus) {
   if (aStatus != eTimerDone) {
     return CreateTimerError(aCx, aLabel, aStatus);
   }
 
   RootedDictionary<ConsoleTimerLogOrEnd> timer(aCx);
   timer.mName = aLabel;
   timer.mDuration = aDuration;
 
   JS::Rooted<JS::Value> value(aCx);
   if (!ToJSValue(aCx, timer, &value)) {
     return JS::UndefinedValue();
   }
 
   return value;
 }
 
+/* static */
 JS::Value Console::CreateTimerError(JSContext* aCx, const nsAString& aLabel,
-                                    TimerStatus aStatus) const {
+                                    TimerStatus aStatus) {
   MOZ_ASSERT(aStatus != eTimerUnknown && aStatus != eTimerDone);
 
   RootedDictionary<ConsoleTimerError> error(aCx);
 
   error.mName = aLabel;
 
   switch (aStatus) {
     case eTimerAlreadyExists:
--- a/dom/console/Console.h
+++ b/dom/console/Console.h
@@ -257,18 +257,18 @@ class Console final : public nsIObserver
     eTimerUnknown,
     eTimerDone,
     eTimerAlreadyExists,
     eTimerDoesntExist,
     eTimerJSException,
     eTimerMaxReached,
   };
 
-  JS::Value CreateTimerError(JSContext* aCx, const nsAString& aTimerLabel,
-                             TimerStatus aStatus) const;
+  static JS::Value CreateTimerError(JSContext* aCx, const nsAString& aLabel,
+                                    TimerStatus aStatus);
 
   // StartTimer is called on the owning thread and populates aTimerLabel and
   // aTimerValue.
   // * aCx - the JSContext rooting aName.
   // * aName - this is (should be) the name of the timer as JS::Value.
   // * aTimestamp - the monotonicTimer for this context taken from
   //                performance.now().
   // * aTimerLabel - This label will be populated with the aName converted to a
@@ -281,18 +281,19 @@ class Console final : public nsIObserver
 
   // CreateStartTimerValue generates a ConsoleTimerStart dictionary exposed as
   // JS::Value. If aTimerStatus is false, it generates a ConsoleTimerError
   // instead. It's called only after the execution StartTimer on the owning
   // thread.
   // * aCx - this is the context that will root the returned value.
   // * aTimerLabel - this label must be what StartTimer received as aTimerLabel.
   // * aTimerStatus - the return value of StartTimer.
-  JS::Value CreateStartTimerValue(JSContext* aCx, const nsAString& aTimerLabel,
-                                  TimerStatus aTimerStatus) const;
+  static JS::Value CreateStartTimerValue(JSContext* aCx,
+                                         const nsAString& aTimerLabel,
+                                         TimerStatus aTimerStatus);
 
   // LogTimer follows the same pattern as StartTimer: it runs on the
   // owning thread and populates aTimerLabel and aTimerDuration, used by
   // CreateLogOrEndTimerValue.
   // * aCx - the JSContext rooting aName.
   // * aName - this is (should be) the name of the timer as JS::Value.
   // * aTimestamp - the monotonicTimer for this context taken from
   //                performance.now().
@@ -306,20 +307,20 @@ class Console final : public nsIObserver
                        double* aTimerDuration, bool aCancelTimer);
 
   // This method generates a ConsoleTimerEnd dictionary exposed as JS::Value, or
   // a ConsoleTimerError dictionary if aTimerStatus is false. See LogTimer.
   // * aCx - this is the context that will root the returned value.
   // * aTimerLabel - this label must be what LogTimer received as aTimerLabel.
   // * aTimerDuration - this is what LogTimer received as aTimerDuration
   // * aTimerStatus - the return value of LogTimer.
-  JS::Value CreateLogOrEndTimerValue(JSContext* aCx,
-                                     const nsAString& aTimerLabel,
-                                     double aTimerDuration,
-                                     TimerStatus aTimerStatus) const;
+  static JS::Value CreateLogOrEndTimerValue(JSContext* aCx,
+                                            const nsAString& aLabel,
+                                            double aDuration,
+                                            TimerStatus aStatus);
 
   // The method populates a Sequence from an array of JS::Value.
   bool ArgumentsToValueList(const Sequence<JS::Value>& aData,
                             Sequence<JS::Value>& aSequence) const;
 
   // This method follows the same pattern as StartTimer: its runs on the owning
   // thread and populate aCountLabel, used by CreateCounterOrResetCounterValue.
   // Returns 3 possible values: