Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / media / mediasession / MediaSessionIPCUtils.h
blob610b123b6cb916021dd19c1e9920242f2e3e4ae6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #ifndef DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
6 #define DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_
8 #include "ipc/EnumSerializer.h"
9 #include "mozilla/dom/BindingIPCUtils.h"
10 #include "MediaMetadata.h"
11 #include "mozilla/dom/MediaSession.h"
12 #include "mozilla/dom/MediaSessionBinding.h"
13 #include "mozilla/Maybe.h"
15 namespace mozilla {
16 namespace dom {
18 typedef Maybe<MediaMetadataBase> MaybeMediaMetadataBase;
20 } // namespace dom
21 } // namespace mozilla
23 namespace IPC {
25 template <>
26 struct ParamTraits<mozilla::dom::MediaImage> {
27 typedef mozilla::dom::MediaImage paramType;
29 static void Write(MessageWriter* aWriter, const paramType& aParam) {
30 WriteParam(aWriter, aParam.mSizes);
31 WriteParam(aWriter, aParam.mSrc);
32 WriteParam(aWriter, aParam.mType);
35 static bool Read(MessageReader* aReader, paramType* aResult) {
36 if (!ReadParam(aReader, &(aResult->mSizes)) ||
37 !ReadParam(aReader, &(aResult->mSrc)) ||
38 !ReadParam(aReader, &(aResult->mType))) {
39 return false;
41 return true;
45 template <>
46 struct ParamTraits<mozilla::dom::MediaMetadataBase> {
47 typedef mozilla::dom::MediaMetadataBase paramType;
49 static void Write(MessageWriter* aWriter, const paramType& aParam) {
50 WriteParam(aWriter, aParam.mTitle);
51 WriteParam(aWriter, aParam.mArtist);
52 WriteParam(aWriter, aParam.mAlbum);
53 WriteParam(aWriter, aParam.mArtwork);
56 static bool Read(MessageReader* aReader, paramType* aResult) {
57 if (!ReadParam(aReader, &(aResult->mTitle)) ||
58 !ReadParam(aReader, &(aResult->mArtist)) ||
59 !ReadParam(aReader, &(aResult->mAlbum)) ||
60 !ReadParam(aReader, &(aResult->mArtwork))) {
61 return false;
63 return true;
67 template <>
68 struct ParamTraits<mozilla::dom::PositionState> {
69 typedef mozilla::dom::PositionState paramType;
71 static void Write(MessageWriter* aWriter, const paramType& aParam) {
72 WriteParam(aWriter, aParam.mDuration);
73 WriteParam(aWriter, aParam.mPlaybackRate);
74 WriteParam(aWriter, aParam.mLastReportedPlaybackPosition);
75 WriteParam(aWriter, aParam.mPositionUpdatedTime);
78 static bool Read(MessageReader* aReader, paramType* aResult) {
79 if (!ReadParam(aReader, &(aResult->mDuration)) ||
80 !ReadParam(aReader, &(aResult->mPlaybackRate)) ||
81 !ReadParam(aReader, &(aResult->mLastReportedPlaybackPosition)) ||
82 !ReadParam(aReader, &(aResult->mPositionUpdatedTime))) {
83 return false;
85 return true;
89 template <>
90 struct ParamTraits<mozilla::dom::MediaSessionPlaybackState>
91 : public mozilla::dom::WebIDLEnumSerializer<
92 mozilla::dom::MediaSessionPlaybackState> {};
94 template <>
95 struct ParamTraits<mozilla::dom::MediaSessionAction>
96 : public mozilla::dom::WebIDLEnumSerializer<
97 mozilla::dom::MediaSessionAction> {};
99 } // namespace IPC
101 #endif // DOM_MEDIA_MEDIASESSION_MEDIASESSIONIPCUTILS_H_