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

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

Issue 69863006: Address races in UserImageManagerImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix WallpaperManager browser tests now that UserImageLoader contains a DCHECK(success). Created 7 years, 1 month 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 | Annotate | Revision Log
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/mock_user_manager.h ('k') | chrome/browser/chromeos/login/user_image_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698