bug 1405299 - Do not attempt to upload pings if sending is not yet enabled r=Dexter
authorChris H-C <chutten@mozilla.com>
Wed, 11 Oct 2017 16:22:14 -0400
changeset 385889 0fd360d7ba33e0f46406815b28d01ce466c2cfff
parent 385888 f2390464f1ef86d3a53e11ec20c038e9b9281606
child 385890 52a05ad77fa54d8271a6217512e1fe4d55ea6041
push id32672
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 09:00:05 +0000
treeherdermozilla-central@3efcb26e5f37 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersDexter
bugs1405299
milestone58.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 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();
   },