Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1839)

Unified Diff: content/common/media/media_session_struct_traits.h

Issue 2367393002: Migrating MediaSession messages to mojo (Closed)
Patch Set: fixed layout tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/media/media_session_messages_android.h ('k') | content/common/typemaps.gni » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_
« no previous file with comments | « content/common/media/media_session_messages_android.h ('k') | content/common/typemaps.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698