mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 03:25:13 +00:00
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macos-15, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Bring back 2d625f5c23
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Error.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibIPC/Transport.h>
|
|
|
|
namespace IPC {
|
|
|
|
class MessageBuffer {
|
|
public:
|
|
MessageBuffer();
|
|
|
|
MessageBuffer(Vector<u8, 1024> data, Vector<NonnullRefPtr<AutoCloseFileDescriptor>, 1> fds)
|
|
: m_data(move(data))
|
|
, m_fds(move(fds))
|
|
{
|
|
}
|
|
|
|
ErrorOr<void> extend_data_capacity(size_t capacity);
|
|
ErrorOr<void> append_data(u8 const* values, size_t count);
|
|
|
|
ErrorOr<void> append_file_descriptor(int fd);
|
|
|
|
ErrorOr<void> transfer_message(Transport& transport);
|
|
|
|
auto const& data() const { return m_data; }
|
|
auto take_fds() { return move(m_fds); }
|
|
|
|
private:
|
|
Vector<u8, 1024> m_data;
|
|
Vector<NonnullRefPtr<AutoCloseFileDescriptor>, 1> m_fds;
|
|
#ifdef AK_OS_WINDOWS
|
|
Vector<size_t> m_handle_offsets;
|
|
#endif
|
|
};
|
|
|
|
enum class ErrorCode : u32 {
|
|
PeerDisconnected
|
|
};
|
|
|
|
template<typename Value>
|
|
using IPCErrorOr = ErrorOr<Value, ErrorCode>;
|
|
|
|
class Message {
|
|
public:
|
|
virtual ~Message() = default;
|
|
|
|
virtual u32 endpoint_magic() const = 0;
|
|
virtual int message_id() const = 0;
|
|
virtual char const* message_name() const = 0;
|
|
virtual ErrorOr<MessageBuffer> encode() const = 0;
|
|
|
|
protected:
|
|
Message() = default;
|
|
};
|
|
|
|
}
|