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

Unified Diff: third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp

Issue 1904293003: Restore the histograms for notification resource loading. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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: third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
index 6e59fd3bcc556a32fc8e48bdc7cde746d53dd75d..855dfd9c18761024cceff718b2343e84c5b0868b 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
+++ b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.cpp
@@ -4,12 +4,14 @@
#include "modules/notifications/NotificationResourcesLoader.h"
+#include "platform/Histogram.h"
#include "platform/weborigin/KURL.h"
#include "public/platform/modules/notifications/WebNotificationConstants.h"
#include "public/platform/modules/notifications/WebNotificationData.h"
#include "public/platform/modules/notifications/WebNotificationResources.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "wtf/CurrentTime.h"
namespace blink {
@@ -21,8 +23,15 @@ namespace {
// TODO(mvanouwerkerk): Explore doing the scaling on a background thread.
SkBitmap scaleDownIfNeeded(const SkBitmap& image, int maxSizePx)
{
- if (image.width() > maxSizePx || image.height() > maxSizePx)
- return skia::ImageOperations::Resize(image, skia::ImageOperations::RESIZE_BEST, std::min(image.width(), maxSizePx), std::min(image.height(), maxSizePx));
+ if (image.width() > maxSizePx || image.height() > maxSizePx) {
+ // Matches SCOPED_UMA_HISTOGRAM_TIMER - the way Notifications.Icon.ScaleDownTime was originally defined.
+ DEFINE_STATIC_LOCAL(CustomCountHistogram, scaleTimeHistogram, ("Notifications.Icon.ScaleDownTime", 1, 1000 * 10 /* 10 seconds max */, 50 /* buckets */));
+
+ double startTime = monotonicallyIncreasingTimeMS();
+ SkBitmap scaledImage = skia::ImageOperations::Resize(image, skia::ImageOperations::RESIZE_BEST, std::min(image.width(), maxSizePx), std::min(image.height(), maxSizePx));
+ scaleTimeHistogram.count(monotonicallyIncreasingTimeMS() - startTime);
+ return scaledImage;
+ }
return image;
}

Powered by Google App Engine
This is Rietveld 408576698