| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/media_galleries/fileapi/supported_image_type_validator.
h" | 5 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator.
h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 return result; | 35 return result; |
| 36 | 36 |
| 37 base::File::Info file_info; | 37 base::File::Info file_info; |
| 38 if (!file.GetInfo(&file_info) || | 38 if (!file.GetInfo(&file_info) || |
| 39 file_info.size > kMaxImageFileSize) { | 39 file_info.size > kMaxImageFileSize) { |
| 40 return result; | 40 return result; |
| 41 } | 41 } |
| 42 | 42 |
| 43 result.reset(new std::string); | 43 result.reset(new std::string); |
| 44 result->resize(file_info.size); | 44 result->resize(file_info.size); |
| 45 if (file.Read(0, string_as_array(result.get()), file_info.size) != | 45 if (file.Read(0, base::string_as_array(result.get()), file_info.size) != |
| 46 file_info.size) { | 46 file_info.size) { |
| 47 result.reset(); | 47 result.reset(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 return result; | 50 return result; |
| 51 } | 51 } |
| 52 | 52 |
| 53 class ImageDecoderDelegateAdapter : public ImageDecoder::ImageRequest { | 53 class ImageDecoderDelegateAdapter : public ImageDecoder::ImageRequest { |
| 54 public: | 54 public: |
| 55 ImageDecoderDelegateAdapter( | 55 ImageDecoderDelegateAdapter( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (!data.get()) { | 125 if (!data.get()) { |
| 126 callback_.Run(base::File::FILE_ERROR_SECURITY); | 126 callback_.Run(base::File::FILE_ERROR_SECURITY); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // |adapter| will delete itself after a completion message is received. | 130 // |adapter| will delete itself after a completion message is received. |
| 131 ImageDecoderDelegateAdapter* adapter = | 131 ImageDecoderDelegateAdapter* adapter = |
| 132 new ImageDecoderDelegateAdapter(std::move(data), callback_); | 132 new ImageDecoderDelegateAdapter(std::move(data), callback_); |
| 133 ImageDecoder::Start(adapter, adapter->data()); | 133 ImageDecoder::Start(adapter, adapter->data()); |
| 134 } | 134 } |
| OLD | NEW |