| 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 |
| 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 "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "chrome/browser/image_decoder.h" | 16 #include "chrome/browser/image_decoder.h" |
| 17 | 17 |
| 18 class SkBitmap; |
| 19 |
| 20 namespace base { |
| 18 class MessageLoop; | 21 class MessageLoop; |
| 19 class SkBitmap; | 22 } |
| 20 | 23 |
| 21 namespace chromeos { | 24 namespace chromeos { |
| 22 | 25 |
| 23 typedef base::SequencedWorkerPool::SequenceToken SequenceToken; | 26 typedef base::SequencedWorkerPool::SequenceToken SequenceToken; |
| 24 | 27 |
| 25 class UserImage; | 28 class UserImage; |
| 26 | 29 |
| 27 // A facility to read a file containing user image asynchronously in the IO | 30 // A facility to read a file containing user image asynchronously in the IO |
| 28 // thread. Returns the image in the form of an SkBitmap. | 31 // thread. Returns the image in the form of an SkBitmap. |
| 29 class UserImageLoader : public base::RefCountedThreadSafe<UserImageLoader>, | 32 class UserImageLoader : public base::RefCountedThreadSafe<UserImageLoader>, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 void LoadImage(const std::string& filepath, | 73 void LoadImage(const std::string& filepath, |
| 71 const ImageInfo& image_info, | 74 const ImageInfo& image_info, |
| 72 scoped_refptr<base::SequencedTaskRunner> task_runner); | 75 scoped_refptr<base::SequencedTaskRunner> task_runner); |
| 73 | 76 |
| 74 // ImageDecoder::Delegate implementation. | 77 // ImageDecoder::Delegate implementation. |
| 75 virtual void OnImageDecoded(const ImageDecoder* decoder, | 78 virtual void OnImageDecoded(const ImageDecoder* decoder, |
| 76 const SkBitmap& decoded_image) OVERRIDE; | 79 const SkBitmap& decoded_image) OVERRIDE; |
| 77 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; | 80 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; |
| 78 | 81 |
| 79 // The message loop object of the thread in which we notify the delegate. | 82 // The message loop object of the thread in which we notify the delegate. |
| 80 MessageLoop* target_message_loop_; | 83 base::MessageLoop* target_message_loop_; |
| 81 | 84 |
| 82 // Specify how the file should be decoded in the utility process. | 85 // Specify how the file should be decoded in the utility process. |
| 83 const ImageDecoder::ImageCodec image_codec_; | 86 const ImageDecoder::ImageCodec image_codec_; |
| 84 | 87 |
| 85 // Proctect image_info_map_ | 88 // Proctect image_info_map_ |
| 86 base::Lock lock_; | 89 base::Lock lock_; |
| 87 | 90 |
| 88 // Holds info structures about all images we're trying to decode. | 91 // Holds info structures about all images we're trying to decode. |
| 89 // Accessed on multiple worker threads. | 92 // Accessed on multiple worker threads. |
| 90 ImageInfoMap image_info_map_; | 93 ImageInfoMap image_info_map_; |
| 91 | 94 |
| 92 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); | 95 DISALLOW_COPY_AND_ASSIGN(UserImageLoader); |
| 93 }; | 96 }; |
| 94 | 97 |
| 95 } // namespace chromeos | 98 } // namespace chromeos |
| 96 | 99 |
| 97 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ | 100 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USER_IMAGE_LOADER_H_ |
| OLD | NEW |