Blob Blame History Raw
diff -up mozilla-esr24/xpcom/ds/TimeStamp.cpp.906754 mozilla-esr24/xpcom/ds/TimeStamp.cpp
--- mozilla-esr24/xpcom/ds/TimeStamp.cpp.906754	2013-12-06 03:21:33.000000000 +0100
+++ mozilla-esr24/xpcom/ds/TimeStamp.cpp	2013-12-20 16:11:06.607243958 +0100
@@ -13,15 +13,41 @@
 
 namespace mozilla {
 
-TimeStamp TimeStamp::sFirstTimeStamp;
-TimeStamp TimeStamp::sProcessCreation;
+/**
+ * Wrapper class used to initialize static data used by the TimeStamp class
+ */
+struct TimeStampInitialization {
+  /**
+   * First timestamp taken when the class static initializers are run. This
+   * timestamp is used to sanitize timestamps coming from different sources.
+   */
+  TimeStamp mFirstTimeStamp;
+
+  /**
+   * Timestamp representing the time when the process was created. This field
+   * is populated lazily the first time this information is required and is
+   * replaced every time the process is restarted.
+   */
+  TimeStamp mProcessCreation;
+
+  TimeStampInitialization() {
+    TimeStamp::Startup();
+    mFirstTimeStamp = TimeStamp::Now();
+  };
+
+  ~TimeStampInitialization() {
+    TimeStamp::Shutdown();
+  };
+};
+
+static TimeStampInitialization sInitOnce;
 
 TimeStamp
 TimeStamp::ProcessCreation(bool& aIsInconsistent)
 {
   aIsInconsistent = false;
 
-  if (sProcessCreation.IsNull()) {
+  if (sInitOnce.mProcessCreation.IsNull()) {
     char *mozAppRestart = PR_GetEnv("MOZ_APP_RESTART");
     TimeStamp ts;
 
@@ -31,7 +57,7 @@ TimeStamp::ProcessCreation(bool& aIsInco
     if (mozAppRestart && (strcmp(mozAppRestart, "") != 0)) {
       /* Firefox was restarted, use the first time-stamp we've taken as the new
        * process startup time and unset MOZ_APP_RESTART. */
-      ts = sFirstTimeStamp;
+      ts = sInitOnce.mFirstTimeStamp;
       PR_SetEnv("MOZ_APP_RESTART=");
     } else {
       TimeStamp now = Now();
@@ -39,26 +65,26 @@ TimeStamp::ProcessCreation(bool& aIsInco
 
       ts = now - TimeDuration::FromMicroseconds(uptime);
 
-      if ((ts > sFirstTimeStamp) || (uptime == 0)) {
+      if ((ts > sInitOnce.mFirstTimeStamp) || (uptime == 0)) {
         /* If the process creation timestamp was inconsistent replace it with
          * the first one instead and notify that a telemetry error was
          * detected. */
         aIsInconsistent = true;
-        ts = sFirstTimeStamp;
+        ts = sInitOnce.mFirstTimeStamp;
       }
     }
 
-    sProcessCreation = ts;
+    sInitOnce.mProcessCreation = ts;
   }
 
-  return sProcessCreation;
+  return sInitOnce.mProcessCreation;
 }
 
 void
 TimeStamp::RecordProcessRestart()
 {
   PR_SetEnv("MOZ_APP_RESTART=1");
-  sProcessCreation = TimeStamp();
+  sInitOnce.mProcessCreation = TimeStamp();
 }
 
 } // namespace mozilla
diff -up mozilla-esr24/xpcom/ds/TimeStamp_darwin.cpp.906754 mozilla-esr24/xpcom/ds/TimeStamp_darwin.cpp
--- mozilla-esr24/xpcom/ds/TimeStamp_darwin.cpp.906754	2013-12-06 03:21:33.000000000 +0100
+++ mozilla-esr24/xpcom/ds/TimeStamp_darwin.cpp	2013-12-20 15:58:50.356993425 +0100
@@ -114,18 +114,6 @@ TimeDuration::Resolution()
   return TimeDuration::FromTicks(int64_t(sResolution));
 }
 
-struct TimeStampInitialization
-{
-  TimeStampInitialization() {
-    TimeStamp::Startup();
-  }
-  ~TimeStampInitialization() {
-    TimeStamp::Shutdown();
-  }
-};
-
-static TimeStampInitialization initOnce;
-
 nsresult
 TimeStamp::Startup()
 {
@@ -152,8 +140,6 @@ TimeStamp::Startup()
        sResolutionSigDigs *= 10);
 
   gInitialized = true;
-  sFirstTimeStamp = TimeStamp::Now();
-  sProcessCreation = TimeStamp();
 
   return NS_OK;
 }
diff -up mozilla-esr24/xpcom/ds/TimeStamp.h.906754 mozilla-esr24/xpcom/ds/TimeStamp.h
--- mozilla-esr24/xpcom/ds/TimeStamp.h.906754	2013-12-06 03:21:33.000000000 +0100
+++ mozilla-esr24/xpcom/ds/TimeStamp.h	2013-12-20 15:58:50.356993425 +0100
@@ -363,19 +363,6 @@ private:
    * When using a system clock, a value is system dependent.
    */
   TimeStampValue mValue;
-
-  /**
-   * First timestamp taken when the class static initializers are run. This
-   * timestamp is used to sanitize timestamps coming from different sources.
-   */
-  static TimeStamp sFirstTimeStamp;
-
-  /**
-   * Timestamp representing the time when the process was created. This field
-   * is populated lazily the first time this information is required and is
-   * replaced every time the process is restarted.
-   */
-  static TimeStamp sProcessCreation;
 };
 
 }
diff -up mozilla-esr24/xpcom/ds/TimeStamp_posix.cpp.906754 mozilla-esr24/xpcom/ds/TimeStamp_posix.cpp
--- mozilla-esr24/xpcom/ds/TimeStamp_posix.cpp.906754	2013-12-06 03:21:33.000000000 +0100
+++ mozilla-esr24/xpcom/ds/TimeStamp_posix.cpp	2013-12-20 15:58:50.356993425 +0100
@@ -159,17 +159,6 @@ TimeDuration::Resolution()
   return TimeDuration::FromTicks(int64_t(sResolution));
 }
 
-struct TimeStampInitialization
-{
-  TimeStampInitialization() {
-    TimeStamp::Startup();
-  }
-  ~TimeStampInitialization() {
-    TimeStamp::Shutdown();
-  }
-};
-
-static TimeStampInitialization initOnce;
 static bool gInitialized = false;
 
 nsresult
@@ -192,8 +181,6 @@ TimeStamp::Startup()
        sResolutionSigDigs *= 10);
 
   gInitialized = true;
-  sFirstTimeStamp = TimeStamp::Now();
-  sProcessCreation = TimeStamp();
 
   return NS_OK;
 }
diff -up mozilla-esr24/xpcom/ds/TimeStamp_windows.cpp.906754 mozilla-esr24/xpcom/ds/TimeStamp_windows.cpp
--- mozilla-esr24/xpcom/ds/TimeStamp_windows.cpp.906754	2013-12-06 03:21:33.000000000 +0100
+++ mozilla-esr24/xpcom/ds/TimeStamp_windows.cpp	2013-12-20 15:58:50.357993430 +0100
@@ -457,18 +457,6 @@ TimeDuration::Resolution()
   return TimeDuration::FromTicks(int64_t(sResolution));
 }
 
-struct TimeStampInitialization
-{
-  TimeStampInitialization() {
-    TimeStamp::Startup();
-  }
-  ~TimeStampInitialization() {
-    TimeStamp::Shutdown();
-  }
-};
-
-static TimeStampInitialization initOnce;
-
 static bool
 HasStableTSC()
 {
@@ -534,8 +522,6 @@ TimeStamp::Startup()
 
   InitThresholds();
   InitResolution();
-  sFirstTimeStamp = TimeStamp::Now();
-  sProcessCreation = TimeStamp();
 
   return NS_OK;
 }