diff options
author | satorux <satorux@chromium.org> | 2016-03-01 20:22:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 04:23:37 +0000 |
commit | 730760a001e019fc2f5fa8d8a2035d0e9dd8539d (patch) | |
tree | cb6d25d91131fcb0d4ffa4ce1d8447ac011d4afe /components/user_manager | |
parent | b90a631cdd8bf933a4e935db73605796e4c5461c (diff) | |
download | chromium_src-730760a001e019fc2f5fa8d8a2035d0e9dd8539d.zip chromium_src-730760a001e019fc2f5fa8d8a2035d0e9dd8539d.tar.gz chromium_src-730760a001e019fc2f5fa8d8a2035d0e9dd8539d.tar.bz2 |
Rename raw_image() to image_bytes() in UserImage
raw_image() was a misnomer, because this function returns
data bytes representation of an image encoded in web-compatible
format such as JPEG for WebUI (ex. chrome://userimage/),
rather than raw bitmap data.
Along the way, get rid of DiscardRawImage() that is not
used at all
BUG=590630
TEST=everything builds as before
TBR=achuith@chromium.org for components/user_manager, bshe@chromium.org for components/wallpaper
Review URL: https://codereview.chromium.org/1747843002
Cr-Commit-Position: refs/heads/master@{#378687}
Diffstat (limited to 'components/user_manager')
-rw-r--r-- | components/user_manager/user.cc | 2 | ||||
-rw-r--r-- | components/user_manager/user.h | 10 | ||||
-rw-r--r-- | components/user_manager/user_image/user_image.cc | 24 | ||||
-rw-r--r-- | components/user_manager/user_image/user_image.h | 38 |
4 files changed, 36 insertions, 38 deletions
diff --git a/components/user_manager/user.cc b/components/user_manager/user.cc index a77ab8b..f84767c 100644 --- a/components/user_manager/user.cc +++ b/components/user_manager/user.cc @@ -238,7 +238,7 @@ void User::SetImage(const UserImage& user_image, int image_index) { image_index_ = image_index; image_is_stub_ = false; image_is_loading_ = false; - DCHECK(HasDefaultImage() || user_image.has_raw_image()); + DCHECK(HasDefaultImage() || user_image.has_image_bytes()); } void User::SetImageURL(const GURL& image_url) { diff --git a/components/user_manager/user.h b/components/user_manager/user.h index 0d6431b6..df3d5cb 100644 --- a/components/user_manager/user.h +++ b/components/user_manager/user.h @@ -127,13 +127,13 @@ class USER_MANAGER_EXPORT User : public UserInfo { bool HasDefaultImage() const; int image_index() const { return image_index_; } - bool has_raw_image() const { return user_image_.has_raw_image(); } - // Returns raw representation of static user image. - const UserImage::RawImage& raw_image() const { - return user_image_.raw_image(); + bool has_image_bytes() const { return user_image_.has_image_bytes(); } + // Returns bytes representation of static user image for WebUI. + const UserImage::Bytes& image_bytes() const { + return user_image_.image_bytes(); } - // Whether |raw_image| contains data in format that is considered safe to + // Whether |user_image_| contains data in format that is considered safe to // decode in sensitive environment (on Login screen). bool image_is_safe_format() const { return user_image_.is_safe_format(); } diff --git a/components/user_manager/user_image/user_image.cc b/components/user_manager/user_image/user_image.cc index e9937da..af37983 100644 --- a/components/user_manager/user_image/user_image.cc +++ b/components/user_manager/user_image/user_image.cc @@ -16,7 +16,7 @@ namespace { const int kDefaultEncodingQuality = 90; bool EncodeImageSkia(const gfx::ImageSkia& image, - std::vector<unsigned char>* output) { + UserImage::Bytes* output) { TRACE_EVENT2("oobe", "EncodeImageSkia", "width", image.width(), "height", image.height()); if (image.isNull()) @@ -36,9 +36,9 @@ bool EncodeImageSkia(const gfx::ImageSkia& image, // static UserImage UserImage::CreateAndEncode(const gfx::ImageSkia& image) { - RawImage raw_image; - if (EncodeImageSkia(image, &raw_image)) { - UserImage result(image, raw_image); + Bytes image_bytes; + if (EncodeImageSkia(image, &image_bytes)) { + UserImage result(image, image_bytes); result.MarkAsSafe(); return result; } @@ -46,31 +46,27 @@ UserImage UserImage::CreateAndEncode(const gfx::ImageSkia& image) { } UserImage::UserImage() - : has_raw_image_(false), + : has_image_bytes_(false), is_safe_format_(false) { } UserImage::UserImage(const gfx::ImageSkia& image) : image_(image), - has_raw_image_(false), + has_image_bytes_(false), is_safe_format_(false) { } UserImage::UserImage(const gfx::ImageSkia& image, - const RawImage& raw_image) + const Bytes& image_bytes) : image_(image), - has_raw_image_(false), + has_image_bytes_(false), is_safe_format_(false) { - has_raw_image_ = true; - raw_image_ = raw_image; + has_image_bytes_ = true; + image_bytes_ = image_bytes; } UserImage::~UserImage() {} -void UserImage::DiscardRawImage() { - RawImage().swap(raw_image_); // Clear |raw_image_|. -} - void UserImage::MarkAsSafe() { is_safe_format_ = true; } diff --git a/components/user_manager/user_image/user_image.h b/components/user_manager/user_image/user_image.h index 1a05aeb..6397096 100644 --- a/components/user_manager/user_image/user_image.h +++ b/components/user_manager/user_image/user_image.h @@ -15,43 +15,45 @@ namespace user_manager { -// Wrapper class storing a still image and it's raw representation. Could be -// used for storing profile images and user wallpapers. +// Wrapper class storing a still image and its bytes representation for +// WebUI in a web-compatible format such as JPEG. Could be used for storing +// 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> RawImage; + typedef std::vector<unsigned char> Bytes; - // Creates a new instance from a given still frame and tries to encode raw - // representation for it. + // Creates a new instance from a given still frame and tries to encode it + // to bytes representation for WebUI. // TODO(ivankr): remove eventually. static UserImage CreateAndEncode(const gfx::ImageSkia& image); - // Create instance with an empty still frame and no raw data. + // Create instance with an empty still frame and no bytes + // representation for WebUI. UserImage(); - // Creates a new instance from a given still frame without any raw data. + // Creates a new instance from a given still frame without any bytes + // representation for WebUI. explicit UserImage(const gfx::ImageSkia& image); - // Creates a new instance from a given still frame and raw representation. - UserImage(const gfx::ImageSkia& image, const RawImage& raw_image); + // Creates a new instance from a given still frame and bytes + // representation for WebUI. + UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes); virtual ~UserImage(); const gfx::ImageSkia& image() const { return image_; } - // Optional raw representation of the still image. - bool has_raw_image() const { return has_raw_image_; } - const RawImage& raw_image() const { return raw_image_; } - - // Discards the stored raw image, freeing used memory. - void DiscardRawImage(); + // 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_; } // URL from which this image was originally downloaded, if any. void set_url(const GURL& url) { url_ = url; } GURL url() const { return url_; } - // Whether |raw_image| contains data in format that is considered safe to + // Whether |image_bytes| contains data in format that is considered safe to // decode in sensitive environment (on Login screen). bool is_safe_format() const { return is_safe_format_; } void MarkAsSafe(); @@ -63,8 +65,8 @@ class USER_MANAGER_EXPORT UserImage { private: gfx::ImageSkia image_; - bool has_raw_image_; - RawImage raw_image_; + bool has_image_bytes_; + Bytes image_bytes_; GURL url_; // If image was loaded from the local file, file path is stored here. |