| Index: components/user_manager/user_image/user_image.h
|
| diff --git a/components/user_manager/user_image/user_image.h b/components/user_manager/user_image/user_image.h
|
| index 7d822c4d3bfa651f398462c7a61b910fbb77e4a8..4604163df218e66c9028d2329e2719e4323dc794 100644
|
| --- a/components/user_manager/user_image/user_image.h
|
| +++ b/components/user_manager/user_image/user_image.h
|
| @@ -10,6 +10,7 @@
|
| #include <vector>
|
|
|
| #include "base/files/file_path.h"
|
| +#include "base/memory/ref_counted_memory.h"
|
| #include "components/user_manager/user_manager_export.h"
|
| #include "ui/gfx/image/image_skia.h"
|
| #include "url/gurl.h"
|
| @@ -21,13 +22,9 @@ namespace user_manager {
|
| // profile images and user wallpapers.
|
| class USER_MANAGER_EXPORT UserImage {
|
| public:
|
| - // Used to store bytes representation for WebUI.
|
| - // TODO(ivankr): replace with RefCountedMemory to prevent copying.
|
| - typedef std::vector<unsigned char> Bytes;
|
| -
|
| // Encodes the given bitmap to bytes representation for WebUI. Returns null
|
| // on failure.
|
| - static std::unique_ptr<Bytes> Encode(const SkBitmap& bitmap);
|
| + static scoped_refptr<base::RefCountedBytes> Encode(const SkBitmap& bitmap);
|
|
|
| // Creates a new instance from a given still frame and tries to encode it
|
| // to bytes representation for WebUI. Always returns a non-null result.
|
| @@ -45,16 +42,18 @@ class USER_MANAGER_EXPORT UserImage {
|
|
|
| // Creates a new instance from a given still frame and bytes
|
| // representation for WebUI.
|
| - // TODO(crbug.com/593251): Remove the data copy via |image_bytes|.
|
| - UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes);
|
| + UserImage(const gfx::ImageSkia& image,
|
| + scoped_refptr<base::RefCountedBytes> image_bytes);
|
|
|
| virtual ~UserImage();
|
|
|
| const gfx::ImageSkia& image() const { return image_; }
|
|
|
| // Optional bytes representation of the still image for WebUI.
|
| - bool has_image_bytes() const { return has_image_bytes_; }
|
| - const Bytes& image_bytes() const { return image_bytes_; }
|
| + bool has_image_bytes() const { return image_bytes_ != nullptr; }
|
| + scoped_refptr<base::RefCountedBytes> image_bytes() const {
|
| + return image_bytes_;
|
| + }
|
|
|
| // URL from which this image was originally downloaded, if any.
|
| void set_url(const GURL& url) { url_ = url; }
|
| @@ -72,13 +71,12 @@ class USER_MANAGER_EXPORT UserImage {
|
|
|
| private:
|
| gfx::ImageSkia image_;
|
| - bool has_image_bytes_;
|
| - Bytes image_bytes_;
|
| + scoped_refptr<base::RefCountedBytes> image_bytes_;
|
| GURL url_;
|
|
|
| // If image was loaded from the local file, file path is stored here.
|
| base::FilePath file_path_;
|
| - bool is_safe_format_;
|
| + bool is_safe_format_ = false;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(UserImage);
|
| };
|
|
|