| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public ImageDecoder::Delegate { | 29 public ImageDecoder::Delegate { |
| 30 public: | 30 public: |
| 31 // Callback used to return the result of an image load operation. | 31 // Callback used to return the result of an image load operation. |
| 32 typedef base::Callback<void(const UserImage& user_image)> LoadedCallback; | 32 typedef base::Callback<void(const UserImage& user_image)> LoadedCallback; |
| 33 | 33 |
| 34 // All file I/O, decoding and resizing are done via |background_task_runner|. | 34 // All file I/O, decoding and resizing are done via |background_task_runner|. |
| 35 UserImageLoader( | 35 UserImageLoader( |
| 36 ImageDecoder::ImageCodec image_codec, | 36 ImageDecoder::ImageCodec image_codec, |
| 37 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 37 scoped_refptr<base::SequencedTaskRunner> background_task_runner); |
| 38 | 38 |
| 39 // Load an image in the background and call |loaded_cb| with the result. If | 39 // Load an image in the background and call |loaded_cb| with the resulting |
| 40 // |size| is positive, the image is cropped to a square and shrunk so that it | 40 // UserImage (which may be empty in case of error). If |pixels_per_side| is |
| 41 // does not exceed |size|x|size|. The first variant of this method reads the | 41 // positive, the image is cropped to a square and shrunk so that it does not |
| 42 // image from |filepath| on disk, the second processes |data| read into memory | 42 // exceed |pixels_per_side|x|pixels_per_side|. The first variant of this |
| 43 // already. | 43 // method reads the image from |filepath| on disk, the second processes |data| |
| 44 // read into memory already. |
| 44 void Start(const std::string& filepath, | 45 void Start(const std::string& filepath, |
| 45 int pixels_per_side, | 46 int pixels_per_side, |
| 46 const LoadedCallback& loaded_cb); | 47 const LoadedCallback& loaded_cb); |
| 47 void Start(scoped_ptr<std::string> data, | 48 void Start(scoped_ptr<std::string> data, |
| 48 int pixels_per_side, | 49 int pixels_per_side, |
| 49 const LoadedCallback& loaded_cb); | 50 const LoadedCallback& loaded_cb); |
| 50 | 51 |
| 51 private: | 52 private: |
| 52 friend class base::RefCountedThreadSafe<UserImageLoader>; | 53 friend class base::RefCountedThreadSafe<UserImageLoader>; |
| 53 | 54 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 // Holds information about the images currently being decoded. Accessed via | 97 // Holds information about the images currently being decoded. Accessed via |
| 97 // |background_task_runner_| only. | 98 // |background_task_runner_| only. |
| 98 ImageInfoMap image_info_map_; | 99 ImageInfoMap image_info_map_; |
| 99 | 100 |
| 100 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); | 101 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 } // namespace chromeos | 104 } // namespace chromeos |
| 104 | 105 |
| 105 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ | 106 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ |
| OLD | NEW |