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 CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "chrome/browser/image_decoder.h" | 14 #include "chrome/browser/image_decoder.h" |
15 | 15 |
16 class SkBitmap; | 16 class SkBitmap; |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class SequencedTaskRunner; | 19 class SequencedTaskRunner; |
20 } | 20 } |
21 | 21 |
| 22 namespace user_manager { |
| 23 class UserImage; |
| 24 } |
| 25 |
22 namespace chromeos { | 26 namespace chromeos { |
23 | 27 |
24 class UserImage; | |
25 | |
26 // Helper that reads, decodes and optionally resizes an image on a background | 28 // Helper that reads, decodes and optionally resizes an image on a background |
27 // thread. Returns the image in the form of an SkBitmap. | 29 // thread. Returns the image in the form of an SkBitmap. |
28 class UserImageLoader : public base::RefCountedThreadSafe<UserImageLoader>, | 30 class UserImageLoader : public base::RefCountedThreadSafe<UserImageLoader>, |
29 public ImageDecoder::Delegate { | 31 public ImageDecoder::Delegate { |
30 public: | 32 public: |
31 // Callback used to return the result of an image load operation. | 33 // Callback used to return the result of an image load operation. |
32 typedef base::Callback<void(const UserImage& user_image)> LoadedCallback; | 34 typedef base::Callback<void(const user_manager::UserImage& user_image)> |
| 35 LoadedCallback; |
33 | 36 |
34 // All file I/O, decoding and resizing are done via |background_task_runner|. | 37 // All file I/O, decoding and resizing are done via |background_task_runner|. |
35 UserImageLoader( | 38 UserImageLoader( |
36 ImageDecoder::ImageCodec image_codec, | 39 ImageDecoder::ImageCodec image_codec, |
37 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 40 scoped_refptr<base::SequencedTaskRunner> background_task_runner); |
38 | 41 |
39 // Load an image in the background and call |loaded_cb| with the resulting | 42 // Load an image in the background and call |loaded_cb| with the resulting |
40 // UserImage (which may be empty in case of error). If |pixels_per_side| is | 43 // UserImage (which may be empty in case of error). If |pixels_per_side| is |
41 // positive, the image is cropped to a square and shrunk so that it does not | 44 // positive, the image is cropped to a square and shrunk so that it does not |
42 // exceed |pixels_per_side|x|pixels_per_side|. The first variant of this | 45 // exceed |pixels_per_side|x|pixels_per_side|. The first variant of this |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Holds information about the images currently being decoded. Accessed via | 100 // Holds information about the images currently being decoded. Accessed via |
98 // |background_task_runner_| only. | 101 // |background_task_runner_| only. |
99 ImageInfoMap image_info_map_; | 102 ImageInfoMap image_info_map_; |
100 | 103 |
101 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); | 104 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); |
102 }; | 105 }; |
103 | 106 |
104 } // namespace chromeos | 107 } // namespace chromeos |
105 | 108 |
106 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ | 109 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ |
OLD | NEW |