tor-browser

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

SerializationHelpers.h (3132B)


      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 file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_dom_indexeddb_serializationhelpers_h__
      8 #define mozilla_dom_indexeddb_serializationhelpers_h__
      9 
     10 #include "ipc/EnumSerializer.h"
     11 #include "ipc/IPCMessageUtilsSpecializations.h"
     12 #include "mozilla/dom/BindingIPCUtils.h"
     13 #include "mozilla/dom/IDBCursor.h"
     14 #include "mozilla/dom/IDBTransaction.h"
     15 #include "mozilla/dom/indexedDB/Key.h"
     16 #include "mozilla/dom/indexedDB/KeyPath.h"
     17 
     18 namespace IPC {
     19 
     20 template <>
     21 struct ParamTraits<mozilla::dom::indexedDB::StructuredCloneFileBase::FileType>
     22    : public ContiguousEnumSerializer<
     23          mozilla::dom::indexedDB::StructuredCloneFileBase::FileType,
     24          mozilla::dom::indexedDB::StructuredCloneFileBase::eBlob,
     25          mozilla::dom::indexedDB::StructuredCloneFileBase::eEndGuard> {};
     26 
     27 template <>
     28 struct ParamTraits<mozilla::dom::indexedDB::Key> {
     29  typedef mozilla::dom::indexedDB::Key paramType;
     30 
     31  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     32    WriteParam(aWriter, aParam.mBuffer);
     33    WriteParam(aWriter, aParam.mAutoIncrementKeyOffsets);
     34  }
     35 
     36  static bool Read(MessageReader* aReader, paramType* aResult) {
     37    return ReadParam(aReader, &aResult->mBuffer) &&
     38           ReadParam(aReader, &aResult->mAutoIncrementKeyOffsets);
     39  }
     40 };
     41 
     42 template <>
     43 struct ParamTraits<mozilla::dom::indexedDB::KeyPath::KeyPathType>
     44    : public ContiguousEnumSerializer<
     45          mozilla::dom::indexedDB::KeyPath::KeyPathType,
     46          mozilla::dom::indexedDB::KeyPath::KeyPathType::NonExistent,
     47          mozilla::dom::indexedDB::KeyPath::KeyPathType::EndGuard> {};
     48 
     49 template <>
     50 struct ParamTraits<mozilla::dom::indexedDB::KeyPath> {
     51  typedef mozilla::dom::indexedDB::KeyPath paramType;
     52 
     53  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     54    WriteParam(aWriter, aParam.mType);
     55    WriteParam(aWriter, aParam.mStrings);
     56  }
     57 
     58  static bool Read(MessageReader* aReader, paramType* aResult) {
     59    return ReadParam(aReader, &aResult->mType) &&
     60           ReadParam(aReader, &aResult->mStrings);
     61  }
     62 };
     63 
     64 template <>
     65 struct ParamTraits<mozilla::dom::IDBCursor::Direction>
     66    : public mozilla::dom::WebIDLEnumSerializer<
     67          mozilla::dom::IDBCursor::Direction> {};
     68 
     69 template <>
     70 struct ParamTraits<mozilla::dom::IDBTransaction::Mode>
     71    : public ContiguousEnumSerializer<
     72          mozilla::dom::IDBTransaction::Mode,
     73          mozilla::dom::IDBTransaction::Mode::ReadOnly,
     74          mozilla::dom::IDBTransaction::Mode::Invalid> {};
     75 
     76 template <>
     77 struct ParamTraits<mozilla::dom::IDBTransaction::Durability>
     78    : public ContiguousEnumSerializer<
     79          mozilla::dom::IDBTransaction::Durability,
     80          mozilla::dom::IDBTransaction::Durability::Default,
     81          mozilla::dom::IDBTransaction::Durability::Invalid> {};
     82 
     83 }  // namespace IPC
     84 
     85 #endif  // mozilla_dom_indexeddb_serializationhelpers_h__