bug 1405299 - Do not attempt to upload pings if sending is not yet enabled r?Dexter draft
authorChris H-C <chutten@mozilla.com>
Wed, 11 Oct 2017 16:22:14 -0400
changeset 679414 8608d37e20f6a8b0bc4e95b685e8f7feb00ea052
parent 679413 4538f6c52f315344c700e4df6a11b8e0bad5808a
child 735598 7228a13f1a74fe16ed1f737aa7cb890bdd91bde5
push id84219
push userbmo:chutten@mozilla.com
push dateThu, 12 Oct 2017 17:03:51 +0000
reviewersDexter
bugs1405299
milestone58.0a1
bug 1405299 - Do not attempt to upload pings if sending is not yet enabled r?Dexter TelemetrySend may at any time be notified it can upload. This includes before when setup() is called. Since setup will attempt to upload when it runs, we can safely ignore a too-early notify. MozReview-Commit-ID: 9aeYitCpcIJ
toolkit/components/telemetry/TelemetrySend.jsm
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -648,22 +648,22 @@ var TelemetrySendImpl = {
   },
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference]),
 
   async setup(testing) {
     this._log.trace("setup");
 
     this._testMode = testing;
-    this._sendingEnabled = true;
 
     Services.obs.addObserver(this, TOPIC_IDLE_DAILY);
     Services.obs.addObserver(this, TOPIC_PROFILE_CHANGE_NET_TEARDOWN);
 
     this._server = Services.prefs.getStringPref(TelemetryUtils.Preferences.Server, undefined);
+    this._sendingEnabled = true;
 
     // Annotate crash reports so that crash pings are sent correctly and listen
     // to pref changes to adjust the annotations accordingly.
     for (let pref of this.OBSERVED_PREFERENCES) {
       Services.prefs.addObserver(pref, this, true);
     }
     this._annotateCrashReport();
 
@@ -792,16 +792,20 @@ var TelemetrySendImpl = {
 
     return SendScheduler.reset();
   },
 
   /**
    * Notify that we can start submitting data to the servers.
    */
   notifyCanUpload() {
+    if (!this._sendingEnabled) {
+      this._log.trace("notifyCanUpload - notifying before sending is enabled. Ignoring.");
+      return Promise.resolve();
+    }
     // Let the scheduler trigger sending pings if possible, also inform the
     // crash reporter that it can send crash pings if appropriate.
     SendScheduler.triggerSendingPings(true);
     this._annotateCrashReport();
 
     return this.promisePendingPingActivity();
   },