Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Unified Diff: Source/platform/image-decoders/ImageDecoder.h

Issue 1242263011: Record UMA stats for Blink decoded image types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/image-decoders/ImageDecoder.h
diff --git a/Source/platform/image-decoders/ImageDecoder.h b/Source/platform/image-decoders/ImageDecoder.h
index 83c0cb9b0380e2e5e95850be4014a720a054b030..7224eecb02f30d222b8f1cb2508c5f5327b67d7e 100644
--- a/Source/platform/image-decoders/ImageDecoder.h
+++ b/Source/platform/image-decoders/ImageDecoder.h
@@ -49,6 +49,23 @@ typedef Vector<char> ColorProfile;
namespace blink {
+enum DecodedImageType {
+ // These values are histogrammed over time; do not change their ordinal
+ // values. When deleting an image type, replace it with a dummy value;
+ // when adding an image type, do so at the bottom (and update DecodedImageTypeMax).
+ // Also, this enum should be in sync with the 'DecodedImageType' enum in
+ // tools/metrics/histograms/histograms.xml
+ ImageUnknown = 0,
+ ImageJPEG,
+ ImagePNG,
+ ImageGIF,
+ ImageWebP,
+ ImageICO,
+ ImageBMP,
+
+ DecodedImageTypeMax = ImageBMP // Must equal the last "real" image type above.
+};
+
// ImagePlanes can be used to decode color components into provided buffers instead of using an ImageFrame.
class PLATFORM_EXPORT ImagePlanes {
public:
@@ -326,6 +343,14 @@ protected:
// Decodes the requested frame.
virtual void decode(size_t) = 0;
+ // Report image stats if it's NOT a trivial 1x1 image.
+ void reportStats(DecodedImageType type) const
+ {
+ if (isDecodedSizeAvailable() && (size().width() > 1 || size().height() > 1)) {
+ Platform::current()->histogramEnumeration("Blink.DecodedImageType", type, DecodedImageTypeMax + 1);
+ }
+ }
+
RefPtr<SharedBuffer> m_data; // The encoded data.
Vector<ImageFrame, 1> m_frameBufferCache;
bool m_premultiplyAlpha;

Powered by Google App Engine
This is Rietveld 408576698