Chromium Code Reviews| Index: chrome/common/extensions/media_parser_struct_traits.h |
| diff --git a/chrome/common/extensions/media_parser_struct_traits.h b/chrome/common/extensions/media_parser_struct_traits.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..141738a920485993cf3855e0e0034eb0772724ae |
| --- /dev/null |
| +++ b/chrome/common/extensions/media_parser_struct_traits.h |
| @@ -0,0 +1,38 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |
| +#define CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |
| + |
| +#include <string> |
| + |
| +#include "chrome/common/extensions/media_parser.mojom.h" |
| +#include "chrome/common/media_galleries/metadata_types.h" |
| + |
| +namespace mojo { |
| + |
| +using AttachedImageData = extensions::mojom::AttachedImageDataView; |
|
tibell
2017/01/09 03:55:52
Do we allow using in .h files? Doesn't it pollute
Noel Gordon
2017/01/09 14:54:19
Done.
|
| + |
| +template <> |
| +struct StructTraits<AttachedImageData, metadata::AttachedImage> { |
| + static const std::string& type(const metadata::AttachedImage& image) { |
| + return image.type; |
| + } |
| + |
| + static const std::string& data(const metadata::AttachedImage& image) { |
| + return image.data; |
| + } |
| + |
| + static bool Read(AttachedImageData view, metadata::AttachedImage* out) { |
| + if (!view.ReadType(&out->type)) |
| + return false; |
| + if (!view.ReadData(&out->data)) |
| + return false; |
| + return true; |
| + } |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ |