Bug 1118839 - Add telemetry to measure the number of saved passwords for a user. r=dolske
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 16 Jan 2015 13:08:29 -0800
changeset 224337 e41cbd7c6973080b316cf4b536c5b4958848b5d4
parent 224336 4bb30ec57818382e86ef1a2e1f9488e597318138
child 224338 dceee642eec766ba05739f85d61e1c9b895282cb
push id54190
push userkwierso@gmail.com
push dateSat, 17 Jan 2015 02:06:29 +0000
treeherdermozilla-inbound@369a8f14ccf8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske
bugs1118839
milestone38.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 1118839 - Add telemetry to measure the number of saved passwords for a user. r=dolske
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
@@ -7144,10 +7144,18 @@
     "description": "Stumbler: The time between receiving passive locations."
   },
   "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"
   }
 }