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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_
6 #define CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_
7
8 #include "third_party/WebKit/public/platform/modules/mediasession/media_session. mojom.h"
9
10 namespace mojo {
11
12 template <>
13 struct StructTraits<blink::mojom::MediaImageDataView,
14 content::MediaMetadata::Artwork> {
15 static const GURL& src(const content::MediaMetadata::Artwork& artwork) {
16 return artwork.src;
17 }
18
19 static const base::string16& type(
20 const content::MediaMetadata::Artwork& artwork) {
21 return artwork.type;
22 }
23
24 static const std::vector<gfx::Size>& sizes(
25 const content::MediaMetadata::Artwork& artwork) {
26 return artwork.sizes;
27 }
28
29 static bool Read(blink::mojom::MediaImageDataView data,
30 content::MediaMetadata::Artwork* out) {
31 if (!data.ReadSrc(&out->src))
32 return false;
33 if (!data.ReadType(&out->type))
34 return false;
35 if (!data.ReadSizes(&out->sizes))
36 return false;
37
38 return true;
39 }
40 };
41
42 template <>
43 struct StructTraits<blink::mojom::MediaMetadataDataView,
44 content::MediaMetadata> {
45 static const base::string16& title(const content::MediaMetadata& metadata) {
46 return metadata.title;
47 }
48
49 static const base::string16& artist(const content::MediaMetadata& metadata) {
50 return metadata.artist;
51 }
52
53 static const base::string16& album(const content::MediaMetadata& metadata) {
54 return metadata.album;
55 }
56
57 static const std::vector<content::MediaMetadata::Artwork>& artwork(
58 const content::MediaMetadata& metadata) {
59 return metadata.artwork;
60 }
61
62 static bool Read(blink::mojom::MediaMetadataDataView data,
63 content::MediaMetadata* out) {
64 if (!data.ReadTitle(&out->title))
65 return false;
66 if (!data.ReadArtist(&out->artist))
67 return false;
68 if (!data.ReadAlbum(&out->album))
69 return false;
70 if (!data.ReadArtwork(&out->artwork))
71 return false;
72
73 return true;
74 }
75 };
76
77 } // namespace mojo
78
79 #endif // CONTENT_COMMON_MEDIA_MEDIA_SESSION_STRUCT_TRAITS_H_
OLDNEW
« 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