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

Unified Diff: components/user_manager/user_image/user_image.h

Issue 2517053004: Use base::RefCountedBytes in user_manager::UserImage (Closed)
Patch Set: remove unnecessary base::move Created 4 years, 1 month 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 | « components/user_manager/user.h ('k') | components/user_manager/user_image/user_image.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « components/user_manager/user.h ('k') | components/user_manager/user_image/user_image.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698