summaryrefslogtreecommitdiff
path: root/Services/ProtocolServer
diff options
context:
space:
mode:
Diffstat (limited to 'Services/ProtocolServer')
-rw-r--r--Services/ProtocolServer/CMakeLists.txt2
-rw-r--r--Services/ProtocolServer/ClientConnection.cpp (renamed from Services/ProtocolServer/PSClientConnection.cpp)28
-rw-r--r--Services/ProtocolServer/ClientConnection.h (renamed from Services/ProtocolServer/PSClientConnection.h)15
-rw-r--r--Services/ProtocolServer/Download.cpp8
-rw-r--r--Services/ProtocolServer/Download.h9
-rw-r--r--Services/ProtocolServer/Forward.h38
-rw-r--r--Services/ProtocolServer/GeminiDownload.cpp10
-rw-r--r--Services/ProtocolServer/GeminiDownload.h10
-rw-r--r--Services/ProtocolServer/GeminiProtocol.cpp8
-rw-r--r--Services/ProtocolServer/GeminiProtocol.h6
-rw-r--r--Services/ProtocolServer/HttpDownload.cpp8
-rw-r--r--Services/ProtocolServer/HttpDownload.h10
-rw-r--r--Services/ProtocolServer/HttpProtocol.cpp6
-rw-r--r--Services/ProtocolServer/HttpProtocol.h6
-rw-r--r--Services/ProtocolServer/HttpsDownload.cpp8
-rw-r--r--Services/ProtocolServer/HttpsDownload.h8
-rw-r--r--Services/ProtocolServer/HttpsProtocol.cpp6
-rw-r--r--Services/ProtocolServer/HttpsProtocol.h6
-rw-r--r--Services/ProtocolServer/Protocol.cpp4
-rw-r--r--Services/ProtocolServer/Protocol.h8
-rw-r--r--Services/ProtocolServer/main.cpp10
21 files changed, 158 insertions, 56 deletions
diff --git a/Services/ProtocolServer/CMakeLists.txt b/Services/ProtocolServer/CMakeLists.txt
index 37230778c7..4fb0757759 100644
--- a/Services/ProtocolServer/CMakeLists.txt
+++ b/Services/ProtocolServer/CMakeLists.txt
@@ -2,6 +2,7 @@ compile_ipc(ProtocolServer.ipc ProtocolServerEndpoint.h)
compile_ipc(ProtocolClient.ipc ProtocolClientEndpoint.h)
set(SOURCES
+ ClientConnection.cpp
Download.cpp
GeminiDownload.cpp
GeminiProtocol.cpp
@@ -11,7 +12,6 @@ set(SOURCES
HttpsProtocol.cpp
main.cpp
Protocol.cpp
- PSClientConnection.cpp
ProtocolServerEndpoint.h
ProtocolClientEndpoint.h
)
diff --git a/Services/ProtocolServer/PSClientConnection.cpp b/Services/ProtocolServer/ClientConnection.cpp
index bb0c5c2940..40387f4208 100644
--- a/Services/ProtocolServer/PSClientConnection.cpp
+++ b/Services/ProtocolServer/ClientConnection.cpp
@@ -27,34 +27,36 @@
#include <AK/Badge.h>
#include <AK/SharedBuffer.h>
#include <ProtocolServer/Download.h>
-#include <ProtocolServer/PSClientConnection.h>
+#include <ProtocolServer/ClientConnection.h>
#include <ProtocolServer/Protocol.h>
#include <ProtocolServer/ProtocolClientEndpoint.h>
-static HashMap<int, RefPtr<PSClientConnection>> s_connections;
+namespace ProtocolServer {
-PSClientConnection::PSClientConnection(Core::LocalSocket& socket, int client_id)
+static HashMap<int, RefPtr<ClientConnection>> s_connections;
+
+ClientConnection::ClientConnection(Core::LocalSocket& socket, int client_id)
: IPC::ClientConnection<ProtocolServerEndpoint>(*this, socket, client_id)
{
s_connections.set(client_id, *this);
}
-PSClientConnection::~PSClientConnection()
+ClientConnection::~ClientConnection()
{
}
-void PSClientConnection::die()
+void ClientConnection::die()
{
s_connections.remove(client_id());
}
-OwnPtr<Messages::ProtocolServer::IsSupportedProtocolResponse> PSClientConnection::handle(const Messages::ProtocolServer::IsSupportedProtocol& message)
+OwnPtr<Messages::ProtocolServer::IsSupportedProtocolResponse> ClientConnection::handle(const Messages::ProtocolServer::IsSupportedProtocol& message)
{
bool supported = Protocol::find_by_name(message.protocol().to_lowercase());
return make<Messages::ProtocolServer::IsSupportedProtocolResponse>(supported);
}
-OwnPtr<Messages::ProtocolServer::StartDownloadResponse> PSClientConnection::handle(const Messages::ProtocolServer::StartDownload& message)
+OwnPtr<Messages::ProtocolServer::StartDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StartDownload& message)
{
URL url(message.url());
if (!url.is_valid())
@@ -70,7 +72,7 @@ OwnPtr<Messages::ProtocolServer::StartDownloadResponse> PSClientConnection::hand
return make<Messages::ProtocolServer::StartDownloadResponse>(id);
}
-OwnPtr<Messages::ProtocolServer::StopDownloadResponse> PSClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)
+OwnPtr<Messages::ProtocolServer::StopDownloadResponse> ClientConnection::handle(const Messages::ProtocolServer::StopDownload& message)
{
auto* download = const_cast<Download*>(m_downloads.get(message.download_id()).value_or(nullptr));
bool success = false;
@@ -81,7 +83,7 @@ OwnPtr<Messages::ProtocolServer::StopDownloadResponse> PSClientConnection::handl
return make<Messages::ProtocolServer::StopDownloadResponse>(success);
}
-void PSClientConnection::did_finish_download(Badge<Download>, Download& download, bool success)
+void ClientConnection::did_finish_download(Badge<Download>, Download& download, bool success)
{
RefPtr<SharedBuffer> buffer;
if (success && download.payload().size() > 0 && !download.payload().is_null()) {
@@ -101,18 +103,20 @@ void PSClientConnection::did_finish_download(Badge<Download>, Download& download
m_downloads.remove(download.id());
}
-void PSClientConnection::did_progress_download(Badge<Download>, Download& download)
+void ClientConnection::did_progress_download(Badge<Download>, Download& download)
{
post_message(Messages::ProtocolClient::DownloadProgress(download.id(), download.total_size(), download.downloaded_size()));
}
-OwnPtr<Messages::ProtocolServer::GreetResponse> PSClientConnection::handle(const Messages::ProtocolServer::Greet&)
+OwnPtr<Messages::ProtocolServer::GreetResponse> ClientConnection::handle(const Messages::ProtocolServer::Greet&)
{
return make<Messages::ProtocolServer::GreetResponse>(client_id());
}
-OwnPtr<Messages::ProtocolServer::DisownSharedBufferResponse> PSClientConnection::handle(const Messages::ProtocolServer::DisownSharedBuffer& message)
+OwnPtr<Messages::ProtocolServer::DisownSharedBufferResponse> ClientConnection::handle(const Messages::ProtocolServer::DisownSharedBuffer& message)
{
m_shared_buffers.remove(message.shbuf_id());
return make<Messages::ProtocolServer::DisownSharedBufferResponse>();
}
+
+}
diff --git a/Services/ProtocolServer/PSClientConnection.h b/Services/ProtocolServer/ClientConnection.h
index 8bb0fd1aa5..cb0ca45b23 100644
--- a/Services/ProtocolServer/PSClientConnection.h
+++ b/Services/ProtocolServer/ClientConnection.h
@@ -29,15 +29,18 @@
#include <AK/HashMap.h>
#include <LibIPC/ClientConnection.h>
#include <ProtocolServer/ProtocolServerEndpoint.h>
+#include <ProtocolServer/Forward.h>
-class Download;
+namespace ProtocolServer {
-class PSClientConnection final : public IPC::ClientConnection<ProtocolServerEndpoint>
+class ClientConnection final
+ : public IPC::ClientConnection<ProtocolServerEndpoint>
, public ProtocolServerEndpoint {
- C_OBJECT(PSClientConnection)
+ C_OBJECT(ClientConnection);
+
public:
- explicit PSClientConnection(Core::LocalSocket&, int client_id);
- ~PSClientConnection() override;
+ explicit ClientConnection(Core::LocalSocket&, int client_id);
+ ~ClientConnection() override;
virtual void die() override;
@@ -54,3 +57,5 @@ private:
HashMap<i32, OwnPtr<Download>> m_downloads;
HashMap<i32, RefPtr<AK::SharedBuffer>> m_shared_buffers;
};
+
+}
diff --git a/Services/ProtocolServer/Download.cpp b/Services/ProtocolServer/Download.cpp
index 6d510374d3..32531894c6 100644
--- a/Services/ProtocolServer/Download.cpp
+++ b/Services/ProtocolServer/Download.cpp
@@ -26,12 +26,14 @@
#include <AK/Badge.h>
#include <ProtocolServer/Download.h>
-#include <ProtocolServer/PSClientConnection.h>
+#include <ProtocolServer/ClientConnection.h>
+
+namespace ProtocolServer {
// FIXME: What about rollover?
static i32 s_next_id = 1;
-Download::Download(PSClientConnection& client)
+Download::Download(ClientConnection& client)
: m_client(client)
, m_id(s_next_id++)
{
@@ -68,3 +70,5 @@ void Download::did_progress(Optional<u32> total_size, u32 downloaded_size)
m_downloaded_size = downloaded_size;
m_client.did_progress_download({}, *this);
}
+
+}
diff --git a/Services/ProtocolServer/Download.h b/Services/ProtocolServer/Download.h
index 08b0605e03..9bc3c7a5f7 100644
--- a/Services/ProtocolServer/Download.h
+++ b/Services/ProtocolServer/Download.h
@@ -31,8 +31,9 @@
#include <AK/Optional.h>
#include <AK/RefCounted.h>
#include <AK/URL.h>
+#include <ProtocolServer/Forward.h>
-class PSClientConnection;
+namespace ProtocolServer {
class Download {
public:
@@ -49,7 +50,7 @@ public:
void stop();
protected:
- explicit Download(PSClientConnection&);
+ explicit Download(ClientConnection&);
void did_finish(bool success);
void did_progress(Optional<u32> total_size, u32 downloaded_size);
@@ -57,7 +58,7 @@ protected:
void set_response_headers(const HashMap<String, String, CaseInsensitiveStringTraits>&);
private:
- PSClientConnection& m_client;
+ ClientConnection& m_client;
i32 m_id { 0 };
URL m_url;
Optional<u32> m_total_size {};
@@ -65,3 +66,5 @@ private:
ByteBuffer m_payload;
HashMap<String, String, CaseInsensitiveStringTraits> m_response_headers;
};
+
+}
diff --git a/Services/ProtocolServer/Forward.h b/Services/ProtocolServer/Forward.h
new file mode 100644
index 0000000000..13dc9f249f
--- /dev/null
+++ b/Services/ProtocolServer/Forward.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace ProtocolServer {
+
+class ClientConnection;
+class Download;
+class GeminiProtocol;
+class HttpProtocol;
+class HttpsProtocol;
+class Protocol;
+
+}
diff --git a/Services/ProtocolServer/GeminiDownload.cpp b/Services/ProtocolServer/GeminiDownload.cpp
index 54114bcd77..7c95d4d23f 100644
--- a/Services/ProtocolServer/GeminiDownload.cpp
+++ b/Services/ProtocolServer/GeminiDownload.cpp
@@ -24,11 +24,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <LibGemini/GeminiResponse.h>
#include <LibGemini/GeminiJob.h>
+#include <LibGemini/GeminiResponse.h>
#include <ProtocolServer/GeminiDownload.h>
-GeminiDownload::GeminiDownload(PSClientConnection& client, NonnullRefPtr<Gemini::GeminiJob> job)
+namespace ProtocolServer {
+
+GeminiDownload::GeminiDownload(ClientConnection& client, NonnullRefPtr<Gemini::GeminiJob> job)
: Download(client)
, m_job(job)
{
@@ -60,7 +62,9 @@ GeminiDownload::~GeminiDownload()
m_job->shutdown();
}
-NonnullOwnPtr<GeminiDownload> GeminiDownload::create_with_job(Badge<GeminiProtocol>, PSClientConnection& client, NonnullRefPtr<Gemini::GeminiJob> job)
+NonnullOwnPtr<GeminiDownload> GeminiDownload::create_with_job(Badge<GeminiProtocol>, ClientConnection& client, NonnullRefPtr<Gemini::GeminiJob> job)
{
return adopt_own(*new GeminiDownload(client, move(job)));
}
+
+}
diff --git a/Services/ProtocolServer/GeminiDownload.h b/Services/ProtocolServer/GeminiDownload.h
index cc7ed4f242..b6e796e952 100644
--- a/Services/ProtocolServer/GeminiDownload.h
+++ b/Services/ProtocolServer/GeminiDownload.h
@@ -28,18 +28,20 @@
#include <AK/Badge.h>
#include <LibCore/Forward.h>
-#include <LibGemini/GeminiJob.h>
+#include <LibGemini/Forward.h>
#include <ProtocolServer/Download.h>
-class GeminiProtocol;
+namespace ProtocolServer {
class GeminiDownload final : public Download {
public:
virtual ~GeminiDownload() override;
- static NonnullOwnPtr<GeminiDownload> create_with_job(Badge<GeminiProtocol>, PSClientConnection&, NonnullRefPtr<Gemini::GeminiJob>);
+ static NonnullOwnPtr<GeminiDownload> create_with_job(Badge<GeminiProtocol>, ClientConnection&, NonnullRefPtr<Gemini::GeminiJob>);
private:
- explicit GeminiDownload(PSClientConnection&, NonnullRefPtr<Gemini::GeminiJob>);
+ explicit GeminiDownload(ClientConnection&, NonnullRefPtr<Gemini::GeminiJob>);
NonnullRefPtr<Gemini::GeminiJob> m_job;
};
+
+}
diff --git a/Services/ProtocolServer/GeminiProtocol.cpp b/Services/ProtocolServer/GeminiProtocol.cpp
index 0bc413a463..956633b177 100644
--- a/Services/ProtocolServer/GeminiProtocol.cpp
+++ b/Services/ProtocolServer/GeminiProtocol.cpp
@@ -24,11 +24,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <LibGemini/GeminiRequest.h>
#include <LibGemini/GeminiJob.h>
+#include <LibGemini/GeminiRequest.h>
#include <ProtocolServer/GeminiDownload.h>
#include <ProtocolServer/GeminiProtocol.h>
+namespace ProtocolServer {
+
GeminiProtocol::GeminiProtocol()
: Protocol("gemini")
{
@@ -38,7 +40,7 @@ GeminiProtocol::~GeminiProtocol()
{
}
-OwnPtr<Download> GeminiProtocol::start_download(PSClientConnection& client, const URL& url)
+OwnPtr<Download> GeminiProtocol::start_download(ClientConnection& client, const URL& url)
{
Gemini::GeminiRequest request;
request.set_url(url);
@@ -47,3 +49,5 @@ OwnPtr<Download> GeminiProtocol::start_download(PSClientConnection& client, cons
job->start();
return download;
}
+
+}
diff --git a/Services/ProtocolServer/GeminiProtocol.h b/Services/ProtocolServer/GeminiProtocol.h
index 9d3066e9b7..e72f4e324f 100644
--- a/Services/ProtocolServer/GeminiProtocol.h
+++ b/Services/ProtocolServer/GeminiProtocol.h
@@ -28,10 +28,14 @@
#include <ProtocolServer/Protocol.h>
+namespace ProtocolServer {
+
class GeminiProtocol final : public Protocol {
public:
GeminiProtocol();
virtual ~GeminiProtocol() override;
- virtual OwnPtr<Download> start_download(PSClientConnection&, const URL&) override;
+ virtual OwnPtr<Download> start_download(ClientConnection&, const URL&) override;
};
+
+}
diff --git a/Services/ProtocolServer/HttpDownload.cpp b/Services/ProtocolServer/HttpDownload.cpp
index 5bfadefb6d..fd0a9862cf 100644
--- a/Services/ProtocolServer/HttpDownload.cpp
+++ b/Services/ProtocolServer/HttpDownload.cpp
@@ -28,7 +28,9 @@
#include <LibHTTP/HttpResponse.h>
#include <ProtocolServer/HttpDownload.h>
-HttpDownload::HttpDownload(PSClientConnection& client, NonnullRefPtr<HTTP::HttpJob> job)
+namespace ProtocolServer {
+
+HttpDownload::HttpDownload(ClientConnection& client, NonnullRefPtr<HTTP::HttpJob> job)
: Download(client)
, m_job(job)
{
@@ -57,7 +59,9 @@ HttpDownload::~HttpDownload()
m_job->shutdown();
}
-NonnullOwnPtr<HttpDownload> HttpDownload::create_with_job(Badge<HttpProtocol>, PSClientConnection& client, NonnullRefPtr<HTTP::HttpJob> job)
+NonnullOwnPtr<HttpDownload> HttpDownload::create_with_job(Badge<HttpProtocol>, ClientConnection& client, NonnullRefPtr<HTTP::HttpJob> job)
{
return adopt_own(*new HttpDownload(client, move(job)));
}
+
+}
diff --git a/Services/ProtocolServer/HttpDownload.h b/Services/ProtocolServer/HttpDownload.h
index 49da391ed9..d0d745ef0c 100644
--- a/Services/ProtocolServer/HttpDownload.h
+++ b/Services/ProtocolServer/HttpDownload.h
@@ -28,18 +28,20 @@
#include <AK/Badge.h>
#include <LibCore/Forward.h>
-#include <LibHTTP/HttpJob.h>
+#include <LibHTTP/Forward.h>
#include <ProtocolServer/Download.h>
-class HttpProtocol;
+namespace ProtocolServer {
class HttpDownload final : public Download {
public:
virtual ~HttpDownload() override;
- static NonnullOwnPtr<HttpDownload> create_with_job(Badge<HttpProtocol>, PSClientConnection&, NonnullRefPtr<HTTP::HttpJob>);
+ static NonnullOwnPtr<HttpDownload> create_with_job(Badge<HttpProtocol>, ClientConnection&, NonnullRefPtr<HTTP::HttpJob>);
private:
- explicit HttpDownload(PSClientConnection&, NonnullRefPtr<HTTP::HttpJob>);
+ explicit HttpDownload(ClientConnection&, NonnullRefPtr<HTTP::HttpJob>);
NonnullRefPtr<HTTP::HttpJob> m_job;
};
+
+}
diff --git a/Services/ProtocolServer/HttpProtocol.cpp b/Services/ProtocolServer/HttpProtocol.cpp
index 5e2f4803a7..ecd03eaa80 100644
--- a/Services/ProtocolServer/HttpProtocol.cpp
+++ b/Services/ProtocolServer/HttpProtocol.cpp
@@ -29,6 +29,8 @@
#include <ProtocolServer/HttpDownload.h>
#include <ProtocolServer/HttpProtocol.h>
+namespace ProtocolServer {
+
HttpProtocol::HttpProtocol()
: Protocol("http")
{
@@ -38,7 +40,7 @@ HttpProtocol::~HttpProtocol()
{
}
-OwnPtr<Download> HttpProtocol::start_download(PSClientConnection& client, const URL& url)
+OwnPtr<Download> HttpProtocol::start_download(ClientConnection& client, const URL& url)
{
HTTP::HttpRequest request;
request.set_method(HTTP::HttpRequest::Method::GET);
@@ -48,3 +50,5 @@ OwnPtr<Download> HttpProtocol::start_download(PSClientConnection& client, const
return nullptr;
return HttpDownload::create_with_job({}, client, (HTTP::HttpJob&)*job);
}
+
+}
diff --git a/Services/ProtocolServer/HttpProtocol.h b/Services/ProtocolServer/HttpProtocol.h
index 0c6c391931..b382a255d4 100644
--- a/Services/ProtocolServer/HttpProtocol.h
+++ b/Services/ProtocolServer/HttpProtocol.h
@@ -28,10 +28,14 @@
#include <ProtocolServer/Protocol.h>
+namespace ProtocolServer {
+
class HttpProtocol final : public Protocol {
public:
HttpProtocol();
virtual ~HttpProtocol() override;
- virtual OwnPtr<Download> start_download(PSClientConnection&, const URL&) override;
+ virtual OwnPtr<Download> start_download(ClientConnection&, const URL&) override;
};
+
+}
diff --git a/Services/ProtocolServer/HttpsDownload.cpp b/Services/ProtocolServer/HttpsDownload.cpp
index 6a629b1bbc..6a578b80ab 100644
--- a/Services/ProtocolServer/HttpsDownload.cpp
+++ b/Services/ProtocolServer/HttpsDownload.cpp
@@ -28,7 +28,9 @@
#include <LibHTTP/HttpsJob.h>
#include <ProtocolServer/HttpsDownload.h>
-HttpsDownload::HttpsDownload(PSClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job)
+namespace ProtocolServer {
+
+HttpsDownload::HttpsDownload(ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job)
: Download(client)
, m_job(job)
{
@@ -57,7 +59,9 @@ HttpsDownload::~HttpsDownload()
m_job->shutdown();
}
-NonnullOwnPtr<HttpsDownload> HttpsDownload::create_with_job(Badge<HttpsProtocol>, PSClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job)
+NonnullOwnPtr<HttpsDownload> HttpsDownload::create_with_job(Badge<HttpsProtocol>, ClientConnection& client, NonnullRefPtr<HTTP::HttpsJob> job)
{
return adopt_own(*new HttpsDownload(client, move(job)));
}
+
+}
diff --git a/Services/ProtocolServer/HttpsDownload.h b/Services/ProtocolServer/HttpsDownload.h
index 8a5b6aceb2..4b0ee573fc 100644
--- a/Services/ProtocolServer/HttpsDownload.h
+++ b/Services/ProtocolServer/HttpsDownload.h
@@ -31,15 +31,17 @@
#include <LibHTTP/HttpsJob.h>
#include <ProtocolServer/Download.h>
-class HttpsProtocol;
+namespace ProtocolServer {
class HttpsDownload final : public Download {
public:
virtual ~HttpsDownload() override;
- static NonnullOwnPtr<HttpsDownload> create_with_job(Badge<HttpsProtocol>, PSClientConnection&, NonnullRefPtr<HTTP::HttpsJob>);
+ static NonnullOwnPtr<HttpsDownload> create_with_job(Badge<HttpsProtocol>, ClientConnection&, NonnullRefPtr<HTTP::HttpsJob>);
private:
- explicit HttpsDownload(PSClientConnection&, NonnullRefPtr<HTTP::HttpsJob>);
+ explicit HttpsDownload(ClientConnection&, NonnullRefPtr<HTTP::HttpsJob>);
NonnullRefPtr<HTTP::HttpsJob> m_job;
};
+
+}
diff --git a/Services/ProtocolServer/HttpsProtocol.cpp b/Services/ProtocolServer/HttpsProtocol.cpp
index 8796741c08..f1e964e78f 100644
--- a/Services/ProtocolServer/HttpsProtocol.cpp
+++ b/Services/ProtocolServer/HttpsProtocol.cpp
@@ -29,6 +29,8 @@
#include <ProtocolServer/HttpsDownload.h>
#include <ProtocolServer/HttpsProtocol.h>
+namespace ProtocolServer {
+
HttpsProtocol::HttpsProtocol()
: Protocol("https")
{
@@ -38,7 +40,7 @@ HttpsProtocol::~HttpsProtocol()
{
}
-OwnPtr<Download> HttpsProtocol::start_download(PSClientConnection& client, const URL& url)
+OwnPtr<Download> HttpsProtocol::start_download(ClientConnection& client, const URL& url)
{
HTTP::HttpRequest request;
request.set_method(HTTP::HttpRequest::Method::GET);
@@ -48,3 +50,5 @@ OwnPtr<Download> HttpsProtocol::start_download(PSClientConnection& client, const
job->start();
return download;
}
+
+}
diff --git a/Services/ProtocolServer/HttpsProtocol.h b/Services/ProtocolServer/HttpsProtocol.h
index ca6f8dafd2..ab6dae90dd 100644
--- a/Services/ProtocolServer/HttpsProtocol.h
+++ b/Services/ProtocolServer/HttpsProtocol.h
@@ -28,10 +28,14 @@
#include <ProtocolServer/Protocol.h>
+namespace ProtocolServer {
+
class HttpsProtocol final : public Protocol {
public:
HttpsProtocol();
virtual ~HttpsProtocol() override;
- virtual OwnPtr<Download> start_download(PSClientConnection&, const URL&) override;
+ virtual OwnPtr<Download> start_download(ClientConnection&, const URL&) override;
};
+
+}
diff --git a/Services/ProtocolServer/Protocol.cpp b/Services/ProtocolServer/Protocol.cpp
index bf53895eaa..de7d74b269 100644
--- a/Services/ProtocolServer/Protocol.cpp
+++ b/Services/ProtocolServer/Protocol.cpp
@@ -27,6 +27,8 @@
#include <AK/HashMap.h>
#include <ProtocolServer/Protocol.h>
+namespace ProtocolServer {
+
static HashMap<String, Protocol*>& all_protocols()
{
static HashMap<String, Protocol*> map;
@@ -47,3 +49,5 @@ Protocol::~Protocol()
{
ASSERT_NOT_REACHED();
}
+
+}
diff --git a/Services/ProtocolServer/Protocol.h b/Services/ProtocolServer/Protocol.h
index bc72751bd5..b50e97195d 100644
--- a/Services/ProtocolServer/Protocol.h
+++ b/Services/ProtocolServer/Protocol.h
@@ -28,16 +28,16 @@
#include <AK/RefPtr.h>
#include <AK/URL.h>
+#include <ProtocolServer/Forward.h>
-class Download;
-class PSClientConnection;
+namespace ProtocolServer {
class Protocol {
public:
virtual ~Protocol();
const String& name() const { return m_name; }
- virtual OwnPtr<Download> start_download(PSClientConnection&, const URL&) = 0;
+ virtual OwnPtr<Download> start_download(ClientConnection&, const URL&) = 0;
static Protocol* find_by_name(const String&);
@@ -47,3 +47,5 @@ protected:
private:
String m_name;
};
+
+}
diff --git a/Services/ProtocolServer/main.cpp b/Services/ProtocolServer/main.cpp
index da307fcefc..37dcb2d80c 100644
--- a/Services/ProtocolServer/main.cpp
+++ b/Services/ProtocolServer/main.cpp
@@ -30,7 +30,7 @@
#include <ProtocolServer/GeminiProtocol.h>
#include <ProtocolServer/HttpProtocol.h>
#include <ProtocolServer/HttpsProtocol.h>
-#include <ProtocolServer/PSClientConnection.h>
+#include <ProtocolServer/ClientConnection.h>
int main(int, char**)
{
@@ -53,9 +53,9 @@ int main(int, char**)
return 1;
}
- (void)*new GeminiProtocol;
- (void)*new HttpProtocol;
- (void)*new HttpsProtocol;
+ (void)*new ProtocolServer::GeminiProtocol;
+ (void)*new ProtocolServer::HttpProtocol;
+ (void)*new ProtocolServer::HttpsProtocol;
auto server = Core::LocalServer::construct();
bool ok = server->take_over_from_system_server();
ASSERT(ok);
@@ -67,7 +67,7 @@ int main(int, char**)
}
static int s_next_client_id = 0;
int client_id = ++s_next_client_id;
- IPC::new_client_connection<PSClientConnection>(*client_socket, client_id);
+ IPC::new_client_connection<ProtocolServer::ClientConnection>(*client_socket, client_id);
};
return event_loop.exec();
}