| 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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 this, | 59 this, |
| 60 base::Passed(&data), | 60 base::Passed(&data), |
| 61 ImageInfo(size, loaded_cb))); | 61 ImageInfo(size, loaded_cb))); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void UserImageLoader::ReadAndDecodeImage(const std::string& filepath, | 64 void UserImageLoader::ReadAndDecodeImage(const std::string& filepath, |
| 65 const ImageInfo& image_info) { | 65 const ImageInfo& image_info) { |
| 66 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); | 66 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| 67 | 67 |
| 68 scoped_ptr<std::string> data(new std::string); | 68 scoped_ptr<std::string> data(new std::string); |
| 69 base::ReadFileToString(base::FilePath(filepath), data.get()); | 69 const bool success = |
| 70 base::ReadFileToString(base::FilePath(filepath), data.get()); |
| 71 DCHECK(success); |
| 70 | 72 |
| 71 DecodeImage(data.Pass(), image_info); | 73 DecodeImage(data.Pass(), image_info); |
| 72 } | 74 } |
| 73 | 75 |
| 74 void UserImageLoader::DecodeImage(const scoped_ptr<std::string> data, | 76 void UserImageLoader::DecodeImage(const scoped_ptr<std::string> data, |
| 75 const ImageInfo& image_info) { | 77 const ImageInfo& image_info) { |
| 76 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); | 78 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); |
| 77 | 79 |
| 78 scoped_refptr<ImageDecoder> image_decoder = | 80 scoped_refptr<ImageDecoder> image_decoder = |
| 79 new ImageDecoder(this, *data, image_codec_); | 81 new ImageDecoder(this, *data, image_codec_); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 return; | 138 return; |
| 137 } | 139 } |
| 138 const LoadedCallback loaded_cb = it->second.loaded_cb; | 140 const LoadedCallback loaded_cb = it->second.loaded_cb; |
| 139 image_info_map_.erase(it); | 141 image_info_map_.erase(it); |
| 140 | 142 |
| 141 foreground_task_runner_->PostTask(FROM_HERE, | 143 foreground_task_runner_->PostTask(FROM_HERE, |
| 142 base::Bind(loaded_cb, UserImage())); | 144 base::Bind(loaded_cb, UserImage())); |
| 143 } | 145 } |
| 144 | 146 |
| 145 } // namespace chromeos | 147 } // namespace chromeos |
| OLD | NEW |