Bumping manifests a=b2g-bump
[gecko.git] / toolkit / mozapps / update / UpdaterHealthProvider.jsm
blobd15e0cf86d9009bb34924ea3df90764747a7297a
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 "use strict";
7 this.EXPORTED_SYMBOLS = [
8   "UpdateProvider",
9 ];
11 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
13 Cu.import("resource://gre/modules/Metrics.jsm", this);
14 Cu.import("resource://gre/modules/Task.jsm", this);
16 const DAILY_COUNTER_FIELD = {type: Metrics.Storage.FIELD_DAILY_COUNTER};
17 const DAILY_DISCRETE_NUMERIC_FIELD = {type: Metrics.Storage.FIELD_DAILY_DISCRETE_NUMERIC};
19 function UpdateMeasurement1() {
20   Metrics.Measurement.call(this);
23 UpdateMeasurement1.prototype = Object.freeze({
24   __proto__: Metrics.Measurement.prototype,
26   name: "update",
27   version: 1,
29   fields: {
30     updateCheckStartCount: DAILY_COUNTER_FIELD,
31     updateCheckSuccessCount: DAILY_COUNTER_FIELD,
32     updateCheckFailedCount: DAILY_COUNTER_FIELD,
33     updateCheckFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
34     completeUpdateStartCount: DAILY_COUNTER_FIELD,
35     partialUpdateStartCount: DAILY_COUNTER_FIELD,
36     completeUpdateSuccessCount: DAILY_COUNTER_FIELD,
37     partialUpdateSuccessCount: DAILY_COUNTER_FIELD,
38     updateFailedCount: DAILY_COUNTER_FIELD,
39     updateFailedStatuses: DAILY_DISCRETE_NUMERIC_FIELD,
40   },
41 });
43 this.UpdateProvider = function () {
44   Metrics.Provider.call(this);
46 UpdateProvider.prototype = Object.freeze({
47   __proto__: Metrics.Provider.prototype,
49   name: "org.mozilla.update",
51   measurementTypes: [
52     UpdateMeasurement1,
53   ],
55   recordUpdate: function (field, status) {
56     let m = this.getMeasurement(UpdateMeasurement1.prototype.name,
57                                 UpdateMeasurement1.prototype.version);
59     return this.enqueueStorageOperation(function recordUpdateFields() {
60       return Task.spawn(function recordUpdateFieldsTask() {
61         yield m.incrementDailyCounter(field + "Count");
63         if ((field == "updateFailed" || field == "updateCheckFailed") && status) {
64           yield m.addDailyDiscreteNumeric(field + "Statuses", status);
65         }
66       }.bind(this));
67     }.bind(this));
68   },
69 });