Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ | 5 #ifndef COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ |
| 6 #define COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ | 6 #define COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 public: | 22 public: |
| 23 // Used to store bytes representation for WebUI. | 23 // Used to store bytes representation for WebUI. |
| 24 // TODO(ivankr): replace with RefCountedMemory to prevent copying. | 24 // TODO(ivankr): replace with RefCountedMemory to prevent copying. |
| 25 typedef std::vector<unsigned char> Bytes; | 25 typedef std::vector<unsigned char> Bytes; |
| 26 | 26 |
| 27 // Encodes the given bitmap to bytes representation for WebUI. Returns null | 27 // Encodes the given bitmap to bytes representation for WebUI. Returns null |
| 28 // on failure. | 28 // on failure. |
| 29 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap); | 29 static scoped_ptr<Bytes> Encode(const SkBitmap& bitmap); |
| 30 | 30 |
| 31 // Creates a new instance from a given still frame and tries to encode it | 31 // Creates a new instance from a given still frame and tries to encode it |
| 32 // to bytes representation for WebUI. | 32 // to bytes representation for WebUI. Always returns a non-null result. |
| 33 // TODO(ivankr): remove eventually. | 33 // TODO(ivankr): remove eventually. |
| 34 static UserImage CreateAndEncode(const gfx::ImageSkia& image); | 34 static scoped_ptr<UserImage> CreateAndEncode(const gfx::ImageSkia& image); |
| 35 | 35 |
| 36 // Create instance with an empty still frame and no bytes | 36 // Create instance with an empty still frame and no bytes |
| 37 // representation for WebUI. | 37 // representation for WebUI. |
| 38 UserImage(); | 38 UserImage(); |
| 39 | 39 |
| 40 // Creates a new instance from a given still frame without any bytes | 40 // Creates a new instance from a given still frame without any bytes |
| 41 // representation for WebUI. | 41 // representation for WebUI. |
| 42 explicit UserImage(const gfx::ImageSkia& image); | 42 explicit UserImage(const gfx::ImageSkia& image); |
| 43 | 43 |
| 44 // Creates a new instance from a given still frame and bytes | 44 // Creates a new instance from a given still frame and bytes |
| 45 // representation for WebUI. | 45 // representation for WebUI. |
| 46 UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes); | 46 UserImage(const gfx::ImageSkia& image, const Bytes& image_bytes); |
|
hashimoto
2016/03/15 08:39:27
This ctor still copies image bytes.
satorux1
2016/03/16 02:01:30
Added a TODO comment.
| |
| 47 | 47 |
| 48 virtual ~UserImage(); | 48 virtual ~UserImage(); |
| 49 | 49 |
| 50 const gfx::ImageSkia& image() const { return image_; } | 50 const gfx::ImageSkia& image() const { return image_; } |
| 51 | 51 |
| 52 // Optional bytes representation of the still image for WebUI. | 52 // Optional bytes representation of the still image for WebUI. |
| 53 bool has_image_bytes() const { return has_image_bytes_; } | 53 bool has_image_bytes() const { return has_image_bytes_; } |
| 54 const Bytes& image_bytes() const { return image_bytes_; } | 54 const Bytes& image_bytes() const { return image_bytes_; } |
| 55 | 55 |
| 56 // URL from which this image was originally downloaded, if any. | 56 // URL from which this image was originally downloaded, if any. |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 gfx::ImageSkia image_; | 71 gfx::ImageSkia image_; |
| 72 bool has_image_bytes_; | 72 bool has_image_bytes_; |
| 73 Bytes image_bytes_; | 73 Bytes image_bytes_; |
| 74 GURL url_; | 74 GURL url_; |
| 75 | 75 |
| 76 // If image was loaded from the local file, file path is stored here. | 76 // If image was loaded from the local file, file path is stored here. |
| 77 base::FilePath file_path_; | 77 base::FilePath file_path_; |
| 78 bool is_safe_format_; | 78 bool is_safe_format_; |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(UserImage); | |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace user_manager | 83 } // namespace user_manager |
| 82 | 84 |
| 83 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ | 85 #endif // COMPONENTS_USER_MANAGER_USER_IMAGE_USER_IMAGE_H_ |
| OLD | NEW |