Index: third_party/WebKit/Source/modules/mediasession/MediaSessionStructTraits.h |
diff --git a/third_party/WebKit/Source/modules/mediasession/MediaSessionStructTraits.h b/third_party/WebKit/Source/modules/mediasession/MediaSessionStructTraits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8d862c6c0c4235b09f2c2107674ed2c34441baf0 |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/mediasession/MediaSessionStructTraits.h |
@@ -0,0 +1,77 @@ |
+// Copyright 2016 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 "public/platform/modules/mediasession/media_session.mojom-blink.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<blink::mojom::blink::MediaImage::DataView, |
+ ::blink::MojoMediaArtwork> { |
+ static const blink::KURL& src(const ::blink::MojoMediaArtwork& artwork) { |
+ return artwork.src; |
+ } |
+ |
+ static const blink::WebString& type( |
+ const ::blink::MojoMediaArtwork& artwork) { |
+ return artwork.type; |
+ } |
+ |
+ static const WTF::Vector<blink::WebSize>& sizes( |
+ const ::blink::MojoMediaArtwork& artwork) { |
+ return artwork.sizes; |
+ } |
+ |
+ static bool Read(blink::mojom::blink::MediaImage::DataView data, |
+ ::blink::MojoMediaArtwork* out) { |
+ if (!data.ReadSrc(&out->src)) |
+ return false; |
+ if (!data.ReadType(&out->type)) |
+ return false; |
+ if (!data.ReadSizes(&out->sizes)) |
+ return false; |
+ |
+ return true; |
+ } |
+}; |
+ |
+template <> |
+struct StructTraits<blink::mojom::blink::MediaMetadata::DataView, |
+ ::blink::MojoMediaMetadata> { |
+ static const blink::WebString& title( |
+ const ::blink::MojoMediaMetadata& metadata) { |
+ return metadata.title; |
+ } |
+ |
+ static const blink::WebString& artist( |
+ const ::blink::MojoMediaMetadata& metadata) { |
+ return metadata.artist; |
+ } |
+ |
+ static const blink::WebString& album( |
+ const ::blink::MojoMediaMetadata& metadata) { |
+ return metadata.album; |
+ } |
+ |
+ static const WTF::Vector<::blink::MojoMediaArtwork>& artwork( |
+ const ::blink::MojoMediaMetadata& metadata) { |
+ return metadata.artwork; |
+ } |
+ |
+ static bool Read(blink::mojom::blink::MediaMetadata::DataView data, |
+ ::blink::MojoMediaMetadata* out) { |
+ if (!data.ReadTitle(&out->title)) |
+ return false; |
+ if (!data.ReadArtist(&out->artist)) |
+ return false; |
+ if (!data.ReadAlbum(&out->album)) |
+ return false; |
+ if (!data.ReadArtwork(&out->artwork)) |
+ return false; |
+ |
+ return true; |
+ } |
+}; |
+ |
+} // namespace mojo |