OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/login/user_image_loader.h" | 5 #include "chrome/browser/chromeos/login/user_image_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 void UserImageLoader::LoadImage(const std::string& filepath, | 51 void UserImageLoader::LoadImage(const std::string& filepath, |
52 const ImageInfo& image_info) { | 52 const ImageInfo& image_info) { |
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
54 | 54 |
55 std::string image_data; | 55 std::string image_data; |
56 file_util::ReadFileToString(FilePath(filepath), &image_data); | 56 file_util::ReadFileToString(FilePath(filepath), &image_data); |
57 | 57 |
58 scoped_refptr<ImageDecoder> image_decoder = | 58 scoped_refptr<ImageDecoder> image_decoder = |
59 new ImageDecoder(this, image_data); | 59 new ImageDecoder(this, image_data, ImageDecoder::ONLY_IJG_LIBJPEG_CODEC); |
60 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); | 60 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); |
61 image_decoder->Start(); | 61 image_decoder->Start(); |
62 } | 62 } |
63 | 63 |
64 void UserImageLoader::OnImageDecoded(const ImageDecoder* decoder, | 64 void UserImageLoader::OnImageDecoded(const ImageDecoder* decoder, |
65 const SkBitmap& decoded_image) { | 65 const SkBitmap& decoded_image) { |
66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
67 | 67 |
68 ImageInfoMap::iterator info_it = image_info_map_.find(decoder); | 68 ImageInfoMap::iterator info_it = image_info_map_.find(decoder); |
69 if (info_it == image_info_map_.end()) { | 69 if (info_it == image_info_map_.end()) { |
(...skipping 30 matching lines...) Expand all Loading... |
100 | 100 |
101 image_info_map_.erase(info_it); | 101 image_info_map_.erase(info_it); |
102 } | 102 } |
103 | 103 |
104 void UserImageLoader::OnDecodeImageFailed(const ImageDecoder* decoder) { | 104 void UserImageLoader::OnDecodeImageFailed(const ImageDecoder* decoder) { |
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
106 image_info_map_.erase(decoder); | 106 image_info_map_.erase(decoder); |
107 } | 107 } |
108 | 108 |
109 } // namespace chromeos | 109 } // namespace chromeos |
OLD | NEW |