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 #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_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 task_runner)); | 64 task_runner)); |
65 } | 65 } |
66 | 66 |
67 void UserImageLoader::LoadImage( | 67 void UserImageLoader::LoadImage( |
68 const std::string& filepath, | 68 const std::string& filepath, |
69 const ImageInfo& image_info, | 69 const ImageInfo& image_info, |
70 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 70 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
71 DCHECK(task_runner->RunsTasksOnCurrentThread()); | 71 DCHECK(task_runner->RunsTasksOnCurrentThread()); |
72 | 72 |
73 std::string image_data; | 73 std::string image_data; |
74 file_util::ReadFileToString(base::FilePath(filepath), &image_data); | 74 base::ReadFileToString(base::FilePath(filepath), &image_data); |
75 | 75 |
76 scoped_refptr<ImageDecoder> image_decoder = | 76 scoped_refptr<ImageDecoder> image_decoder = |
77 new ImageDecoder(this, image_data, image_codec_); | 77 new ImageDecoder(this, image_data, image_codec_); |
78 { | 78 { |
79 base::AutoLock lock(lock_); | 79 base::AutoLock lock(lock_); |
80 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); | 80 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); |
81 } | 81 } |
82 image_decoder->Start(task_runner); | 82 image_decoder->Start(task_runner); |
83 } | 83 } |
84 | 84 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 new ImageInfo(info_it->second.size, info_it->second.loaded_cb)); | 146 new ImageInfo(info_it->second.size, info_it->second.loaded_cb)); |
147 image_info_map_.erase(decoder); | 147 image_info_map_.erase(decoder); |
148 } | 148 } |
149 | 149 |
150 target_message_loop_->PostTask( | 150 target_message_loop_->PostTask( |
151 FROM_HERE, | 151 FROM_HERE, |
152 base::Bind(image_info->loaded_cb, UserImage())); | 152 base::Bind(image_info->loaded_cb, UserImage())); |
153 } | 153 } |
154 | 154 |
155 } // namespace chromeos | 155 } // namespace chromeos |
OLD | NEW |