| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 return true; | 46 return true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 class Request { | 49 class Request { |
| 50 public: | 50 public: |
| 51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} | 51 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} |
| 52 | 52 |
| 53 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { | 53 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { |
| 54 decoder_->DecodeImage( | 54 decoder_->DecodeImage( |
| 55 image, mojom::ImageCodec::DEFAULT, shrink, kTestMaxImageSize, | 55 image, mojom::ImageCodec::DEFAULT, shrink, kTestMaxImageSize, |
| 56 gfx::Size(), |
| 56 base::Bind(&Request::OnRequestDone, base::Unretained(this))); | 57 base::Bind(&Request::OnRequestDone, base::Unretained(this))); |
| 57 } | 58 } |
| 58 | 59 |
| 59 const SkBitmap& bitmap() const { return bitmap_; } | 60 const SkBitmap& bitmap() const { return bitmap_; } |
| 60 | 61 |
| 61 private: | 62 private: |
| 62 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } | 63 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } |
| 63 | 64 |
| 64 ImageDecoderImpl* decoder_; | 65 ImageDecoderImpl* decoder_; |
| 65 SkBitmap bitmap_; | 66 SkBitmap bitmap_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; | 153 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; |
| 153 std::vector<unsigned char> jpg(kRandomData, | 154 std::vector<unsigned char> jpg(kRandomData, |
| 154 kRandomData + sizeof(kRandomData)); | 155 kRandomData + sizeof(kRandomData)); |
| 155 | 156 |
| 156 Request request(decoder()); | 157 Request request(decoder()); |
| 157 request.DecodeImage(jpg, false); | 158 request.DecodeImage(jpg, false); |
| 158 EXPECT_TRUE(request.bitmap().isNull()); | 159 EXPECT_TRUE(request.bitmap().isNull()); |
| 159 } | 160 } |
| 160 | 161 |
| 161 } // namespace image_decoder | 162 } // namespace image_decoder |
| OLD | NEW |