OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |
| 6 #define CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "chrome/common/extensions/media_parser.mojom.h" |
| 11 #include "chrome/common/media_galleries/metadata_types.h" |
| 12 #include "mojo/public/cpp/bindings/array_traits_carray.h" |
| 13 |
| 14 namespace mojo { |
| 15 |
| 16 template <> |
| 17 struct StructTraits<extensions::mojom::AttachedImageDataView, |
| 18 ::metadata::AttachedImage> { |
| 19 static const std::string& type(const ::metadata::AttachedImage& image) { |
| 20 return image.type; |
| 21 } |
| 22 |
| 23 static ConstCArray<uint8_t> data(const ::metadata::AttachedImage& image) { |
| 24 // TODO(dcheng): perhaps metadata::AttachedImage should consider passing the |
| 25 // image data around in a std::vector<uint8_t>. |
| 26 return ConstCArray<uint8_t>( |
| 27 image.data.size(), reinterpret_cast<const uint8_t*>(image.data.data())); |
| 28 } |
| 29 |
| 30 static bool Read(extensions::mojom::AttachedImageDataView view, |
| 31 ::metadata::AttachedImage* out); |
| 32 }; |
| 33 |
| 34 } // namespace mojo |
| 35 |
| 36 #endif // CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |
OLD | NEW |