Index: chrome/common/extensions/media_parser_struct_traits.cc |
diff --git a/chrome/common/extensions/media_parser_struct_traits.cc b/chrome/common/extensions/media_parser_struct_traits.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a93fc262a8849835a19176142bf55676d51168b9 |
--- /dev/null |
+++ b/chrome/common/extensions/media_parser_struct_traits.cc |
@@ -0,0 +1,30 @@ |
+// 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. |
+ |
+#include "chrome/common/extensions/media_parser_struct_traits.h" |
+#include "mojo/public/cpp/bindings/array_data_view.h" |
+ |
+namespace { |
+ |
+using TypeImageDataView = extensions::mojom::AttachedImageDataView; |
+using TypeImage = ::metadata::AttachedImage; |
+ |
+} // namespace |
+ |
+namespace mojo { |
+ |
+// static |
+bool StructTraits<TypeImageDataView, TypeImage>::Read(TypeImageDataView view, |
+ TypeImage* out) { |
+ if (!view.ReadType(&out->type)) |
+ return false; |
+ |
+ ArrayDataView<uint8_t> data; |
+ view.GetDataDataView(&data); |
+ |
+ out->data.assign(reinterpret_cast<const char*>(data.data()), data.size()); |
+ return true; |
+} |
+ |
+} // namespace mojo |