LibIPC: Move stuff from Connection.h to .cpp and reduce #include count

This commit is contained in:
Andreas Kling 2024-06-28 14:24:49 +02:00 committed by Andreas Kling
parent 6d9c4d852d
commit 4fe21e6d87
Notes: sideshowbarker 2024-07-17 18:06:52 +09:00
4 changed files with 23 additions and 17 deletions

View file

@ -5,9 +5,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/System.h>
#include <AK/Vector.h>
#include <LibCore/Socket.h>
#include <LibCore/Timer.h>
#include <LibIPC/Connection.h>
#include <LibIPC/File.h>
#include <LibIPC/Message.h>
#include <LibIPC/Stub.h>
namespace IPC {
@ -18,6 +20,19 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalS
, m_local_endpoint_magic(local_endpoint_magic)
{
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
m_socket->on_ready_to_read = [this] {
NonnullRefPtr protect = *this;
// FIXME: Do something about errors.
(void)drain_messages_from_peer();
handle_messages();
};
}
ConnectionBase::~ConnectionBase() = default;
bool ConnectionBase::is_open() const
{
return m_socket->is_open();
}
ErrorOr<void> ConnectionBase::post_message(Message const& message)

View file

@ -7,16 +7,11 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/Forward.h>
#include <AK/Queue.h>
#include <AK/Try.h>
#include <LibCore/Event.h>
#include <LibCore/EventLoop.h>
#include <LibCore/Socket.h>
#include <LibCore/Timer.h>
#include <LibCore/EventReceiver.h>
#include <LibIPC/File.h>
#include <LibIPC/Forward.h>
#include <LibIPC/Message.h>
namespace IPC {
@ -24,9 +19,9 @@ class ConnectionBase : public Core::EventReceiver {
C_OBJECT_ABSTRACT(ConnectionBase);
public:
virtual ~ConnectionBase() override = default;
virtual ~ConnectionBase() override;
bool is_open() const { return m_socket->is_open(); }
[[nodiscard]] bool is_open() const;
ErrorOr<void> post_message(Message const&);
void shutdown();
@ -70,12 +65,6 @@ public:
Connection(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalSocket> socket)
: ConnectionBase(local_stub, move(socket), LocalEndpoint::static_magic())
{
m_socket->on_ready_to_read = [this] {
NonnullRefPtr protect = *this;
// FIXME: Do something about errors.
(void)drain_messages_from_peer();
handle_messages();
};
}
template<typename MessageType>

View file

@ -8,6 +8,7 @@
#include <AK/String.h>
#include <LibCore/DateTime.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/Timer.h>
#include <LibGfx/ImageFormats/PNGWriter.h>
#include <LibWeb/Infra/Strings.h>
#include <LibWebView/ViewImplementation.h>

View file

@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/EventLoop.h>
#include <WebWorker/ConnectionFromClient.h>
#include <WebWorker/DedicatedWorkerHost.h>
#include <WebWorker/PageHost.h>