Bug 1366147 - SetTarget() should be called once only after the timer is created. draft
authorJW Wang <jwwang@mozilla.com>
Fri, 19 May 2017 11:56:12 +0800
changeset 580900 4bcd6f8f280417e2ad577bbe930cf97a06ccb060
parent 580899 c0743e9dfdf6647fe6a648136ca4e7330724bf8d
child 629425 d133acc7abb7b2af0c4fabc6298d34e1bb833f5e
push id59705
push userjwwang@mozilla.com
push dateFri, 19 May 2017 04:02:33 +0000
bugs1366147
milestone55.0a1
Bug 1366147 - SetTarget() should be called once only after the timer is created. MozReview-Commit-ID: 9kmxzZX8Zfc
toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
--- a/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
+++ b/toolkit/components/telemetry/ipc/TelemetryIPCAccumulator.cpp
@@ -76,19 +76,21 @@ DoArmIPCTimerMainThread(const StaticMute
 {
   MOZ_ASSERT(NS_IsMainThread());
   gIPCTimerArming = false;
   if (gIPCTimerArmed) {
     return;
   }
   if (!gIPCTimer) {
     CallCreateInstance(NS_TIMER_CONTRACTID, &gIPCTimer);
+    if (gIPCTimer) {
+      gIPCTimer->SetTarget(SystemGroup::EventTargetFor(TaskCategory::Other));
+    }
   }
   if (gIPCTimer) {
-    gIPCTimer->SetTarget(SystemGroup::EventTargetFor(TaskCategory::Other));
     gIPCTimer->InitWithNamedFuncCallback(TelemetryIPCAccumulator::IPCTimerFired,
                                          nullptr, kBatchTimeoutMs,
                                          nsITimer::TYPE_ONE_SHOT,
                                          "TelemetryIPCAccumulator::IPCTimerFired");
     gIPCTimerArmed = true;
   }
 }