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

Side by Side Diff: chrome/browser/chromeos/login/users/avatar/user_image_manager_test_util.cc

Issue 1067593005: Fix race conditions in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use TestBrowserThreadBundle, cleanup tests Created 5 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/users/avatar/user_image_manager_test_uti l.h" 5 #include "chrome/browser/chromeos/login/users/avatar/user_image_manager_test_uti l.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 26 matching lines...) Expand all
37 SkAutoLockPixels second_pixel_lock(*second_bitmap); 37 SkAutoLockPixels second_pixel_lock(*second_bitmap);
38 uint8_t* first_data = reinterpret_cast<uint8_t*>(first_bitmap->getPixels()); 38 uint8_t* first_data = reinterpret_cast<uint8_t*>(first_bitmap->getPixels());
39 uint8_t* second_data = reinterpret_cast<uint8_t*>(second_bitmap->getPixels()); 39 uint8_t* second_data = reinterpret_cast<uint8_t*>(second_bitmap->getPixels());
40 for (size_t i = 0; i < size; ++i) { 40 for (size_t i = 0; i < size; ++i) {
41 if (first_data[i] != second_data[i]) 41 if (first_data[i] != second_data[i])
42 return false; 42 return false;
43 } 43 }
44 return true; 44 return true;
45 } 45 }
46 46
47 ImageLoader::ImageLoader(const base::FilePath& path) 47 ImageLoader::ImageLoader(const base::FilePath& path) : path_(path) {
48 : ImageRequest(base::MessageLoopProxy::current()), path_(path) {
49 } 48 }
50 49
51 ImageLoader::~ImageLoader() { 50 ImageLoader::~ImageLoader() {
52 } 51 }
53 52
54 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() { 53 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() {
55 std::string image_data; 54 std::string image_data;
56 ReadFileToString(path_, &image_data); 55 ReadFileToString(path_, &image_data);
57 ImageDecoder::StartWithOptions(this, image_data, 56 ImageDecoder::StartWithOptions(this, image_data,
58 ImageDecoder::ROBUST_JPEG_CODEC, false); 57 ImageDecoder::ROBUST_JPEG_CODEC, false);
59 run_loop_.Run(); 58 run_loop_.Run();
60 return decoded_image_.Pass(); 59 return decoded_image_.Pass();
61 } 60 }
62 61
63 void ImageLoader::OnImageDecoded(const SkBitmap& decoded_image) { 62 void ImageLoader::OnImageDecoded(const SkBitmap& decoded_image) {
64 decoded_image_.reset( 63 decoded_image_.reset(
65 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f))); 64 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f)));
66 run_loop_.Quit(); 65 run_loop_.Quit();
67 } 66 }
68 67
69 void ImageLoader::OnDecodeImageFailed() { 68 void ImageLoader::OnDecodeImageFailed() {
70 run_loop_.Quit(); 69 run_loop_.Quit();
71 } 70 }
72 71
73 } // namespace test 72 } // namespace test
74 } // namespace chromeos 73 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/supervised/supervised_user_creation_screen.cc ('k') | chrome/browser/image_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698