Bug 1191336 - Part 1 - Don't show the datachoices infobar when sending deletion pings. r=gfritzsche
authorAlessio Placitelli <alessio.placitelli@gmail.com>
Thu, 06 Aug 2015 09:00:00 +0200
changeset 288656 20565e58ac99bbfc05a23b1a05f9bab8b2d21087
parent 288655 03f3c300a156707097fa47b8e4ab539e93fb565f
child 288657 f63aa8d0a399d02aed164a2b524416fcd60b4902
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1191336
milestone42.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 1191336 - Part 1 - Don't show the datachoices infobar when sending deletion pings. r=gfritzsche
toolkit/components/telemetry/TelemetrySend.jsm
--- a/toolkit/components/telemetry/TelemetrySend.jsm
+++ b/toolkit/components/telemetry/TelemetrySend.jsm
@@ -108,16 +108,30 @@ function isV4PingFormat(aPing) {
  * Check if the provided ping is a deletion ping.
  * @param {Object} aPing The ping to check.
  * @return {Boolean} True if the ping is a deletion ping, false otherwise.
  */
 function isDeletionPing(aPing) {
   return isV4PingFormat(aPing) && (aPing.type == PING_TYPE_DELETION);
 }
 
+/**
+ * Save the provided ping as a pending ping. If it's a deletion ping, save it
+ * to a special location.
+ * @param {Object} aPing The ping to save.
+ * @return {Promise} A promise resolved when the ping is saved.
+ */
+function savePing(aPing) {
+  if (isDeletionPing(aPing)) {
+    return TelemetryStorage.saveDeletionPing(aPing);
+  } else {
+    return TelemetryStorage.savePendingPing(aPing);
+  }
+}
+
 function tomorrow(date) {
   let d = new Date(date);
   d.setDate(d.getDate() + 1);
   return d;
 }
 
 /**
  * @return {String} This returns a string with the gzip compressed data.
@@ -668,17 +682,17 @@ let TelemetrySendImpl = {
       this._log.trace("submitPing - Telemetry is not allowed to send pings.");
       return Promise.resolve();
     }
 
     if (!this.canSendNow) {
       // Sending is disabled or throttled, add this to the persisted pending pings.
       this._log.trace("submitPing - can't send ping now, persisting to disk - " +
                       "canSendNow: " + this.canSendNow);
-      return TelemetryStorage.savePendingPing(ping);
+      return savePing(ping);
     }
 
     // Let the scheduler trigger sending pings if possible.
     // As a safety mechanism, this resets any currently active throttling.
     this._log.trace("submitPing - can send pings, trying to send now");
     this._currentPings.set(ping.id, ping);
     SendScheduler.triggerSendingPings(true);
     return Promise.resolve();
@@ -711,21 +725,17 @@ let TelemetrySendImpl = {
     for (let current of currentPings) {
       let ping = current;
       let p = Task.spawn(function*() {
         try {
           yield this._doPing(ping, ping.id, false);
         } catch (ex) {
           this._log.info("sendPings - ping " + ping.id + " not sent, saving to disk", ex);
           // Deletion pings must be saved to a special location.
-          if (isDeletionPing(ping)) {
-            yield TelemetryStorage.saveDeletionPing(ping);
-          } else {
-            yield TelemetryStorage.savePendingPing(ping);
-          }
+          yield savePing(ping);
         } finally {
           this._currentPings.delete(ping.id);
         }
       }.bind(this));
 
       this._trackPendingPingTask(p);
       pingSends.push(p);
     }
@@ -1017,17 +1027,17 @@ let TelemetrySendImpl = {
     })];
     p.push(SendScheduler.waitOnSendTask());
     return Promise.all(p);
   },
 
   _persistCurrentPings: Task.async(function*() {
     for (let [id, ping] of this._currentPings) {
       try {
-        yield TelemetryStorage.savePendingPing(ping);
+        yield savePing(ping);
         this._log.trace("_persistCurrentPings - saved ping " + id);
       } catch (ex) {
         this._log.error("_persistCurrentPings - failed to save ping " + id, ex);
       } finally {
         this._currentPings.delete(id);
       }
     }
   }),