tor-browser

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

OriginTrialsIPCUtils.h (1227B)


      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 mozilla_OriginTrialsIPCUtils_h
      8 #define mozilla_OriginTrialsIPCUtils_h
      9 
     10 #include "ipc/EnumSerializer.h"
     11 #include "mozilla/EnumTypeTraits.h"
     12 #include "mozilla/OriginTrials.h"
     13 
     14 namespace mozilla {
     15 template <>
     16 struct MaxEnumValue<OriginTrial> {
     17  static constexpr unsigned int value =
     18      static_cast<unsigned int>(OriginTrial::MAX);
     19 };
     20 }  // namespace mozilla
     21 
     22 namespace IPC {
     23 
     24 template <>
     25 struct ParamTraits<mozilla::OriginTrials> {
     26  using paramType = mozilla::OriginTrials;
     27  using RawType = mozilla::OriginTrials::RawType;
     28 
     29  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     30    WriteParam(aWriter, aParam.Raw());
     31  }
     32 
     33  static bool Read(MessageReader* aReader, paramType* aResult) {
     34    RawType raw;
     35    if (!ReadParam(aReader, &raw)) {
     36      return false;
     37    }
     38    *aResult = mozilla::OriginTrials::FromRaw(raw);
     39    return true;
     40  }
     41 };
     42 
     43 }  // namespace IPC
     44 
     45 #endif