Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/chromeos/login/user_image_loader.cc

Issue 264483004: UserImageLoader: Remove DCHECK requiring success of ReadFileToString(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add logging as suggested by Pavel. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/login/user_image_loader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 base::Bind(&UserImageLoader::DecodeImage, 60 base::Bind(&UserImageLoader::DecodeImage,
61 this, 61 this,
62 base::Passed(&data), 62 base::Passed(&data),
63 ImageInfo(std::string(), pixels_per_side, loaded_cb))); 63 ImageInfo(std::string(), pixels_per_side, loaded_cb)));
64 } 64 }
65 65
66 void UserImageLoader::ReadAndDecodeImage(const ImageInfo& image_info) { 66 void UserImageLoader::ReadAndDecodeImage(const ImageInfo& image_info) {
67 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 67 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
68 68
69 scoped_ptr<std::string> data(new std::string); 69 scoped_ptr<std::string> data(new std::string);
70 const bool success = 70 if (!base::ReadFileToString(base::FilePath(image_info.file_path), data.get()))
71 base::ReadFileToString(base::FilePath(image_info.file_path), data.get()); 71 LOG(ERROR) << "Failed to read image " << image_info.file_path;
72 DCHECK(success);
73 72
73 // In case ReadFileToString() fails, |data| is empty and DecodeImage() calls
74 // back to OnDecodeImageFailed().
74 DecodeImage(data.Pass(), image_info); 75 DecodeImage(data.Pass(), image_info);
75 } 76 }
76 77
77 void UserImageLoader::DecodeImage(const scoped_ptr<std::string> data, 78 void UserImageLoader::DecodeImage(const scoped_ptr<std::string> data,
78 const ImageInfo& image_info) { 79 const ImageInfo& image_info) {
79 DCHECK(background_task_runner_->RunsTasksOnCurrentThread()); 80 DCHECK(background_task_runner_->RunsTasksOnCurrentThread());
80 81
81 scoped_refptr<ImageDecoder> image_decoder = 82 scoped_refptr<ImageDecoder> image_decoder =
82 new ImageDecoder(this, *data, image_codec_); 83 new ImageDecoder(this, *data, image_codec_);
83 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info)); 84 image_info_map_.insert(std::make_pair(image_decoder.get(), image_info));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 return; 143 return;
143 } 144 }
144 const LoadedCallback loaded_cb = it->second.loaded_cb; 145 const LoadedCallback loaded_cb = it->second.loaded_cb;
145 image_info_map_.erase(it); 146 image_info_map_.erase(it);
146 147
147 foreground_task_runner_->PostTask(FROM_HERE, 148 foreground_task_runner_->PostTask(FROM_HERE,
148 base::Bind(loaded_cb, UserImage())); 149 base::Bind(loaded_cb, UserImage()));
149 } 150 }
150 151
151 } // namespace chromeos 152 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/user_image_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698