Bug 1124392 - Telemetry: Record the number of passwords per hostname. r=MattN, a=lmandel
authorChenxia Liu <liuche@mozilla.com>
Mon, 02 Feb 2015 12:51:48 -0800
changeset 240583 af0810842345bacd6e3f5d84a5008f403438e6b3
parent 240582 cc5e2253319997d3d0aa1bc5c3899efc34dcdc08
child 240584 874b03be37f26a0b89a621b3df746a32df0f5eff
push id7597
push userryanvm@gmail.com
push dateTue, 10 Feb 2015 18:12:55 +0000
treeherdermozilla-aurora@10d1df99ba8e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMattN, lmandel
bugs1124392
milestone37.0a2
Bug 1124392 - Telemetry: Record the number of passwords per hostname. r=MattN, a=lmandel
toolkit/components/passwordmgr/nsLoginManager.js
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/passwordmgr/nsLoginManager.js
+++ b/toolkit/components/passwordmgr/nsLoginManager.js
@@ -248,27 +248,36 @@ LoginManager.prototype = {
       return;
     }
 
     let logins = this.getAllLogins({});
 
     let usernamePresentHistogram = clearAndGetHistogram("PWMGR_USERNAME_PRESENT");
     let loginLastUsedDaysHistogram = clearAndGetHistogram("PWMGR_LOGIN_LAST_USED_DAYS");
 
+    let hostnameCount = new Map();
     for (let login of logins) {
       usernamePresentHistogram.add(!!login.username);
 
+      let hostname = login.hostname;
+      hostnameCount.set(hostname, (hostnameCount.get(hostname) || 0 ) + 1);
+
       login.QueryInterface(Ci.nsILoginMetaInfo);
       let timeLastUsedAgeMs = referenceTimeMs - login.timeLastUsed;
       if (timeLastUsedAgeMs > 0) {
         loginLastUsedDaysHistogram.add(
           Math.floor(timeLastUsedAgeMs / MS_PER_DAY)
         );
       }
     }
+
+    let passwordsCountHistogram = clearAndGetHistogram("PWMGR_NUM_PASSWORDS_PER_HOSTNAME");
+    for (let count of hostnameCount.values()) {
+      passwordsCountHistogram.add(count);
+    }
   },
 
 
 
 
 
   /* ---------- Primary Public interfaces ---------- */
 
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -7161,16 +7161,23 @@
   "PWMGR_BLOCKLIST_NUM_SITES": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 100,
     "n_buckets" : 10,
     "extended_statistics_ok": true,
     "description": "The number of sites for which the user has explicitly rejected saving logins"
   },
+  "PWMGR_NUM_PASSWORDS_PER_HOSTNAME": {
+    "expires_in_version": "never",
+    "kind": "linear",
+    "high": 21,
+    "n_buckets" : 20,
+    "description": "The number of passwords per hostname"
+  },
   "PWMGR_NUM_SAVED_PASSWORDS": {
     "expires_in_version": "never",
     "kind": "exponential",
     "high": 750,
     "n_buckets" : 50,
     "extended_statistics_ok": true,
     "description": "Total number of saved logins, including those that cannot be decrypted"
   },