From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- ipc/glue/IPDLParamTraits.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 ipc/glue/IPDLParamTraits.h (limited to 'ipc/glue/IPDLParamTraits.h') diff --git a/ipc/glue/IPDLParamTraits.h b/ipc/glue/IPDLParamTraits.h new file mode 100644 index 0000000000..48649d92de --- /dev/null +++ b/ipc/glue/IPDLParamTraits.h @@ -0,0 +1,65 @@ +/* -*- 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 mozilla_ipc_IPDLParamTraits_h +#define mozilla_ipc_IPDLParamTraits_h + +#include "chrome/common/ipc_message_utils.h" +#include "ipc/IPCMessageUtilsSpecializations.h" +#include "mozilla/UniquePtr.h" +#include "mozilla/Variant.h" + +#include "nsTArray.h" + +#include + +namespace mozilla { +namespace ipc { + +class IProtocol; + +// +// IPDLParamTraits was an extended version of ParamTraits. Unlike ParamTraits, +// IPDLParamTraits passes an additional IProtocol* argument to the +// write and read methods. +// +// Previously this was required for serializing and deserializing types which +// require knowledge of which protocol they're being sent over, however the +// actor is now available through `IPC::Message{Writer,Reader}::GetActor()` so +// the extra argument is no longer necessary. Please use `IPC::ParamTraits` in +// the future. +// +// Types which implement IPDLParamTraits are also supported by ParamTraits. +// +template +struct IPDLParamTraits {}; + +// +// WriteIPDLParam and ReadIPDLParam are like IPC::WriteParam and IPC::ReadParam, +// however, they also accept a redundant extra actor argument. +// +// NOTE: WriteIPDLParam takes a universal reference, so that it can support +// whatever reference type is supported by the underlying ParamTraits::Write +// implementation. +// +template +static MOZ_NEVER_INLINE void WriteIPDLParam(IPC::MessageWriter* aWriter, + IProtocol* aActor, P&& aParam) { + MOZ_ASSERT(aActor == aWriter->GetActor()); + IPC::WriteParam(aWriter, std::forward

(aParam)); +} + +template +static MOZ_NEVER_INLINE bool ReadIPDLParam(IPC::MessageReader* aReader, + IProtocol* aActor, P* aResult) { + MOZ_ASSERT(aActor == aReader->GetActor()); + return IPC::ReadParam(aReader, aResult); +} + +} // namespace ipc +} // namespace mozilla + +#endif // defined(mozilla_ipc_IPDLParamTraits_h) -- cgit v1.2.3