Bug 1118839 - Add telemetry to measure the number of saved passwords for a user. r=dolske, a=lmandel
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 16 Jan 2015 13:08:29 -0800
changeset 249665 bfd779b9caceda47293d5b1bd9d117271e64ba53
parent 249664 6719a2a150860e316a67fdd1783deb8648044f52
child 249666 507228e928da97e617f2fbc8db4bc119ea8c5c98
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, lmandel
bugs1118839
milestone37.0a2
Bug 1118839 - Add telemetry to measure the number of saved passwords for a user. r=dolske, a=lmandel
toolkit/components/passwordmgr/nsLoginManager.js
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -71,17 +71,17 @@ LoginManager.prototype = {
             // Allows unwrapping the JavaScript object for regression tests.
             return this;
         }
 
         throw Cr.NS_ERROR_NO_INTERFACE;
     },
 
 
-    /* ---------- private memebers ---------- */
+    /* ---------- private members ---------- */
 
 
     __formFillService : null, // FormFillController, for username autocompleting
     get _formFillService() {
         if (!this.__formFillService)
             this.__formFillService =
                             Cc["@mozilla.org/satchel/form-fill-controller;1"].
                             getService(Ci.nsIFormFillController);
@@ -125,16 +125,18 @@ LoginManager.prototype = {
         if (Services.appinfo.processType ===
             Services.appinfo.PROCESS_TYPE_DEFAULT) {
             Services.obs.addObserver(this._observer, "passwordmgr-storage-replace",
                                      false);
 
             // Initialize storage so that asynchronous data loading can start.
             this._initStorage();
         }
+
+        Services.obs.addObserver(this._observer, "gather-telemetry", false);
     },
 
 
     _initStorage : function () {
 #ifdef ANDROID
         var contractID = "@mozilla.org/login-manager/storage/mozStorage;1";
 #else
         var contractID = "@mozilla.org/login-manager/storage/json;1";
@@ -193,22 +195,30 @@ LoginManager.prototype = {
             } else if (topic == "passwordmgr-storage-replace") {
                 Task.spawn(function () {
                   yield this._pwmgr._storage.terminate();
                   this._pwmgr._initStorage();
                   yield this._pwmgr.initializationPromise;
                   Services.obs.notifyObservers(null,
                                "passwordmgr-storage-replace-complete", null);
                 }.bind(this));
+            } else if (topic == "gather-telemetry") {
+                this._pwmgr._gatherTelemetry();
             } else {
                 log("Oops! Unexpected notification:", topic);
             }
         }
     },
 
+    _gatherTelemetry : function() {
+      let numPasswordsHist = Services.telemetry.getHistogramById("PWMGR_NUM_SAVED_PASSWORDS");
+      numPasswordsHist.clear();
+      numPasswordsHist.add(this.countLogins("", "", ""));
+    },
+
 
 
 
 
     /* ---------- Primary Public interfaces ---------- */
 
 
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7153,16 +7153,24 @@
   },
   "DATA_STORAGE_ENTRIES": {
     "expires_in_version": "default",
     "kind": "linear",
     "high": "1024",
     "n_buckets": 16,
     "description": "The number of entries in persistent DataStorage (HSTS and HPKP data, basically)"
   },
+  "PWMGR_NUM_SAVED_PASSWORDS": {
+    "expires_in_version": "never",
+    "kind": "exponential",
+    "high": 750,
+    "n_buckets" : 50,
+    "extended_statistics_ok": true,
+    "description": "The number of saved signons in storage"
+  },
   "FENNEC_SYNC11_MIGRATION_SENTINELS_SEEN": {
     "expires_in_version": "45",
     "kind": "count",
     "description": "The number of Sync 1.1 -> Sync 1.5 migration sentinels seen by Android Sync."
   },
   "FENNEC_SYNC11_MIGRATIONS_FAILED": {
     "expires_in_version": "45",
     "kind": "count",