Explorar o código

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

Andreas Kling hai 1 ano
pai
achega
4fe21e6d87

+ 17 - 2
Userland/Libraries/LibIPC/Connection.cpp

@@ -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)

+ 4 - 15
Userland/Libraries/LibIPC/Connection.h

@@ -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>

+ 1 - 0
Userland/Libraries/LibWebView/ViewImplementation.cpp

@@ -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>

+ 1 - 0
Userland/Services/WebWorker/ConnectionFromClient.cpp

@@ -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>