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/. */
7 this.EXPORTED_SYMBOLS = [
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,
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,
43 this.UpdateProvider = function () {
44 Metrics.Provider.call(this);
46 UpdateProvider.prototype = Object.freeze({
47 __proto__: Metrics.Provider.prototype,
49 name: "org.mozilla.update",
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);