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 | |
13 namespace mojo { | |
14 | |
15 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.
| |
16 | |
17 template <> | |
18 struct StructTraits<AttachedImageData, metadata::AttachedImage> { | |
19 static const std::string& type(const metadata::AttachedImage& image) { | |
20 return image.type; | |
21 } | |
22 | |
23 static const std::string& data(const metadata::AttachedImage& image) { | |
24 return image.data; | |
25 } | |
26 | |
27 static bool Read(AttachedImageData view, metadata::AttachedImage* out) { | |
28 if (!view.ReadType(&out->type)) | |
29 return false; | |
30 if (!view.ReadData(&out->data)) | |
31 return false; | |
32 return true; | |
33 } | |
34 }; | |
35 | |
36 } // namespace mojo | |
37 | |
38 #endif // CHROME_COMMON_EXTENSIONS_MEDIA_PARSER_STRUCT_TRAITS_H_ | |
OLD | NEW |