OLD | NEW |
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 Loading... |
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 |
OLD | NEW |