Bug 827910 - Only include details for plugin and extension add-ons; r=rnewman, a=akeybl
authorGregory Szorc <gps@mozilla.com>
Tue, 08 Jan 2013 12:07:27 -0800
changeset 123696 509fb1a9021b6bd213c7f30a109d4211a6f56501
parent 123695 cf75b93c729aae43d6054ba7db9ff8c1f7cfcc5f
child 123697 293ee495f43996875a933b95a744e25be754ab5b
push id3207
push usermconnor@mozilla.com
push dateTue, 22 Jan 2013 02:03:47 +0000
treeherdermozilla-aurora@71009680316b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrnewman, akeybl
bugs827910
milestone20.0a2
Bug 827910 - Only include details for plugin and extension add-ons; r=rnewman, a=akeybl
services/healthreport/providers.jsm
services/healthreport/tests/xpcshell/test_provider_addons.js
--- a/services/healthreport/providers.jsm
+++ b/services/healthreport/providers.jsm
@@ -723,16 +723,23 @@ AddonsProvider.prototype = Object.freeze
   // state tracking here, which isn't desirable.
   ADDON_LISTENER_CALLBACKS: [
     "onEnabled",
     "onDisabled",
     "onInstalled",
     "onUninstalled",
   ],
 
+  // Add-on types for which full details are uploaded in the
+  // ActiveAddonsMeasurement. All other types are ignored.
+  FULL_DETAIL_TYPES: [
+    "plugin",
+    "extension",
+  ],
+
   name: "org.mozilla.addons",
 
   measurementTypes: [
     ActiveAddonsMeasurement,
     AddonCountsMeasurement,
   ],
 
   onInit: function () {
@@ -810,16 +817,23 @@ AddonsProvider.prototype = Object.freeze
     "foreignInstall",
     "hasBinaryComponents",
   ],
 
   _createDataStructure: function (addons) {
     let data = {addons: {}, counts: {}};
 
     for (let addon of addons) {
+      let type = addon.type;
+      data.counts[type] = (data.counts[type] || 0) + 1;
+
+      if (this.FULL_DETAIL_TYPES.indexOf(addon.type) == -1) {
+        continue;
+      }
+
       let optOutPref = "extensions." + addon.id + ".getAddons.cache.enabled";
       if (!this._prefs.get(optOutPref, true)) {
         this._log.debug("Ignoring add-on that's opted out of AMO updates: " +
                         addon.id);
         continue;
       }
 
       let obj = {};
@@ -832,18 +846,16 @@ AddonsProvider.prototype = Object.freeze
       }
 
       if (addon.updateDate) {
         obj.updateDay = this._dateToDays(addon.updateDate);
       }
 
       data.addons[addon.id] = obj;
 
-      let type = addon.type;
-      data.counts[type] = (data.counts[type] || 0) + 1;
     }
 
     return data;
   },
 });
 
 
 function DailyCrashesMeasurement() {
--- a/services/healthreport/tests/xpcshell/test_provider_addons.js
+++ b/services/healthreport/tests/xpcshell/test_provider_addons.js
@@ -70,16 +70,29 @@ add_task(function test_collect() {
       version: "2",
       type: "plugin",
       scope: 1,
       foreignInstall: false,
       hasBinaryComponents: false,
       installDate: now,
       updateDate: now,
     },
+    // Is counted but full details are omitted because it is a theme.
+    {
+      id: "addon2",
+      userDisabled: false,
+      appDisabled: false,
+      version: "3",
+      type: "theme",
+      scope: 1,
+      foreignInstall: false,
+      hasBinaryComponents: false,
+      installDate: now,
+      updateDate: now,
+    },
   ];
 
   monkeypatchAddons(provider, addons);
 
   yield provider.collectConstantData();
 
   let active = provider.getMeasurement("active", 1);
   let data = yield active.getValues();
@@ -104,16 +117,17 @@ add_task(function test_collect() {
 
   let counts = provider.getMeasurement("counts", 1);
   data = yield counts.getValues();
   do_check_eq(data.days.size, 1);
   do_check_eq(data.singular.size, 0);
   do_check_true(data.days.hasDay(now));
 
   value = data.days.getDay(now);
-  do_check_eq(value.size, 2);
+  do_check_eq(value.size, 3);
   do_check_eq(value.get("extension"), 1);
   do_check_eq(value.get("plugin"), 1);
+  do_check_eq(value.get("theme"), 1);
 
   yield provider.shutdown();
   yield storage.close();
 });