| 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 "chrome/utility/image_decoder_impl.h" | 5 #include "chrome/utility/image_decoder_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 } | 34 } |
| 35 return true; | 35 return true; |
| 36 } | 36 } |
| 37 | 37 |
| 38 class Request { | 38 class Request { |
| 39 public: | 39 public: |
| 40 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} | 40 explicit Request(ImageDecoderImpl* decoder) : decoder_(decoder) {} |
| 41 | 41 |
| 42 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { | 42 void DecodeImage(const std::vector<unsigned char>& image, bool shrink) { |
| 43 decoder_->DecodeImage( | 43 decoder_->DecodeImage( |
| 44 mojo::Array<uint8_t>::From(image), ImageCodec::DEFAULT, | 44 image, ImageCodec::DEFAULT, shrink, |
| 45 shrink, base::Bind(&Request::OnRequestDone, base::Unretained(this))); | 45 base::Bind(&Request::OnRequestDone, base::Unretained(this))); |
| 46 } | 46 } |
| 47 | 47 |
| 48 const SkBitmap& bitmap() const { return bitmap_; } | 48 const SkBitmap& bitmap() const { return bitmap_; } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } | 51 void OnRequestDone(const SkBitmap& result_image) { bitmap_ = result_image; } |
| 52 | 52 |
| 53 ImageDecoderImpl* decoder_; | 53 ImageDecoderImpl* decoder_; |
| 54 SkBitmap bitmap_; | 54 SkBitmap bitmap_; |
| 55 }; | 55 }; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; | 109 const char kRandomData[] = "u gycfy7xdjkhfgui bdui "; |
| 110 std::vector<unsigned char> jpg(kRandomData, | 110 std::vector<unsigned char> jpg(kRandomData, |
| 111 kRandomData + sizeof(kRandomData)); | 111 kRandomData + sizeof(kRandomData)); |
| 112 | 112 |
| 113 Request request(&decoder); | 113 Request request(&decoder); |
| 114 request.DecodeImage(jpg, false); | 114 request.DecodeImage(jpg, false); |
| 115 EXPECT_TRUE(request.bitmap().isNull()); | 115 EXPECT_TRUE(request.bitmap().isNull()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace mojom | 118 } // namespace mojom |
| OLD | NEW |