Index: content/common/media/media_session_struct_traits.h |
diff --git a/content/common/media/media_session_struct_traits.h b/content/common/media/media_session_struct_traits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..bff354c99410fb7f0310c5e4f7a3078a1be988b3 |
--- /dev/null |
+++ b/content/common/media/media_session_struct_traits.h |
@@ -0,0 +1,79 @@ |
+// 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. |
+ |
+#ifndef CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_ |
+#define CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_ |
+ |
+#include "third_party/WebKit/public/platform/modules/mediasession/media_session.mojom.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<blink::mojom::MediaImageDataView, |
+ content::MediaMetadata::Artwork> { |
+ static const GURL& src(const content::MediaMetadata::Artwork& artwork) { |
+ return artwork.src; |
+ } |
+ |
+ static const base::string16& type( |
+ const content::MediaMetadata::Artwork& artwork) { |
+ return artwork.type; |
+ } |
+ |
+ static const std::vector<gfx::Size>& sizes( |
+ const content::MediaMetadata::Artwork& artwork) { |
+ return artwork.sizes; |
+ } |
+ |
+ static bool Read(blink::mojom::MediaImageDataView data, |
+ content::MediaMetadata::Artwork* 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::MediaMetadataDataView, |
+ content::MediaMetadata> { |
+ static const base::string16& title(const content::MediaMetadata& metadata) { |
+ return metadata.title; |
+ } |
+ |
+ static const base::string16& artist(const content::MediaMetadata& metadata) { |
+ return metadata.artist; |
+ } |
+ |
+ static const base::string16& album(const content::MediaMetadata& metadata) { |
+ return metadata.album; |
+ } |
+ |
+ static const std::vector<content::MediaMetadata::Artwork>& artwork( |
+ const content::MediaMetadata& metadata) { |
+ return metadata.artwork; |
+ } |
+ |
+ static bool Read(blink::mojom::MediaMetadataDataView data, |
+ content::MediaMetadata* 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 |
+ |
+#endif // CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_ |