tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

MediaControlIPC.h (2909B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef ipc_MediaControlIPC_h
      8 #define ipc_MediaControlIPC_h
      9 
     10 #include "ipc/EnumSerializer.h"
     11 #include "mozilla/dom/MediaControlKeySource.h"
     12 #include "mozilla/dom/MediaControllerBinding.h"
     13 #include "mozilla/dom/MediaPlaybackStatus.h"
     14 
     15 namespace IPC {
     16 template <>
     17 struct ParamTraits<mozilla::dom::MediaControlKey>
     18    : public ContiguousEnumSerializerInclusive<
     19          mozilla::dom::MediaControlKey, mozilla::dom::MediaControlKey::Focus,
     20          mozilla::dom::MediaControlKey::Stop> {};
     21 
     22 template <>
     23 struct ParamTraits<mozilla::dom::MediaPlaybackState>
     24    : public ContiguousEnumSerializerInclusive<
     25          mozilla::dom::MediaPlaybackState,
     26          mozilla::dom::MediaPlaybackState::eStarted,
     27          mozilla::dom::MediaPlaybackState::eStopped> {};
     28 
     29 template <>
     30 struct ParamTraits<mozilla::dom::MediaAudibleState>
     31    : public ContiguousEnumSerializerInclusive<
     32          mozilla::dom::MediaAudibleState,
     33          mozilla::dom::MediaAudibleState::eInaudible,
     34          mozilla::dom::MediaAudibleState::eAudible> {};
     35 
     36 template <>
     37 struct ParamTraits<mozilla::dom::AbsoluteSeek> {
     38  typedef mozilla::dom::AbsoluteSeek paramType;
     39 
     40  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     41    WriteParam(aWriter, aParam.mSeekTime);
     42    WriteParam(aWriter, aParam.mFastSeek);
     43  }
     44 
     45  static bool Read(MessageReader* aReader, paramType* aResult) {
     46    if (!ReadParam(aReader, &aResult->mSeekTime) ||
     47        !ReadParam(aReader, &aResult->mFastSeek)) {
     48      return false;
     49    }
     50    return true;
     51  }
     52 };
     53 
     54 template <>
     55 struct ParamTraits<mozilla::dom::SeekDetails> {
     56  typedef mozilla::dom::SeekDetails paramType;
     57 
     58  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     59    WriteParam(aWriter, aParam.mAbsolute);
     60    WriteParam(aWriter, aParam.mRelativeSeekOffset);
     61  }
     62 
     63  static bool Read(MessageReader* aReader, paramType* aResult) {
     64    if (!ReadParam(aReader, &aResult->mAbsolute) ||
     65        !ReadParam(aReader, &aResult->mRelativeSeekOffset)) {
     66      return false;
     67    }
     68    return true;
     69  }
     70 };
     71 
     72 template <>
     73 struct ParamTraits<mozilla::dom::MediaControlAction> {
     74  typedef mozilla::dom::MediaControlAction paramType;
     75 
     76  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     77    WriteParam(aWriter, aParam.mKey);
     78    WriteParam(aWriter, aParam.mDetails);
     79  }
     80 
     81  static bool Read(MessageReader* aReader, paramType* aResult) {
     82    if (!ReadParam(aReader, &aResult->mKey) ||
     83        !ReadParam(aReader, &aResult->mDetails)) {
     84      return false;
     85    }
     86    return true;
     87  }
     88 };
     89 
     90 }  // namespace IPC
     91 
     92 #endif  // mozilla_MediaControlIPC_hh