tor-browser

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

SerializedStructuredCloneBuffer.h (2397B)


      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_GLUE_SERIALIZEDSTRUCTUREDCLONEBUFFER_H__
      8 #define __IPC_GLUE_SERIALIZEDSTRUCTUREDCLONEBUFFER_H__
      9 
     10 #include "chrome/common/ipc_message.h"
     11 #include "chrome/common/ipc_message_utils.h"
     12 #include "js/AllocPolicy.h"
     13 #include "js/StructuredClone.h"
     14 #include "mozilla/mozalloc.h"
     15 class PickleIterator;
     16 
     17 namespace mozilla {
     18 template <typename...>
     19 class Variant;
     20 
     21 namespace detail {
     22 template <typename...>
     23 struct VariantTag;
     24 }
     25 }  // namespace mozilla
     26 
     27 namespace mozilla {
     28 
     29 struct SerializedStructuredCloneBuffer final {
     30  SerializedStructuredCloneBuffer() = default;
     31 
     32  SerializedStructuredCloneBuffer(SerializedStructuredCloneBuffer&&) = default;
     33  SerializedStructuredCloneBuffer& operator=(
     34      SerializedStructuredCloneBuffer&&) = default;
     35 
     36  SerializedStructuredCloneBuffer(const SerializedStructuredCloneBuffer&) =
     37      delete;
     38  SerializedStructuredCloneBuffer& operator=(
     39      const SerializedStructuredCloneBuffer& aOther) = delete;
     40 
     41  bool operator==(const SerializedStructuredCloneBuffer& aOther) const {
     42    // The copy assignment operator and the equality operator are
     43    // needed by the IPDL generated code. We relied on the copy
     44    // assignment operator at some places but we never use the
     45    // equality operator.
     46    return false;
     47  }
     48 
     49  JSStructuredCloneData data{JS::StructuredCloneScope::Unassigned};
     50 };
     51 
     52 }  // namespace mozilla
     53 
     54 namespace IPC {
     55 template <>
     56 struct ParamTraits<JSStructuredCloneData> {
     57  typedef JSStructuredCloneData paramType;
     58 
     59  static void Write(MessageWriter* aWriter, const paramType& aParam);
     60 
     61  static bool Read(MessageReader* aReader, paramType* aResult);
     62 };
     63 
     64 template <>
     65 struct ParamTraits<mozilla::SerializedStructuredCloneBuffer> {
     66  typedef mozilla::SerializedStructuredCloneBuffer paramType;
     67 
     68  static void Write(MessageWriter* aWriter, const paramType& aParam) {
     69    WriteParam(aWriter, aParam.data);
     70  }
     71 
     72  static bool Read(MessageReader* aReader, paramType* aResult) {
     73    return ReadParam(aReader, &aResult->data);
     74  }
     75 };
     76 
     77 }  // namespace IPC
     78 
     79 #endif /* __IPC_GLUE_SERIALIZEDSTRUCTUREDCLONEBUFFER_H__ */