mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-04 01:12:56 +00:00
LibIPC: Move stuff from Connection.h to .cpp and reduce #include count
This commit is contained in:
parent
6d9c4d852d
commit
4fe21e6d87
Notes:
sideshowbarker
2024-07-17 18:06:52 +09:00
Author: https://github.com/awesomekling
Commit: 4fe21e6d87
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/303
4 changed files with 23 additions and 17 deletions
|
@ -5,9 +5,11 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* 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/Connection.h>
|
||||||
#include <LibIPC/File.h>
|
#include <LibIPC/Message.h>
|
||||||
#include <LibIPC/Stub.h>
|
#include <LibIPC/Stub.h>
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
@ -18,6 +20,19 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalS
|
||||||
, m_local_endpoint_magic(local_endpoint_magic)
|
, m_local_endpoint_magic(local_endpoint_magic)
|
||||||
{
|
{
|
||||||
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
|
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)
|
ErrorOr<void> ConnectionBase::post_message(Message const& message)
|
||||||
|
|
|
@ -7,16 +7,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/ByteBuffer.h>
|
#include <AK/Forward.h>
|
||||||
#include <AK/Queue.h>
|
#include <AK/Queue.h>
|
||||||
#include <AK/Try.h>
|
#include <LibCore/EventReceiver.h>
|
||||||
#include <LibCore/Event.h>
|
|
||||||
#include <LibCore/EventLoop.h>
|
|
||||||
#include <LibCore/Socket.h>
|
|
||||||
#include <LibCore/Timer.h>
|
|
||||||
#include <LibIPC/File.h>
|
#include <LibIPC/File.h>
|
||||||
#include <LibIPC/Forward.h>
|
#include <LibIPC/Forward.h>
|
||||||
#include <LibIPC/Message.h>
|
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
|
|
||||||
|
@ -24,9 +19,9 @@ class ConnectionBase : public Core::EventReceiver {
|
||||||
C_OBJECT_ABSTRACT(ConnectionBase);
|
C_OBJECT_ABSTRACT(ConnectionBase);
|
||||||
|
|
||||||
public:
|
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&);
|
ErrorOr<void> post_message(Message const&);
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
@ -70,12 +65,6 @@ public:
|
||||||
Connection(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalSocket> socket)
|
Connection(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalSocket> socket)
|
||||||
: ConnectionBase(local_stub, move(socket), LocalEndpoint::static_magic())
|
: 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>
|
template<typename MessageType>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <LibCore/DateTime.h>
|
#include <LibCore/DateTime.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
|
#include <LibCore/Timer.h>
|
||||||
#include <LibGfx/ImageFormats/PNGWriter.h>
|
#include <LibGfx/ImageFormats/PNGWriter.h>
|
||||||
#include <LibWeb/Infra/Strings.h>
|
#include <LibWeb/Infra/Strings.h>
|
||||||
#include <LibWebView/ViewImplementation.h>
|
#include <LibWebView/ViewImplementation.h>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibCore/EventLoop.h>
|
||||||
#include <WebWorker/ConnectionFromClient.h>
|
#include <WebWorker/ConnectionFromClient.h>
|
||||||
#include <WebWorker/DedicatedWorkerHost.h>
|
#include <WebWorker/DedicatedWorkerHost.h>
|
||||||
#include <WebWorker/PageHost.h>
|
#include <WebWorker/PageHost.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue