Bug 1041843 - Add two telemetry histograms to measure favicon file sizes in use on the web, one for .ico files and one for .png files. r=mak
authorBernardo P. Rittmeyer <bernardo@rittme.com>
Fri, 01 Aug 2014 08:27:00 -0400
changeset 197511 bfd2a9d3c731dba05d217e12c31275326878d3cf
parent 197510 3d3945a8af7d18ca632d67a26df697ed0f259885
child 197512 efdfa1bf63450e16db89a277cc3babc06606cd6a
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersmak
bugs1041843
milestone34.0a1
Bug 1041843 - Add two telemetry histograms to measure favicon file sizes in use on the web, one for .ico files and one for .png files. r=mak
toolkit/components/places/AsyncFaviconHelpers.cpp
toolkit/components/telemetry/Histograms.json
--- a/toolkit/components/places/AsyncFaviconHelpers.cpp
+++ b/toolkit/components/places/AsyncFaviconHelpers.cpp
@@ -8,16 +8,17 @@
 
 #include "nsICacheEntry.h"
 #include "nsICachingChannel.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 
 #include "nsNavHistory.h"
 #include "nsFaviconService.h"
 #include "mozilla/storage.h"
+#include "mozilla/Telemetry.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsStreamUtils.h"
 #include "nsIPrivateBrowsingChannel.h"
 #include "nsISupportsPriority.h"
 #include <algorithm>
 
 using namespace mozilla::places;
@@ -643,16 +644,43 @@ AsyncFetchAndSetIconFromNetwork::OnStopR
   }
 
   nsCOMPtr<nsIChannel> channel = do_QueryInterface(aRequest);
   // aRequest should always QI to nsIChannel.
   // See AsyncFetchAndSetIconFromNetwork::Run()
   MOZ_ASSERT(channel);
   mIcon.expiration = GetExpirationTimeFromChannel(channel);
 
+  // Telemetry probes to measure the favicon file sizes for each different file type.
+  // This allow us to measure common file sizes while also observing each type popularity.
+  if (mIcon.mimeType.EqualsLiteral("image/png")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_PNG_SIZES, mIcon.data.Length());
+  }
+  else if (mIcon.mimeType.EqualsLiteral("image/x-icon") ||
+           mIcon.mimeType.EqualsLiteral("image/vnd.microsoft.icon")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_ICO_SIZES, mIcon.data.Length());
+  }
+  else if (mIcon.mimeType.EqualsLiteral("image/jpeg") ||
+           mIcon.mimeType.EqualsLiteral("image/pjpeg")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_JPEG_SIZES, mIcon.data.Length());
+  }
+  else if (mIcon.mimeType.EqualsLiteral("image/gif")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_GIF_SIZES, mIcon.data.Length());
+  }
+  else if (mIcon.mimeType.EqualsLiteral("image/bmp") ||
+           mIcon.mimeType.EqualsLiteral("image/x-windows-bmp")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_BMP_SIZES, mIcon.data.Length());
+  }
+  else if (mIcon.mimeType.EqualsLiteral("image/svg+xml")) {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_SVG_SIZES, mIcon.data.Length());
+  }
+  else {
+    mozilla::Telemetry::Accumulate(mozilla::Telemetry::PLACES_FAVICON_OTHER_SIZES, mIcon.data.Length());
+  }
+
   rv = OptimizeIconSize(mIcon, favicons);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // If over the maximum size allowed, don't save data to the database to
   // avoid bloating it.
   if (mIcon.data.Length() > MAX_FAVICON_SIZE) {
     return NS_OK;
   }
--- a/toolkit/components/telemetry/Histograms.json
+++ b/toolkit/components/telemetry/Histograms.json
@@ -3008,16 +3008,65 @@
     "expires_in_version": "never",
     "kind": "exponential",
     "low": 50,
     "high": 2000,
     "n_buckets": 10,
     "extended_statistics_ok": true,
     "description": "PLACES: Time to calculate the md5 hash for a backup"
   },
+  "PLACES_FAVICON_ICO_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the ICO favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_PNG_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the PNG favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_GIF_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the GIF favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_JPEG_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the JPEG favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_BMP_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the BMP favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_SVG_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of the SVG favicon files loaded from the web (Bytes)"
+  },
+  "PLACES_FAVICON_OTHER_SIZES": {
+    "expires_in_version" : "never",
+    "kind": "exponential",
+    "high": 524288,
+    "n_buckets" : 100,
+    "description": "PLACES: Size of favicon files without a specific file type probe, loaded from the web (Bytes)"
+  },
   "FENNEC_DISTRIBUTION_REFERRER_INVALID": {
     "expires_in_version": "never",
     "kind": "flag",
     "description": "Whether the referrer intent specified an invalid distribution name",
     "cpp_guard": "ANDROID"
   },
   "FENNEC_DISTRIBUTION_CODE_CATEGORY": {
     "expires_in_version": "never",