Chromium Code Reviews| Index: third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp |
| diff --git a/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp b/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp |
| index dbd0919a44ec72f30f1d20b6e886a00e82e7e178..c8e85060edda653f89892e3457c8ec7b05a0ef91 100644 |
| --- a/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp |
| +++ b/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp |
| @@ -6,6 +6,7 @@ |
| #include "core/dom/ExecutionContext.h" |
| #include "core/fetch/ResourceLoaderOptions.h" |
| +#include "platform/Histogram.h" |
| #include "platform/image-decoders/ImageDecoder.h" |
| #include "platform/image-decoders/ImageFrame.h" |
| #include "platform/network/ResourceError.h" |
| @@ -14,11 +15,12 @@ |
| #include "platform/weborigin/KURL.h" |
| #include "public/platform/WebURLRequest.h" |
| #include "third_party/skia/include/core/SkBitmap.h" |
| +#include "wtf/CurrentTime.h" |
| namespace blink { |
| NotificationImageLoader::NotificationImageLoader() |
| - : m_stopped(false) |
| + : m_stopped(false), m_startTime(0.0) |
| { |
| } |
| @@ -30,6 +32,7 @@ void NotificationImageLoader::start(ExecutionContext* executionContext, const KU |
| { |
| DCHECK(!m_stopped); |
| + m_startTime = monotonicallyIncreasingTimeMS(); |
| m_imageCallback = imageCallback; |
| // TODO(mvanouwerkerk): Add a timeout mechanism: crbug.com/579137. |
| @@ -82,7 +85,14 @@ void NotificationImageLoader::didFinishLoading(unsigned long resourceIdentifier, |
| if (m_stopped) |
| return; |
| + // Matches UMA_HISTOGRAM_LONG_TIMES - the way Notifications.Icon.LoadFinishTime was originally defined. |
|
Peter Beverloo
2016/04/22 15:56:13
Here and elsewhere -
"the way Notifications.Icon
Michael van Ouwerkerk
2016/04/25 11:28:28
Done.
|
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, finishedTimeHistogram, ("Notifications.Icon.LoadFinishTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */)); |
| + finishedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); |
| + |
| if (m_data) { |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, fileSizeHistogram, ("Notifications.Icon.FileSize", 1, 10000000 /* ~10mb max */, 50 /* buckets */)); |
| + fileSizeHistogram.count(m_data->size()); |
| + |
| OwnPtr<ImageDecoder> decoder = ImageDecoder::create(*m_data.get(), ImageDecoder::AlphaPremultiplied, ImageDecoder::GammaAndColorProfileApplied); |
| if (decoder) { |
| decoder->setData(m_data.get(), true /* allDataReceived */); |
| @@ -99,6 +109,10 @@ void NotificationImageLoader::didFinishLoading(unsigned long resourceIdentifier, |
| void NotificationImageLoader::didFail(const ResourceError& error) |
| { |
| + // Matches UMA_HISTOGRAM_LONG_TIMES - the way Notifications.Icon.LoadFailTime was originally defined. |
| + DEFINE_STATIC_LOCAL(CustomCountHistogram, failedTimeHistogram, ("Notifications.Icon.LoadFailTime", 1, 1000 * 60 * 60 /* 1 hour max */, 50 /* buckets */)); |
| + failedTimeHistogram.count(monotonicallyIncreasingTimeMS() - m_startTime); |
| + |
| runCallbackWithEmptyBitmap(); |
| } |