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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "chrome/browser/image_decoder.h" | 13 #include "chrome/browser/image_decoder.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
17 } | 17 } |
18 | 18 |
19 namespace user_manager { | 19 namespace user_manager { |
20 class UserImage; | 20 class UserImage; |
21 } | 21 } |
22 | 22 |
23 // Helper functions that read, decode and optionally resize an image on a | 23 // Helper functions that read, decode and optionally resize an image on a |
24 // background thread. The image is returned in the form of a UserImage. | 24 // background thread. The image is returned in the form of a UserImage. |
25 namespace chromeos { | 25 namespace chromeos { |
26 namespace user_image_loader { | 26 namespace user_image_loader { |
27 | 27 |
28 typedef base::Callback<void(scoped_ptr<user_manager::UserImage>)> | 28 typedef base::Callback<void(std::unique_ptr<user_manager::UserImage>)> |
29 LoadedCallback; | 29 LoadedCallback; |
30 | 30 |
31 // Loads an image with |image_codec| in the background and calls |loaded_cb| | 31 // Loads an image with |image_codec| in the background and calls |loaded_cb| |
32 // with the resulting UserImage (which may be empty in case of error). If | 32 // with the resulting UserImage (which may be empty in case of error). If |
33 // |pixels_per_side| is positive, the image is cropped to a square and shrunk | 33 // |pixels_per_side| is positive, the image is cropped to a square and shrunk |
34 // so that it does not exceed |pixels_per_side|x|pixels_per_side|. The first | 34 // so that it does not exceed |pixels_per_side|x|pixels_per_side|. The first |
35 // variant of this function reads the image from |file_path| on disk, the | 35 // variant of this function reads the image from |file_path| on disk, the |
36 // second processes |data| read into memory already. Decoding is done in a | 36 // second processes |data| read into memory already. Decoding is done in a |
37 // separate sandboxed process via ImageDecoder, and file I/O and resizing are | 37 // separate sandboxed process via ImageDecoder, and file I/O and resizing are |
38 // done via |background_task_runner|. | 38 // done via |background_task_runner|. |
39 void StartWithFilePath( | 39 void StartWithFilePath( |
40 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 40 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
41 const base::FilePath& file_path, | 41 const base::FilePath& file_path, |
42 ImageDecoder::ImageCodec image_codec, | 42 ImageDecoder::ImageCodec image_codec, |
43 int pixels_per_side, | 43 int pixels_per_side, |
44 const LoadedCallback& loaded_cb); | 44 const LoadedCallback& loaded_cb); |
45 void StartWithData( | 45 void StartWithData( |
46 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 46 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
47 scoped_ptr<std::string> data, | 47 std::unique_ptr<std::string> data, |
48 ImageDecoder::ImageCodec image_codec, | 48 ImageDecoder::ImageCodec image_codec, |
49 int pixels_per_side, | 49 int pixels_per_side, |
50 const LoadedCallback& loaded_cb); | 50 const LoadedCallback& loaded_cb); |
51 | 51 |
52 } // namespace user_image_loader | 52 } // namespace user_image_loader |
53 } // namespace chromeos | 53 } // namespace chromeos |
54 | 54 |
55 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ | 55 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_AVATAR_USER_IMAGE_LOADER_H_ |
OLD | NEW |