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

Unified Diff: third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h

Issue 2540763002: Notifications: Split up image loading histograms by image type (Closed)
Patch Set: Use histogram_suffixes Created 4 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h b/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h
index ea0cc3d4a9c541bf763eb3fbcf0b578503130d98..46e6be46c399c734f96f6cb5aea2d0a1a5cde986 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h
+++ b/third_party/WebKit/Source/modules/notifications/NotificationImageLoader.h
@@ -10,12 +10,11 @@
#include "modules/ModulesExport.h"
#include "platform/SharedBuffer.h"
#include "platform/heap/Handle.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "wtf/Functional.h"
#include "wtf/RefPtr.h"
#include <memory>
-class SkBitmap;
-
namespace blink {
class ExecutionContext;
@@ -28,13 +27,20 @@ class MODULES_EXPORT NotificationImageLoader final
: public GarbageCollectedFinalized<NotificationImageLoader>,
public ThreadableLoaderClient {
public:
+ // Type names are used in UMAs, so do not rename.
+ enum class Type { Image, Icon, Badge, ActionIcon };
+
// The bitmap may be empty if the request failed or the image data could not
// be decoded.
using ImageCallback = Function<void(const SkBitmap&)>;
- NotificationImageLoader();
+ explicit NotificationImageLoader(Type);
~NotificationImageLoader() override;
+ // Scales down |image| according to its type and returns result. If it is
+ // already small enough, |image| is returned unchanged.
+ static SkBitmap scaleDownIfNeeded(const SkBitmap& image, Type);
+
// Asynchronously downloads an image from the given url, decodes the loaded
// data, and passes the bitmap to the callback. Times out if the load takes
// too long and ImageCallback is invoked with an empty bitmap.
@@ -56,6 +62,7 @@ class MODULES_EXPORT NotificationImageLoader final
private:
void runCallbackWithEmptyBitmap();
+ Type m_type;
bool m_stopped;
double m_startTime;
RefPtr<SharedBuffer> m_data;
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/notifications/NotificationImageLoader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698