Bug 1582353 - P1. Add MediaResult serializer. r=mjf

Differential Revision: https://phabricator.services.mozilla.com/D47038

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jean-Yves Avenard 2019-09-26 14:51:56 +00:00
parent 47f4838fa0
commit 301e1cb659
2 changed files with 26 additions and 0 deletions

View File

@ -21,6 +21,7 @@ namespace mozilla {
class MediaResult {
public:
MediaResult() : mCode(NS_OK) {}
MOZ_IMPLICIT MediaResult(nsresult aResult) : mCode(aResult) {}
MediaResult(nsresult aResult, const nsACString& aMessage)
: mCode(aResult), mMessage(aMessage) {}

View File

@ -166,6 +166,31 @@ struct ParamTraits<mozilla::media::TimeInterval> {
}
};
template <>
struct ParamTraits<mozilla::MediaResult> {
typedef mozilla::MediaResult paramType;
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, aParam.Code());
WriteParam(aMsg, aParam.Message());
WriteParam(aMsg, aParam.GPUCrashTimeStamp());
}
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
nsresult result;
nsCString message;
mozilla::TimeStamp timeStamp;
if (ReadParam(aMsg, aIter, &result) && ReadParam(aMsg, aIter, &message) &&
ReadParam(aMsg, aIter, &timeStamp)) {
*aResult = paramType(result, std::move(message));
aResult->SetGPUCrashTimeStamp(timeStamp);
return true;
}
return false;
};
};
} // namespace IPC
#endif // mozilla_dom_media_MediaIPCUtils_h