| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 ImageLoader::ImageLoader(const base::FilePath& path) : path_(path) { | 47 ImageLoader::ImageLoader(const base::FilePath& path) : path_(path) { |
| 48 } | 48 } |
| 49 | 49 |
| 50 ImageLoader::~ImageLoader() { | 50 ImageLoader::~ImageLoader() { |
| 51 } | 51 } |
| 52 | 52 |
| 53 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() { | 53 scoped_ptr<gfx::ImageSkia> ImageLoader::Load() { |
| 54 std::string image_data; | 54 std::string image_data; |
| 55 ReadFileToString(path_, &image_data); | 55 ReadFileToString(path_, &image_data); |
| 56 scoped_refptr<ImageDecoder> image_decoder = new ImageDecoder( | 56 ImageDecoder::GetInstance()->Start(this, image_data, |
| 57 this, | 57 ImageDecoder::ROBUST_JPEG_CODEC, |
| 58 image_data, | 58 base::MessageLoopProxy::current(), false); |
| 59 ImageDecoder::ROBUST_JPEG_CODEC); | |
| 60 image_decoder->Start(base::MessageLoopProxy::current()); | |
| 61 run_loop_.Run(); | 59 run_loop_.Run(); |
| 62 return decoded_image_.Pass(); | 60 return decoded_image_.Pass(); |
| 63 } | 61 } |
| 64 | 62 |
| 65 void ImageLoader::OnImageDecoded(const ImageDecoder* decoder, | 63 void ImageLoader::OnImageDecoded(const SkBitmap& decoded_image) { |
| 66 const SkBitmap& decoded_image) { | |
| 67 decoded_image_.reset( | 64 decoded_image_.reset( |
| 68 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f))); | 65 new gfx::ImageSkia(gfx::ImageSkiaRep(decoded_image, 1.0f))); |
| 69 run_loop_.Quit(); | 66 run_loop_.Quit(); |
| 70 } | 67 } |
| 71 | 68 |
| 72 void ImageLoader::OnDecodeImageFailed(const ImageDecoder* decoder) { | 69 void ImageLoader::OnDecodeImageFailed() { |
| 73 run_loop_.Quit(); | 70 run_loop_.Quit(); |
| 74 } | 71 } |
| 75 | 72 |
| 76 } // namespace test | 73 } // namespace test |
| 77 } // namespace chromeos | 74 } // namespace chromeos |
| OLD | NEW |