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/IPCStreamUtils.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 ipc/glue/IPCStreamUtils.h (limited to 'ipc/glue/IPCStreamUtils.h') diff --git a/ipc/glue/IPCStreamUtils.h b/ipc/glue/IPCStreamUtils.h new file mode 100644 index 0000000000..c681f7cf1a --- /dev/null +++ b/ipc/glue/IPCStreamUtils.h @@ -0,0 +1,51 @@ +/* -*- 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_IPCStreamUtils_h +#define mozilla_ipc_IPCStreamUtils_h + +#include "mozilla/ipc/IPCStream.h" +#include "nsCOMPtr.h" +#include "nsIInputStream.h" + +namespace mozilla::ipc { + +// Serialize an IPCStream to be sent over IPC fallibly. +// +// If |aAllowLazy| is true the stream may be serialized as a +// RemoteLazyInputStream when being sent from child to parent. +// +// ParamTraits may be used instead if serialization cannot be +// fallible. +[[nodiscard]] bool SerializeIPCStream( + already_AddRefed aInputStream, IPCStream& aValue, + bool aAllowLazy); + +// If serialization fails, `aValue` will be initialized to `Nothing()`, so this +// return value is safe to ignore. +bool SerializeIPCStream(already_AddRefed aInputStream, + Maybe& aValue, bool aAllowLazy); + +// Deserialize an IPCStream received from an actor call. These methods +// work in both the child and parent. +already_AddRefed DeserializeIPCStream(const IPCStream& aValue); + +already_AddRefed DeserializeIPCStream( + const Maybe& aValue); + +} // namespace mozilla::ipc + +namespace IPC { + +template <> +struct ParamTraits { + static void Write(MessageWriter* aWriter, nsIInputStream* aParam); + static bool Read(MessageReader* aReader, RefPtr* aResult); +}; + +} // namespace IPC + +#endif // mozilla_ipc_IPCStreamUtils_h -- cgit v1.2.3