Remove FHR from app update Bug 1121018 - FHR data migration: org.mozilla.update. r=spohl
authorRobert Strong <robert.bugzilla@gmail.com>
Sat, 28 Mar 2015 20:20:38 -0700
changeset 266729 3de12fe1b92743951aeb66ab08a2b05f0b0a2487
parent 266728 99c3baae746dab74dee6bee92173621ce20b4dc1
child 266730 5c7b6c34ec5c70117d3e382825d3231812f63520
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1121018
milestone39.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
Remove FHR from app update Bug 1121018 - FHR data migration: org.mozilla.update. r=spohl
toolkit/mozapps/update/UpdaterHealthProvider.jsm
toolkit/mozapps/update/moz.build
toolkit/mozapps/update/nsUpdateService.js
toolkit/mozapps/update/tests/unit_aus_update/updateHealthReport.js
toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini
deleted file mode 100644
--- a/toolkit/mozapps/update/UpdaterHealthProvider.jsm
+++ /dev/null
@@ -1,69 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = [
-  "UpdateProvider",
-];
-
-const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
-
-Cu.import("resource://gre/modules/Metrics.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
-
-const DAILY_COUNTER_FIELD = {type: Metrics.Storage.FIELD_DAILY_COUNTER};
-const DAILY_DISCRETE_NUMERIC_FIELD = {type: Metrics.Storage.FIELD_DAILY_DISCRETE_NUMERIC};
-
-function UpdateMeasurement1() {
-  Metrics.Measurement.call(this);
-}
-
-UpdateMeasurement1.prototype = Object.freeze({
-  __proto__: Metrics.Measurement.prototype,
-
-  name: "update",
-  version: 1,
-
-  fields: {
-    updateCheckStartCount: DAILY_COUNTER_FIELD,
-    updateCheckSuccessCount: DAILY_COUNTER_FIELD,
-    updateCheckFailedCount: DAILY_COUNTER_FIELD,
-    updateCheckFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
-    completeUpdateStartCount: DAILY_COUNTER_FIELD,
-    partialUpdateStartCount: DAILY_COUNTER_FIELD,
-    completeUpdateSuccessCount: DAILY_COUNTER_FIELD,
-    partialUpdateSuccessCount: DAILY_COUNTER_FIELD,
-    updateFailedCount: DAILY_COUNTER_FIELD,
-    updateFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
-  },
-});
-
-this.UpdateProvider = function () {
-  Metrics.Provider.call(this);
-};
-UpdateProvider.prototype = Object.freeze({
-  __proto__: Metrics.Provider.prototype,
-
-  name: "org.mozilla.update",
-
-  measurementTypes: [
-    UpdateMeasurement1,
-  ],
-
-  recordUpdate: function (field, status) {
-    let m = this.getMeasurement(UpdateMeasurement1.prototype.name,
-                                UpdateMeasurement1.prototype.version);
-
-    return this.enqueueStorageOperation(function recordUpdateFields() {
-      return Task.spawn(function recordUpdateFieldsTask() {
-        yield m.incrementDailyCounter(field + "Count");
-
-        if ((field == "updateFailed" || field == "updateCheckFailed") && status) {
-          yield m.addDailyDiscreteNumeric(field + "Statuses", status);
-        }
-      }.bind(this));
-    }.bind(this));
-  },
-});
--- a/toolkit/mozapps/update/moz.build
+++ b/toolkit/mozapps/update/moz.build
@@ -41,13 +41,9 @@ if CONFIG['MOZ_UPDATER']:
         'nsUpdateService.manifest',
         'nsUpdateServiceStub.js',
     ]
 
     EXTRA_PP_COMPONENTS += [
         'nsUpdateService.js',
     ]
 
-    EXTRA_JS_MODULES += [
-      'UpdaterHealthProvider.jsm'
-    ]
-
 JAR_MANIFESTS += ['jar.mn']
--- a/toolkit/mozapps/update/nsUpdateService.js
+++ b/toolkit/mozapps/update/nsUpdateService.js
@@ -7,19 +7,16 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/FileUtils.jsm");
 Components.utils.import("resource://gre/modules/AddonManager.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/ctypes.jsm");
-#ifdef MOZ_SERVICES_HEALTHREPORT
-Components.utils.import("resource://gre/modules/UpdaterHealthProvider.jsm");
-#endif
 
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const Cr = Components.results;
 const Cu = Components.utils;
 
 const UPDATESERVICE_CID = Components.ID("{B3C290A6-3943-4B89-8BBE-C01EB7B3B311}");
 const UPDATESERVICE_CONTRACTID = "@mozilla.org/updates/update-service;1";
@@ -256,28 +253,16 @@ const PING_BGUC_ADDON_PREF_DISABLED     
 const PING_BGUC_ADDON_SAME_APP_VER           = 27;
 // No incompatible add-ons found during incompatible check (background download)
 const PING_BGUC_CHECK_NO_INCOMPAT            = 28;
 // Incompatible add-ons found and all of them have updates (background download)
 const PING_BGUC_ADDON_UPDATES_FOR_INCOMPAT   = 29;
 // Incompatible add-ons found (update notification)
 const PING_BGUC_ADDON_HAVE_INCOMPAT          = 30;
 
-// Health report field names
-const UpdaterHealthReportFields = {
-  CHECK_START: "updateCheckStart",
-  CHECK_SUCCESS: "updateCheckSuccess",
-  CHECK_FAILED: "updateCheckFailed",
-  COMPLETE_START: "completeUpdateStart",
-  PARTIAL_START: "partialUpdateStart",
-  COMPLETE_SUCCESS: "completeUpdateSuccess",
-  PARTIAL_SUCCESS: "partialUpdateSuccess",
-  FAILED: "updateFailed"
-};
-
 var gLocale = null;
 var gUpdateMutexHandle = null;
 
 #ifdef MOZ_WIDGET_GONK
 var gSDCardMountLock = null;
 
 XPCOMUtils.defineLazyGetter(this, "gExtStorage", function aus_gExtStorage() {
     return Services.env.get("EXTERNAL_STORAGE");
@@ -960,47 +945,16 @@ function getStatusTextFromCode(code, def
     reason = gUpdateBundle.GetStringFromName("check_error-" + defaultCode);
     LOG("getStatusTextFromCode - transfer error: " + reason +
         ", default code: " + defaultCode);
   }
   return reason;
 }
 
 /**
- * Record count in the health report.
- * @param field
- *        The field name to record
- * @param status
- *        Status code for errors, 0 otherwise
- */
-function recordInHealthReport(field, status) {
-#ifdef MOZ_SERVICES_HEALTHREPORT
-  try {
-    LOG("recordInHealthReport - " + field + " - " + status);
-
-    let reporter = Cc["@mozilla.org/datareporting/service;1"]
-                      .getService().wrappedJSObject.healthReporter;
-
-    if (reporter) {
-      reporter.onInit().then(function recordUpdateInHealthReport() {
-        try {
-          reporter.getProvider("org.mozilla.update").recordUpdate(field, status);
-        } catch (ex) {
-          Cu.reportError(ex);
-        }
-      });
-    }
-  // If getting the heath reporter service fails, don't fail updating.
-  } catch (ex) {
-    LOG("recordInHealthReport - could not initialize health reporter");
-  }
-#endif
-}
-
-/**
  * Get the Active Updates directory
  * @return The active updates directory, as a nsIFile object
  */
 function getUpdatesDir() {
   // Right now, we only support downloading one patch at a time, so we always
   // use the same target directory.
   return getUpdateDirCreate([DIR_UPDATES, "0"]);
 }
@@ -3716,18 +3670,16 @@ Checker.prototype = {
       throw Cr.NS_ERROR_NULL_POINTER;
 
     Services.obs.notifyObservers(null, "update-check-start", null);
 
     var url = this.getUpdateURL(force);
     if (!url || (!this.enabled && !force))
       return;
 
-    recordInHealthReport(UpdaterHealthReportFields.CHECK_START, 0);
-
     this._request = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].
                     createInstance(Ci.nsISupports);
     // This is here to let unit test code override XHR
     if (this._request.wrappedJSObject) {
       this._request = this._request.wrappedJSObject;
     }
     this._request.open("GET", url, true);
     var allowNonBuiltIn = !getPref("getBoolPref",
@@ -3841,18 +3793,16 @@ Checker.prototype = {
       gCertUtils.checkCert(this._request.channel, allowNonBuiltIn, certs);
 
       if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_CERT_ERRORS))
         Services.prefs.clearUserPref(PREF_APP_UPDATE_CERT_ERRORS);
 
       if (Services.prefs.prefHasUserValue(PREF_APP_UPDATE_BACKGROUNDERRORS))
         Services.prefs.clearUserPref(PREF_APP_UPDATE_BACKGROUNDERRORS);
 
-      recordInHealthReport(UpdaterHealthReportFields.CHECK_SUCCESS, 0);
-
       // Tell the callback about the updates
       this._callback.onCheckComplete(event.target, updates, updates.length);
     }
     catch (e) {
       LOG("Checker:onLoad - there was a problem checking for updates. " +
           "Exception: " + e);
       var request = event.target;
       var status = this._getChannelStatus(request);
@@ -3864,18 +3814,16 @@ Checker.prototype = {
       if (this._isHttpStatusCode(status)) {
         update.errorCode = HTTP_ERROR_OFFSET + status;
       }
       if (e.result && e.result == Cr.NS_ERROR_ILLEGAL_VALUE) {
         update.errorCode = updates[0] ? CERT_ATTR_CHECK_FAILED_HAS_UPDATE
                                       : CERT_ATTR_CHECK_FAILED_NO_UPDATE;
       }
 
-      recordInHealthReport(UpdaterHealthReportFields.CHECK_FAILED, update.errorCode);
-
       this._callback.onError(request, update);
     }
 
     this._callback = null;
     this._request = null;
   },
 
   /**
@@ -3897,20 +3845,17 @@ Checker.prototype = {
 
     if (status == Cr.NS_ERROR_OFFLINE) {
       // We use a separate constant here because nsIUpdate.errorCode is signed
       update.errorCode = NETWORK_ERROR_OFFLINE;
     } else if (this._isHttpStatusCode(status)) {
       update.errorCode = HTTP_ERROR_OFFSET + status;
     }
 
-    recordInHealthReport(UpdaterHealthReportFields.CHECK_FAILED, update.errorCode);
-
     this._callback.onError(request, update);
-
     this._request = null;
   },
 
   /**
    * Whether or not we are allowed to do update checking.
    */
   _enabled: true,
   get enabled() {
@@ -4216,20 +4161,16 @@ Downloader.prototype = {
     // to download.
     this._patch = this._selectPatch(update, updateDir);
     if (!this._patch) {
       LOG("Downloader:downloadUpdate - no patch to download");
       return readStatusFile(updateDir);
     }
     this.isCompleteUpdate = this._patch.type == "complete";
 
-    recordInHealthReport(
-      this.isCompleteUpdate ? UpdaterHealthReportFields.COMPLETE_START :
-                              UpdaterHealthReportFields.PARTIAL_START, 0);
-
     var patchFile = null;
 
 #ifdef MOZ_WIDGET_GONK
     let status = readStatusFile(updateDir);
     if (isInterruptedUpdate(status)) {
       LOG("Downloader:downloadUpdate - interruptted update");
       // The update was interrupted. Try to locate the existing patch file.
       // For an interrupted download, this allows a resume rather than a
@@ -4475,20 +4416,16 @@ Downloader.prototype = {
     var retryTimeout = getPref("getIntPref", PREF_APP_UPDATE_RETRY_TIMEOUT,
                                DEFAULT_UPDATE_RETRY_TIMEOUT);
     var maxFail = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_ERRORS,
                           DEFAULT_SOCKET_MAX_ERRORS);
     LOG("Downloader:onStopRequest - status: " + status + ", " +
         "current fail: " + this.updateService._consecutiveSocketErrors + ", " +
         "max fail: " + maxFail + ", " + "retryTimeout: " + retryTimeout);
     if (Components.isSuccessCode(status)) {
-      recordInHealthReport(
-        this.isCompleteUpdate ? UpdaterHealthReportFields.COMPLETE_SUCCESS :
-                                UpdaterHealthReportFields.PARTIAL_SUCCESS, 0);
-
       if (this._verifyDownload()) {
         state = shouldUseService() ? STATE_PENDING_SVC : STATE_PENDING;
         if (this.background) {
           shouldShowPrompt = !getCanStageUpdates();
         }
 
         // Tell the updater.exe we're ready to apply.
         writeStatusFile(getUpdatesDir(), state);
@@ -4508,18 +4445,16 @@ Downloader.prototype = {
 
         if (this._update.isCompleteUpdate || this._update.patchCount != 2)
           deleteActiveUpdate = true;
 
         // Destroy the updates directory, since we're done with it.
         cleanUpUpdatesDir();
       }
     } else {
-      recordInHealthReport(UpdaterHealthReportFields.FAILED, status);
-
       if (status == Cr.NS_ERROR_OFFLINE) {
         // Register an online observer to try again.
         // The online observer will continue the incremental download by
         // calling downloadUpdate on the active update which continues
         // downloading the file from where it was.
         LOG("Downloader:onStopRequest - offline, register online observer: true");
         shouldRegisterOnlineObserver = true;
         deleteActiveUpdate = false;
deleted file mode 100644
--- a/toolkit/mozapps/update/tests/unit_aus_update/updateHealthReport.js
+++ /dev/null
@@ -1,88 +0,0 @@
-/* Any copyright is dedicated to the Public Domain.
- * http://creativecommons.org/publicdomain/zero/1.0/ */
-
-"use strict";
-
-Cu.import("resource://gre/modules/Metrics.jsm");
-Cu.import("resource://gre/modules/UpdaterHealthProvider.jsm");
-
-// Create a profile
-let gProfile = do_get_profile();
-
-function run_test() {
-  run_next_test();
-}
-
-add_test(function test_constructor() {
-  let provider = new UpdateProvider();
-  run_next_test();
-});
-
-add_task(function test_init() {
-  let storage = yield Metrics.Storage("init");
-  let provider = new UpdateProvider();
-  yield provider.init(storage);
-  yield provider.shutdown();
-
-  yield storage.close();
-});
-
-add_task(function test_collect() {
-  let storage = yield Metrics.Storage("collect");
-  let provider = new UpdateProvider();
-  yield provider.init(storage);
-
-  let now = new Date();
-
-  let m = provider.getMeasurement("update", 1);
-
-  let fieldcount = 0;
-  for (let field of ["updateCheckStart",
-                     "updateCheckSuccess",
-                     "completeUpdateStart",
-                     "partialUpdateStart",
-                     "completeUpdateSuccess",
-                     "partialUpdateSuccess"]) {
-    fieldcount++; // One new day per iteration
-
-    yield provider.recordUpdate(field, 0);
-
-    let data = yield m.getValues();
-    do_check_eq(data.days.size, 1);
-
-    let day = data.days.getDay(now);
-    do_check_eq(day.size, fieldcount);
-    do_check_eq(day.get(field + "Count"), 1);
-
-    yield provider.recordUpdate(field, 0);
-
-    data = yield m.getValues();
-    day = data.days.getDay(now);
-    do_check_eq(day.size, fieldcount);
-    do_check_eq(day.get(field + "Count"), 2);
-  }
-
-  for (let field of ["updateCheckFailed", "updateFailed"]) {
-    fieldcount += 2; // Two fields added per iteration
-
-    yield provider.recordUpdate(field, 500);
-
-    let data = yield m.getValues();
-    let day = data.days.getDay(now);
-    do_check_eq(day.size, fieldcount);
-
-    do_check_eq(day.get(field + "Statuses"), 500);
-
-    yield provider.recordUpdate(field, 800);
-
-    data = yield m.getValues();
-    day = data.days.getDay(now);
-    do_check_eq(day.size, fieldcount);
-    do_check_eq(day.get(field + "Statuses")[0], 500);
-    do_check_eq(day.get(field + "Statuses")[1], 800);
-  }
-
-  yield provider.shutdown();
-  yield storage.close();
-});
-
--- a/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini
+++ b/toolkit/mozapps/update/tests/unit_aus_update/xpcshell.ini
@@ -32,10 +32,8 @@ skip-if = toolkit != 'gonk'
 skip-if = toolkit == 'gonk'
 reason = custom nsIUpdatePrompt
 [uiOnlyAllowOneWindow.js]
 skip-if = toolkit == 'gonk'
 reason = custom nsIUpdatePrompt
 [uiUnsupportedAlreadyNotified.js]
 skip-if = toolkit == 'gonk'
 reason = custom nsIUpdatePrompt
-[updateHealthReport.js]
-skip-if = ! healthreport