Chromium Code Reviews| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 const LoadedCallback& loaded_cb); | 46 const LoadedCallback& loaded_cb); |
| 47 void Start(scoped_ptr<std::string> data, | 47 void Start(scoped_ptr<std::string> data, |
| 48 int size, | 48 int size, |
| 49 const LoadedCallback& loaded_cb); | 49 const LoadedCallback& loaded_cb); |
| 50 | 50 |
| 51 private: | 51 private: |
| 52 friend class base::RefCountedThreadSafe<UserImageLoader>; | 52 friend class base::RefCountedThreadSafe<UserImageLoader>; |
| 53 | 53 |
| 54 // Contains attributes we need to know about each image we decode. | 54 // Contains attributes we need to know about each image we decode. |
| 55 struct ImageInfo { | 55 struct ImageInfo { |
| 56 ImageInfo(int size, const LoadedCallback& loaded_cb); | 56 ImageInfo(const std::string& file_path, |
| 57 int size, | |
|
Daniel Erat
2014/04/15 03:06:30
how about renaming this to something that's cleare
Alexander Alekseev
2014/04/15 22:47:31
Done.
| |
| 58 const LoadedCallback& loaded_cb); | |
| 57 ~ImageInfo(); | 59 ~ImageInfo(); |
| 58 | 60 |
| 61 const std::string file_path; | |
| 59 const int size; | 62 const int size; |
| 60 const LoadedCallback loaded_cb; | 63 const LoadedCallback loaded_cb; |
| 61 }; | 64 }; |
| 62 | 65 |
| 63 typedef std::map<const ImageDecoder*, ImageInfo> ImageInfoMap; | 66 typedef std::map<const ImageDecoder*, ImageInfo> ImageInfoMap; |
| 64 | 67 |
| 65 virtual ~UserImageLoader(); | 68 virtual ~UserImageLoader(); |
| 66 | 69 |
| 67 // Reads the image from |filepath| and starts the decoding process. This | 70 // Reads the image from |image_info.file_path| and starts the decoding |
| 68 // method may only be invoked via the |background_task_runner_|. | 71 // process. This method may only be invoked via the |background_task_runner_|. |
| 69 void ReadAndDecodeImage(const std::string& filepath, | 72 void ReadAndDecodeImage(const ImageInfo& image_info); |
| 70 const ImageInfo& image_info); | |
| 71 | 73 |
| 72 // Decodes the image |data|. This method may only be invoked via the | 74 // Decodes the image |data|. This method may only be invoked via the |
| 73 // |background_task_runner_|. | 75 // |background_task_runner_|. |
| 74 void DecodeImage(const scoped_ptr<std::string> data, | 76 void DecodeImage(const scoped_ptr<std::string> data, |
| 75 const ImageInfo& image_info); | 77 const ImageInfo& image_info); |
| 76 | 78 |
| 77 // ImageDecoder::Delegate implementation. These callbacks will only be invoked | 79 // ImageDecoder::Delegate implementation. These callbacks will only be invoked |
| 78 // via the |background_task_runner_|. | 80 // via the |background_task_runner_|. |
| 79 virtual void OnImageDecoded(const ImageDecoder* decoder, | 81 virtual void OnImageDecoded(const ImageDecoder* decoder, |
| 80 const SkBitmap& decoded_image) OVERRIDE; | 82 const SkBitmap& decoded_image) OVERRIDE; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 94 // Holds information about the images currently being decoded. Accessed via | 96 // Holds information about the images currently being decoded. Accessed via |
| 95 // |background_task_runner_| only. | 97 // |background_task_runner_| only. |
| 96 ImageInfoMap image_info_map_; | 98 ImageInfoMap image_info_map_; |
| 97 | 99 |
| 98 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); | 100 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); |
| 99 }; | 101 }; |
| 100 | 102 |
| 101 } // namespace chromeos | 103 } // namespace chromeos |
| 102 | 104 |
| 103 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ | 105 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ |
| OLD | NEW |