Chromium Code Reviews| 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..af05e4c17c967139206b44d428b8b3a68ebf2804 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 and values are used in UMAs, so do not rename/renumber. |
|
Peter Beverloo
2016/11/29 19:01:40
nit: s/renumber/reorder/ (since the numbering is i
johnme
2016/11/29 20:04:29
Done (actually, numbering isn't used for UMA, so s
|
| + 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(); |
| + NotificationImageLoader(Type); |
|
Peter Beverloo
2016/11/29 19:01:40
explicit
johnme
2016/11/29 20:04:29
Done.
|
| ~NotificationImageLoader() override; |
| + // Scales down |image| to fit within |maxWidthPx|x|maxHeightPx| if it's larger |
|
Peter Beverloo
2016/11/29 19:01:40
nit: update comment. Neither |maxWidthPx| nor |max
johnme
2016/11/29 20:04:29
Done.
|
| + // and returns result. Otherwise does nothing and returns |image| 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; |