mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibWebView+Services+UI: Move process helpers to LibWebView
This commit is contained in:
parent
a14937c45e
commit
0ff91a5273
Notes:
github-actions[bot]
2024-11-11 12:36:39 +00:00
Author: https://github.com/trflynn89
Commit: 0ff91a5273
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2269
29 changed files with 110 additions and 119 deletions
57
Libraries/LibWebView/MachPortServer.h
Normal file
57
Libraries/LibWebView/MachPortServer.h
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/MachPort.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
|
||||
#if !defined(AK_OS_MACH)
|
||||
# error "This file is only for Mach kernel-based OS's"
|
||||
#endif
|
||||
|
||||
namespace WebView {
|
||||
|
||||
class MachPortServer {
|
||||
|
||||
public:
|
||||
MachPortServer();
|
||||
~MachPortServer();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
bool is_initialized();
|
||||
|
||||
Function<void(pid_t, Core::MachPort)> on_receive_child_mach_port;
|
||||
struct BackingStoresMessage {
|
||||
pid_t pid { -1 };
|
||||
u64 page_id { 0 };
|
||||
i32 front_backing_store_id { 0 };
|
||||
i32 back_backing_store_id { 0 };
|
||||
Core::MachPort front_backing_store_port;
|
||||
Core::MachPort back_backing_store_port;
|
||||
};
|
||||
Function<void(BackingStoresMessage)> on_receive_backing_stores;
|
||||
|
||||
ByteString const& server_port_name() const { return m_server_port_name; }
|
||||
|
||||
private:
|
||||
void thread_loop();
|
||||
ErrorOr<void> allocate_server_port();
|
||||
|
||||
NonnullRefPtr<Threading::Thread> m_thread;
|
||||
ByteString const m_server_port_name;
|
||||
Core::MachPort m_server_port_recv_right;
|
||||
Core::MachPort m_server_port_send_right;
|
||||
|
||||
Atomic<bool> m_should_stop { false };
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue