2020-12-10 14:09:21 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef __IPC_GLUE_IPCMESSAGEUTILSSPECIALIZATIONS_H__
|
|
|
|
#define __IPC_GLUE_IPCMESSAGEUTILSSPECIALIZATIONS_H__
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <limits>
|
|
|
|
#include <string>
|
|
|
|
#include <type_traits>
|
|
|
|
#include <unordered_map>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
|
|
|
#include "chrome/common/ipc_message.h"
|
|
|
|
#include "chrome/common/ipc_message_utils.h"
|
|
|
|
#include "ipc/EnumSerializer.h"
|
|
|
|
#include "ipc/IPCMessageUtils.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
|
|
|
#include "mozilla/BitSet.h"
|
|
|
|
#include "mozilla/EnumSet.h"
|
|
|
|
#include "mozilla/EnumTypeTraits.h"
|
|
|
|
#include "mozilla/IntegerRange.h"
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#ifdef XP_WIN
|
|
|
|
# include "mozilla/TimeStamp_windows.h"
|
|
|
|
#endif
|
2023-03-27 10:20:25 +03:00
|
|
|
|
2021-09-29 01:01:35 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
#include "mozilla/Unused.h"
|
|
|
|
#include "mozilla/Vector.h"
|
|
|
|
#include "mozilla/dom/ipc/StructuredCloneData.h"
|
2024-01-11 20:24:03 +03:00
|
|
|
#include "mozilla/dom/UserActivation.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
#include "nsCSSPropertyID.h"
|
|
|
|
#include "nsDebug.h"
|
2020-12-16 14:36:47 +03:00
|
|
|
#include "nsIContentPolicy.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
#include "nsID.h"
|
|
|
|
#include "nsILoadInfo.h"
|
|
|
|
#include "nsIThread.h"
|
|
|
|
#include "nsLiteralString.h"
|
2022-12-02 19:15:53 +03:00
|
|
|
#include "nsNetUtil.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
2021-03-23 13:36:37 +03:00
|
|
|
#include "nsTHashSet.h"
|
2020-12-10 14:09:21 +03:00
|
|
|
|
|
|
|
// XXX Includes that are only required by implementations which could be moved
|
|
|
|
// to the cpp file.
|
|
|
|
#include "base/string_util.h" // for StringPrintf
|
|
|
|
#include "mozilla/ArrayUtils.h" // for ArrayLength
|
|
|
|
#include "mozilla/CheckedInt.h"
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning(disable : 4800)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
template <typename... Ts>
|
|
|
|
class Variant;
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
template <typename... Ts>
|
|
|
|
struct VariantTag;
|
|
|
|
}
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
namespace mozilla::dom {
|
|
|
|
template <typename T>
|
|
|
|
class Optional;
|
|
|
|
}
|
|
|
|
|
2021-04-27 11:20:18 +03:00
|
|
|
class nsAtom;
|
|
|
|
|
2020-12-10 14:09:21 +03:00
|
|
|
namespace IPC {
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
template <class T>
|
|
|
|
struct ParamTraits<nsTSubstring<T>> {
|
|
|
|
typedef nsTSubstring<T> paramType;
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2020-12-10 14:09:21 +03:00
|
|
|
bool isVoid = aParam.IsVoid();
|
2022-03-04 18:39:41 +03:00
|
|
|
aWriter->WriteBool(isVoid);
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
if (isVoid) {
|
2020-12-10 14:09:21 +03:00
|
|
|
// represents a nullptr pointer
|
|
|
|
return;
|
2022-09-28 22:25:12 +03:00
|
|
|
}
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
WriteSequenceParam<const T&>(aWriter, aParam.BeginReading(),
|
|
|
|
aParam.Length());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2020-12-10 14:09:21 +03:00
|
|
|
bool isVoid;
|
2022-09-28 22:25:12 +03:00
|
|
|
if (!aReader->ReadBool(&isVoid)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isVoid) {
|
|
|
|
aResult->SetIsVoid(true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-03-20 18:40:34 +03:00
|
|
|
return ReadSequenceParam<T>(aReader, [&](uint32_t aLength) -> T* {
|
2022-09-28 22:25:12 +03:00
|
|
|
T* data = nullptr;
|
|
|
|
aResult->GetMutableData(&data, aLength);
|
|
|
|
return data;
|
|
|
|
});
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
template <class T>
|
|
|
|
struct ParamTraits<nsTString<T>> : ParamTraits<nsTSubstring<T>> {};
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
template <class T>
|
|
|
|
struct ParamTraits<nsTLiteralString<T>> : ParamTraits<nsTSubstring<T>> {};
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
template <class T, size_t N>
|
|
|
|
struct ParamTraits<nsTAutoStringN<T, N>> : ParamTraits<nsTSubstring<T>> {};
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
template <class T>
|
|
|
|
struct ParamTraits<nsTDependentString<T>> : ParamTraits<nsTSubstring<T>> {};
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2021-03-23 13:36:37 +03:00
|
|
|
// XXX While this has no special dependencies, it's currently only used in
|
|
|
|
// GfxMessageUtils and could be moved there, or generalized to potentially work
|
|
|
|
// with any nsTHashSet.
|
2020-12-10 14:09:21 +03:00
|
|
|
template <>
|
2021-03-23 13:36:37 +03:00
|
|
|
struct ParamTraits<nsTHashSet<uint64_t>> {
|
|
|
|
typedef nsTHashSet<uint64_t> paramType;
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2020-12-10 14:09:21 +03:00
|
|
|
uint32_t count = aParam.Count();
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, count);
|
2021-03-23 13:36:37 +03:00
|
|
|
for (const auto& key : aParam) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, key);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2020-12-10 14:09:21 +03:00
|
|
|
uint32_t count;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &count)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
paramType table(count);
|
|
|
|
for (uint32_t i = 0; i < count; ++i) {
|
|
|
|
uint64_t key;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &key)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
2021-03-23 13:36:37 +03:00
|
|
|
table.Insert(key);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
*aResult = std::move(table);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename E>
|
|
|
|
struct ParamTraits<nsTArray<E>> {
|
|
|
|
typedef nsTArray<E> paramType;
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteSequenceParam<const E&>(aWriter, aParam.Elements(), aParam.Length());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static void Write(MessageWriter* aWriter, paramType&& aParam) {
|
|
|
|
WriteSequenceParam<E&&>(aWriter, aParam.Elements(), aParam.Length());
|
2022-03-04 18:39:41 +03:00
|
|
|
}
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2023-03-20 18:40:34 +03:00
|
|
|
return ReadSequenceParam<E>(aReader, [&](uint32_t aLength) {
|
|
|
|
if constexpr (std::is_trivially_default_constructible_v<E>) {
|
|
|
|
return aResult->AppendElements(aLength);
|
|
|
|
} else {
|
|
|
|
aResult->SetCapacity(aLength);
|
|
|
|
return mozilla::Some(MakeBackInserter(*aResult));
|
|
|
|
}
|
2022-09-28 22:25:12 +03:00
|
|
|
});
|
2022-03-04 18:39:41 +03:00
|
|
|
}
|
2020-12-10 14:09:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename E>
|
|
|
|
struct ParamTraits<CopyableTArray<E>> : ParamTraits<nsTArray<E>> {};
|
|
|
|
|
|
|
|
template <typename E>
|
|
|
|
struct ParamTraits<FallibleTArray<E>> {
|
|
|
|
typedef FallibleTArray<E> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2022-09-28 22:25:12 +03:00
|
|
|
WriteSequenceParam<const E&>(aWriter, aParam.Elements(), aParam.Length());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static void Write(MessageWriter* aWriter, paramType&& aParam) {
|
|
|
|
WriteSequenceParam<E&&>(aWriter, aParam.Elements(), aParam.Length());
|
|
|
|
}
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2023-03-20 18:40:34 +03:00
|
|
|
return ReadSequenceParam<E>(aReader, [&](uint32_t aLength) {
|
|
|
|
if constexpr (std::is_trivially_default_constructible_v<E>) {
|
|
|
|
return aResult->AppendElements(aLength, mozilla::fallible);
|
|
|
|
} else {
|
|
|
|
if (!aResult->SetCapacity(aLength, mozilla::fallible)) {
|
|
|
|
return mozilla::Maybe<BackInserter>{};
|
|
|
|
}
|
|
|
|
return mozilla::Some(BackInserter{.mArray = aResult});
|
|
|
|
}
|
2022-09-28 22:25:12 +03:00
|
|
|
});
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
2023-03-20 18:40:34 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct BackInserter {
|
|
|
|
using iterator_category = std::output_iterator_tag;
|
|
|
|
using value_type = void;
|
|
|
|
using difference_type = void;
|
|
|
|
using pointer = void;
|
|
|
|
using reference = void;
|
|
|
|
|
|
|
|
struct Proxy {
|
|
|
|
paramType& mArray;
|
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
void operator=(U&& aValue) {
|
|
|
|
// This won't fail because we've reserved capacity earlier.
|
|
|
|
MOZ_ALWAYS_TRUE(mArray.AppendElement(aValue, mozilla::fallible));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Proxy operator*() { return Proxy{.mArray = *mArray}; }
|
|
|
|
|
|
|
|
BackInserter& operator++() { return *this; }
|
|
|
|
BackInserter& operator++(int) { return *this; }
|
|
|
|
|
|
|
|
paramType* mArray = nullptr;
|
|
|
|
};
|
2020-12-10 14:09:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
template <typename E, size_t N>
|
|
|
|
struct ParamTraits<AutoTArray<E, N>> : ParamTraits<nsTArray<E>> {
|
|
|
|
typedef AutoTArray<E, N> paramType;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename E, size_t N>
|
|
|
|
struct ParamTraits<CopyableAutoTArray<E, N>> : ParamTraits<AutoTArray<E, N>> {};
|
|
|
|
|
2021-10-19 15:01:50 +03:00
|
|
|
template <typename T>
|
|
|
|
struct ParamTraits<mozilla::dom::Sequence<T>> : ParamTraits<FallibleTArray<T>> {
|
|
|
|
};
|
|
|
|
|
2020-12-10 14:09:21 +03:00
|
|
|
template <typename E, size_t N, typename AP>
|
|
|
|
struct ParamTraits<mozilla::Vector<E, N, AP>> {
|
|
|
|
typedef mozilla::Vector<E, N, AP> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2022-09-28 22:25:12 +03:00
|
|
|
WriteSequenceParam<const E&>(aWriter, aParam.Elements(), aParam.Length());
|
|
|
|
}
|
2020-12-10 14:09:21 +03:00
|
|
|
|
2022-09-28 22:25:12 +03:00
|
|
|
static void Write(MessageWriter* aWriter, paramType&& aParam) {
|
|
|
|
WriteSequenceParam<E&&>(aWriter, aParam.Elements(), aParam.Length());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2023-03-20 18:40:34 +03:00
|
|
|
return ReadSequenceParam<E>(aReader, [&](uint32_t aLength) -> E* {
|
2022-09-28 22:25:12 +03:00
|
|
|
if (!aResult->resize(aLength)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
// So that OOM failure shows up as OOM crash instead of IPC FatalError.
|
2022-09-28 22:25:12 +03:00
|
|
|
NS_ABORT_OOM(aLength * sizeof(E));
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
2022-09-28 22:25:12 +03:00
|
|
|
return aResult->begin();
|
|
|
|
});
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename E>
|
|
|
|
struct ParamTraits<std::vector<E>> {
|
|
|
|
typedef std::vector<E> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2022-09-28 22:25:12 +03:00
|
|
|
WriteSequenceParam<const E&>(aWriter, aParam.data(), aParam.size());
|
|
|
|
}
|
|
|
|
static void Write(MessageWriter* aWriter, paramType&& aParam) {
|
|
|
|
WriteSequenceParam<E&&>(aWriter, aParam.data(), aParam.size());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2023-03-20 18:40:34 +03:00
|
|
|
return ReadSequenceParam<E>(aReader, [&](uint32_t aLength) {
|
|
|
|
if constexpr (std::is_trivially_default_constructible_v<E>) {
|
|
|
|
aResult->resize(aLength);
|
|
|
|
return aResult->data();
|
|
|
|
} else {
|
|
|
|
aResult->reserve(aLength);
|
|
|
|
return mozilla::Some(std::back_inserter(*aResult));
|
|
|
|
}
|
2022-09-28 22:25:12 +03:00
|
|
|
});
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename K, typename V>
|
|
|
|
struct ParamTraits<std::unordered_map<K, V>> final {
|
|
|
|
using T = std::unordered_map<K, V>;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* const writer, const T& in) {
|
|
|
|
WriteParam(writer, in.size());
|
2020-12-10 14:09:21 +03:00
|
|
|
for (const auto& pair : in) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(writer, pair.first);
|
|
|
|
WriteParam(writer, pair.second);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* const reader, T* const out) {
|
2020-12-10 14:09:21 +03:00
|
|
|
size_t size = 0;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(reader, &size)) return false;
|
2020-12-10 14:09:21 +03:00
|
|
|
T map;
|
|
|
|
map.reserve(size);
|
|
|
|
for (const auto i : mozilla::IntegerRange(size)) {
|
|
|
|
std::pair<K, V> pair;
|
|
|
|
mozilla::Unused << i;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(reader, &(pair.first)) ||
|
|
|
|
!ReadParam(reader, &(pair.second))) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
map.insert(std::move(pair));
|
|
|
|
}
|
|
|
|
*out = std::move(map);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<float> {
|
|
|
|
typedef float paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
aWriter->WriteBytes(&aParam, sizeof(paramType));
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return aReader->ReadBytesInto(aResult, sizeof(*aResult));
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsCSSPropertyID>
|
|
|
|
: public ContiguousEnumSerializer<nsCSSPropertyID, eCSSProperty_UNKNOWN,
|
|
|
|
eCSSProperty_COUNT> {};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsID> {
|
|
|
|
typedef nsID paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.m0);
|
|
|
|
WriteParam(aWriter, aParam.m1);
|
|
|
|
WriteParam(aWriter, aParam.m2);
|
2020-12-10 14:09:21 +03:00
|
|
|
for (unsigned int i = 0; i < mozilla::ArrayLength(aParam.m3); i++) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, aParam.m3[i]);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
if (!ReadParam(aReader, &(aResult->m0)) ||
|
|
|
|
!ReadParam(aReader, &(aResult->m1)) ||
|
|
|
|
!ReadParam(aReader, &(aResult->m2)))
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < mozilla::ArrayLength(aResult->m3); i++)
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &(aResult->m3[i]))) return false;
|
2020-12-10 14:09:21 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
2020-12-16 14:36:47 +03:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsContentPolicyType>
|
2023-01-18 16:46:33 +03:00
|
|
|
: public ContiguousEnumSerializer<nsContentPolicyType,
|
|
|
|
nsIContentPolicy::TYPE_INVALID,
|
|
|
|
nsIContentPolicy::TYPE_END> {};
|
2020-12-10 14:09:21 +03:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::TimeDuration> {
|
|
|
|
typedef mozilla::TimeDuration paramType;
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.mValue);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return ReadParam(aReader, &aResult->mValue);
|
2020-12-10 14:09:21 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::TimeStamp> {
|
|
|
|
typedef mozilla::TimeStamp paramType;
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.mValue);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return ReadParam(aReader, &aResult->mValue);
|
2020-12-10 14:09:21 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::TimeStampValue> {
|
|
|
|
typedef mozilla::TimeStampValue paramType;
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.mGTC);
|
|
|
|
WriteParam(aWriter, aParam.mQPC);
|
|
|
|
WriteParam(aWriter, aParam.mIsNull);
|
|
|
|
WriteParam(aWriter, aParam.mHasQPC);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return (ReadParam(aReader, &aResult->mGTC) &&
|
|
|
|
ReadParam(aReader, &aResult->mQPC) &&
|
|
|
|
ReadParam(aReader, &aResult->mIsNull) &&
|
|
|
|
ReadParam(aReader, &aResult->mHasQPC));
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::dom::ipc::StructuredCloneData> {
|
|
|
|
typedef mozilla::dom::ipc::StructuredCloneData paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
aParam.WriteIPCParams(aWriter);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return aResult->ReadIPCParams(aReader);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct ParamTraits<mozilla::Maybe<T>> {
|
|
|
|
typedef mozilla::Maybe<T> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* writer, const paramType& param) {
|
2020-12-10 14:09:21 +03:00
|
|
|
if (param.isSome()) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(writer, true);
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(writer, param.ref());
|
|
|
|
} else {
|
|
|
|
WriteParam(writer, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void Write(MessageWriter* writer, paramType&& param) {
|
|
|
|
if (param.isSome()) {
|
|
|
|
WriteParam(writer, true);
|
|
|
|
WriteParam(writer, std::move(param.ref()));
|
2020-12-10 14:09:21 +03:00
|
|
|
} else {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(writer, false);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* reader, paramType* result) {
|
2020-12-10 14:09:21 +03:00
|
|
|
bool isSome;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(reader, &isSome)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (isSome) {
|
2023-03-20 18:40:38 +03:00
|
|
|
mozilla::Maybe<T> tmp = ReadParam<T>(reader).TakeMaybe();
|
2023-02-04 14:12:36 +03:00
|
|
|
if (!tmp) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
2023-02-04 14:12:36 +03:00
|
|
|
*result = std::move(tmp);
|
2020-12-10 14:09:21 +03:00
|
|
|
} else {
|
|
|
|
*result = mozilla::Nothing();
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T, typename U>
|
|
|
|
struct ParamTraits<mozilla::EnumSet<T, U>> {
|
|
|
|
typedef mozilla::EnumSet<T, U> paramType;
|
|
|
|
typedef U serializedType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* writer, const paramType& param) {
|
2020-12-10 14:09:21 +03:00
|
|
|
MOZ_RELEASE_ASSERT(IsLegalValue(param.serialize()));
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(writer, param.serialize());
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* reader, paramType* result) {
|
2020-12-10 14:09:21 +03:00
|
|
|
serializedType tmp;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
if (ReadParam(reader, &tmp)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
if (IsLegalValue(tmp)) {
|
|
|
|
result->deserialize(tmp);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr serializedType AllEnumBits() {
|
|
|
|
return ~serializedType(0) >> (std::numeric_limits<serializedType>::digits -
|
|
|
|
(mozilla::MaxEnumValue<T>::value + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr bool IsLegalValue(const serializedType value) {
|
|
|
|
static_assert(mozilla::MaxEnumValue<T>::value <
|
|
|
|
std::numeric_limits<serializedType>::digits,
|
|
|
|
"Enum max value is not in the range!");
|
|
|
|
static_assert(
|
|
|
|
std::is_unsigned<decltype(mozilla::MaxEnumValue<T>::value)>::value,
|
|
|
|
"Type of MaxEnumValue<T>::value specialization should be unsigned!");
|
|
|
|
|
|
|
|
return (value & AllEnumBits()) == value;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class... Ts>
|
|
|
|
struct ParamTraits<mozilla::Variant<Ts...>> {
|
|
|
|
typedef mozilla::Variant<Ts...> paramType;
|
|
|
|
using Tag = typename mozilla::detail::VariantTag<Ts...>::Type;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* writer, const paramType& param) {
|
|
|
|
WriteParam(writer, param.tag);
|
|
|
|
param.match([writer](const auto& t) { WriteParam(writer, t); });
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Because VariantReader is a nested struct, we need the dummy template
|
|
|
|
// parameter to avoid making VariantReader<0> an explicit specialization,
|
|
|
|
// which is not allowed for a nested class template
|
|
|
|
template <size_t N, typename dummy = void>
|
|
|
|
struct VariantReader {
|
|
|
|
using Next = VariantReader<N - 1>;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* reader, Tag tag, paramType* result) {
|
2020-12-10 14:09:21 +03:00
|
|
|
// Since the VariantReader specializations start at N , we need to
|
|
|
|
// subtract one to look at N - 1, the first valid tag. This means our
|
|
|
|
// comparisons are off by 1. If we get to N = 0 then we have failed to
|
|
|
|
// find a match to the tag.
|
|
|
|
if (tag == N - 1) {
|
|
|
|
// Recall, even though the template parameter is N, we are
|
|
|
|
// actually interested in the N - 1 tag.
|
|
|
|
// Default construct our field within the result outparameter and
|
|
|
|
// directly deserialize into the variant. Note that this means that
|
|
|
|
// every type in Ts needs to be default constructible
|
2022-03-04 18:39:41 +03:00
|
|
|
return ReadParam(reader, &result->template emplace<N - 1>());
|
2020-12-10 14:09:21 +03:00
|
|
|
} else {
|
2022-03-04 18:39:41 +03:00
|
|
|
return Next::Read(reader, tag, result);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}; // VariantReader<N>
|
|
|
|
|
|
|
|
// Since we are conditioning on tag = N - 1 in the preceding specialization,
|
|
|
|
// if we get to `VariantReader<0, dummy>` we have failed to find
|
|
|
|
// a matching tag.
|
|
|
|
template <typename dummy>
|
|
|
|
struct VariantReader<0, dummy> {
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* reader, Tag tag, paramType* result) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* reader, paramType* result) {
|
2020-12-10 14:09:21 +03:00
|
|
|
Tag tag;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (ReadParam(reader, &tag)) {
|
|
|
|
return VariantReader<sizeof...(Ts)>::Read(reader, tag, result);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
struct ParamTraits<mozilla::dom::Optional<T>> {
|
|
|
|
typedef mozilla::dom::Optional<T> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2020-12-10 14:09:21 +03:00
|
|
|
if (aParam.WasPassed()) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, true);
|
|
|
|
WriteParam(aWriter, aParam.Value());
|
2020-12-10 14:09:21 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, false);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2020-12-10 14:09:21 +03:00
|
|
|
bool wasPassed = false;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &wasPassed)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResult->Reset();
|
|
|
|
|
|
|
|
if (wasPassed) {
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->Construct())) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-04-27 11:20:18 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsAtom*> {
|
|
|
|
typedef nsAtom paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType* aParam);
|
|
|
|
static bool Read(MessageReader* aReader, RefPtr<paramType>* aResult);
|
2021-04-27 11:20:18 +03:00
|
|
|
};
|
|
|
|
|
2020-12-10 14:09:21 +03:00
|
|
|
struct CrossOriginOpenerPolicyValidator {
|
2021-02-02 21:04:05 +03:00
|
|
|
using IntegralType =
|
|
|
|
std::underlying_type_t<nsILoadInfo::CrossOriginOpenerPolicy>;
|
|
|
|
|
|
|
|
static bool IsLegalValue(const IntegralType e) {
|
|
|
|
return AreIntegralValuesEqual(e, nsILoadInfo::OPENER_POLICY_UNSAFE_NONE) ||
|
|
|
|
AreIntegralValuesEqual(e, nsILoadInfo::OPENER_POLICY_SAME_ORIGIN) ||
|
|
|
|
AreIntegralValuesEqual(
|
|
|
|
e, nsILoadInfo::OPENER_POLICY_SAME_ORIGIN_ALLOW_POPUPS) ||
|
|
|
|
AreIntegralValuesEqual(
|
|
|
|
e, nsILoadInfo::
|
|
|
|
OPENER_POLICY_SAME_ORIGIN_EMBEDDER_POLICY_REQUIRE_CORP);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool AreIntegralValuesEqual(
|
|
|
|
const IntegralType aLhs,
|
|
|
|
const nsILoadInfo::CrossOriginOpenerPolicy aRhs) {
|
|
|
|
return aLhs == static_cast<IntegralType>(aRhs);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsILoadInfo::CrossOriginOpenerPolicy>
|
|
|
|
: EnumSerializer<nsILoadInfo::CrossOriginOpenerPolicy,
|
|
|
|
CrossOriginOpenerPolicyValidator> {};
|
|
|
|
|
|
|
|
struct CrossOriginEmbedderPolicyValidator {
|
2021-02-02 21:04:05 +03:00
|
|
|
using IntegralType =
|
|
|
|
std::underlying_type_t<nsILoadInfo::CrossOriginEmbedderPolicy>;
|
|
|
|
|
|
|
|
static bool IsLegalValue(const IntegralType e) {
|
|
|
|
return AreIntegralValuesEqual(e, nsILoadInfo::EMBEDDER_POLICY_NULL) ||
|
2022-07-14 11:10:07 +03:00
|
|
|
AreIntegralValuesEqual(e,
|
|
|
|
nsILoadInfo::EMBEDDER_POLICY_REQUIRE_CORP) ||
|
|
|
|
AreIntegralValuesEqual(e,
|
|
|
|
nsILoadInfo::EMBEDDER_POLICY_CREDENTIALLESS);
|
2021-02-02 21:04:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static bool AreIntegralValuesEqual(
|
|
|
|
const IntegralType aLhs,
|
|
|
|
const nsILoadInfo::CrossOriginEmbedderPolicy aRhs) {
|
|
|
|
return aLhs == static_cast<IntegralType>(aRhs);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsILoadInfo::CrossOriginEmbedderPolicy>
|
|
|
|
: EnumSerializer<nsILoadInfo::CrossOriginEmbedderPolicy,
|
|
|
|
CrossOriginEmbedderPolicyValidator> {};
|
|
|
|
|
2023-07-14 19:13:00 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<nsIThread::QoSPriority>
|
|
|
|
: public ContiguousEnumSerializerInclusive<nsIThread::QoSPriority,
|
|
|
|
nsIThread::QOS_PRIORITY_NORMAL,
|
|
|
|
nsIThread::QOS_PRIORITY_LOW> {};
|
|
|
|
|
2020-12-10 14:09:21 +03:00
|
|
|
template <size_t N, typename Word>
|
|
|
|
struct ParamTraits<mozilla::BitSet<N, Word>> {
|
|
|
|
typedef mozilla::BitSet<N, Word> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2020-12-10 14:09:21 +03:00
|
|
|
for (Word word : aParam.Storage()) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, word);
|
2020-12-10 14:09:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2020-12-10 14:09:21 +03:00
|
|
|
for (Word& word : aResult->Storage()) {
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &word)) {
|
2020-12-10 14:09:21 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-09-29 01:01:35 +03:00
|
|
|
template <typename T>
|
|
|
|
struct ParamTraits<mozilla::UniquePtr<T>> {
|
|
|
|
typedef mozilla::UniquePtr<T> paramType;
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2021-09-29 01:01:35 +03:00
|
|
|
bool isNull = aParam == nullptr;
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, isNull);
|
2021-09-29 01:01:35 +03:00
|
|
|
|
|
|
|
if (!isNull) {
|
2022-03-04 18:39:41 +03:00
|
|
|
WriteParam(aWriter, *aParam.get());
|
2021-09-29 01:01:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
static bool Read(IPC::MessageReader* aReader, paramType* aResult) {
|
2021-09-29 01:01:35 +03:00
|
|
|
bool isNull = true;
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, &isNull)) {
|
2021-09-29 01:01:35 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isNull) {
|
|
|
|
aResult->reset();
|
|
|
|
} else {
|
|
|
|
*aResult = mozilla::MakeUnique<T>();
|
2022-03-04 18:39:41 +03:00
|
|
|
if (!ReadParam(aReader, aResult->get())) {
|
2021-09-29 01:01:35 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-04 18:39:41 +03:00
|
|
|
template <typename... Ts>
|
2023-03-27 10:20:25 +03:00
|
|
|
struct ParamTraits<std::tuple<Ts...>> {
|
|
|
|
typedef std::tuple<Ts...> paramType;
|
2022-03-04 18:39:41 +03:00
|
|
|
|
|
|
|
template <typename U>
|
|
|
|
static void Write(IPC::MessageWriter* aWriter, U&& aParam) {
|
|
|
|
WriteInternal(aWriter, std::forward<U>(aParam),
|
|
|
|
std::index_sequence_for<Ts...>{});
|
|
|
|
}
|
|
|
|
|
2023-03-27 10:20:25 +03:00
|
|
|
static bool Read(IPC::MessageReader* aReader, std::tuple<Ts...>* aResult) {
|
2022-03-04 18:39:41 +03:00
|
|
|
return ReadInternal(aReader, *aResult, std::index_sequence_for<Ts...>{});
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
template <size_t... Is>
|
|
|
|
static void WriteInternal(IPC::MessageWriter* aWriter,
|
2023-03-27 10:20:25 +03:00
|
|
|
const std::tuple<Ts...>& aParam,
|
2022-03-04 18:39:41 +03:00
|
|
|
std::index_sequence<Is...>) {
|
2023-03-27 10:20:25 +03:00
|
|
|
WriteParams(aWriter, std::get<Is>(aParam)...);
|
2022-03-04 18:39:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t... Is>
|
|
|
|
static void WriteInternal(IPC::MessageWriter* aWriter,
|
2023-03-27 10:20:25 +03:00
|
|
|
std::tuple<Ts...>&& aParam,
|
2022-03-04 18:39:41 +03:00
|
|
|
std::index_sequence<Is...>) {
|
2023-03-27 10:20:25 +03:00
|
|
|
WriteParams(aWriter, std::move(std::get<Is>(aParam))...);
|
2022-03-04 18:39:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
template <size_t... Is>
|
|
|
|
static bool ReadInternal(IPC::MessageReader* aReader,
|
2023-03-27 10:20:25 +03:00
|
|
|
std::tuple<Ts...>& aResult,
|
2022-03-04 18:39:41 +03:00
|
|
|
std::index_sequence<Is...>) {
|
2023-03-27 10:20:25 +03:00
|
|
|
return ReadParams(aReader, std::get<Is>(aResult)...);
|
2022-03-04 18:39:41 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-12-02 19:15:53 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::net::LinkHeader> {
|
|
|
|
typedef mozilla::net::LinkHeader paramType;
|
2023-10-24 10:37:47 +03:00
|
|
|
constexpr static int kNumberOfMembers = 14;
|
|
|
|
constexpr static int kSizeOfEachMember = sizeof(nsString);
|
|
|
|
constexpr static int kExpectedSizeOfParamType =
|
|
|
|
kNumberOfMembers * kSizeOfEachMember;
|
|
|
|
|
2022-12-02 19:15:53 +03:00
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
2023-10-24 10:37:47 +03:00
|
|
|
static_assert(sizeof(paramType) == kExpectedSizeOfParamType,
|
|
|
|
"All members of should be written below.");
|
|
|
|
// Bug 1860565: `aParam.mAnchor` is not written.
|
|
|
|
|
2022-12-02 19:15:53 +03:00
|
|
|
WriteParam(aWriter, aParam.mHref);
|
|
|
|
WriteParam(aWriter, aParam.mRel);
|
|
|
|
WriteParam(aWriter, aParam.mTitle);
|
2023-07-31 17:49:57 +03:00
|
|
|
WriteParam(aWriter, aParam.mNonce);
|
2022-12-02 19:15:53 +03:00
|
|
|
WriteParam(aWriter, aParam.mIntegrity);
|
|
|
|
WriteParam(aWriter, aParam.mSrcset);
|
|
|
|
WriteParam(aWriter, aParam.mSizes);
|
|
|
|
WriteParam(aWriter, aParam.mType);
|
|
|
|
WriteParam(aWriter, aParam.mMedia);
|
2024-05-06 19:59:44 +03:00
|
|
|
WriteParam(aWriter, aParam.mAnchor);
|
2022-12-02 19:15:53 +03:00
|
|
|
WriteParam(aWriter, aParam.mCrossOrigin);
|
|
|
|
WriteParam(aWriter, aParam.mReferrerPolicy);
|
|
|
|
WriteParam(aWriter, aParam.mAs);
|
2023-10-24 10:37:47 +03:00
|
|
|
WriteParam(aWriter, aParam.mFetchPriority);
|
2022-12-02 19:15:53 +03:00
|
|
|
}
|
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
2023-10-24 10:37:47 +03:00
|
|
|
static_assert(sizeof(paramType) == kExpectedSizeOfParamType,
|
|
|
|
"All members of should be handled below.");
|
|
|
|
// Bug 1860565: `aParam.mAnchor` is not handled.
|
|
|
|
|
2022-12-02 19:15:53 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mHref)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mRel)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mTitle)) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-07-31 17:49:57 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mNonce)) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-12-02 19:15:53 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mIntegrity)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mSrcset)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mSizes)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mType)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mMedia)) {
|
|
|
|
return false;
|
|
|
|
}
|
2024-05-06 19:59:44 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mAnchor)) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-12-02 19:15:53 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mCrossOrigin)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!ReadParam(aReader, &aResult->mReferrerPolicy)) {
|
|
|
|
return false;
|
|
|
|
}
|
2023-10-24 10:37:47 +03:00
|
|
|
if (!ReadParam(aReader, &aResult->mAs)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return ReadParam(aReader, &aResult->mFetchPriority);
|
2022-12-02 19:15:53 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-01-11 20:24:03 +03:00
|
|
|
template <>
|
|
|
|
struct ParamTraits<mozilla::dom::UserActivation::Modifiers> {
|
|
|
|
typedef mozilla::dom::UserActivation::Modifiers paramType;
|
|
|
|
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
|
|
|
WriteParam(aWriter, aParam.mModifiers);
|
|
|
|
}
|
|
|
|
static bool Read(MessageReader* aReader, paramType* aResult) {
|
|
|
|
return ReadParam(aReader, &aResult->mModifiers);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-12-10 14:09:21 +03:00
|
|
|
} /* namespace IPC */
|
|
|
|
|
|
|
|
#endif /* __IPC_GLUE_IPCMESSAGEUTILSSPECIALIZATIONS_H__ */
|