LibWebView: Remove now-unused ProcessManager HTML generator

This commit is contained in:
Timothy Flynn 2025-03-16 12:43:23 -04:00 committed by Tim Flynn
parent 45d8cd5c9f
commit 942f26a846
Notes: github-actions[bot] 2025-03-19 14:04:15 +00:00
4 changed files with 0 additions and 101 deletions

View file

@ -321,16 +321,6 @@ Optional<Process&> Application::find_process(pid_t pid)
return m_process_manager.find_process(pid);
}
void Application::update_process_statistics()
{
m_process_manager.update_all_process_statistics();
}
String Application::generate_process_statistics_html()
{
return m_process_manager.generate_html();
}
void Application::send_updated_process_statistics_to_view(ViewImplementation& view)
{
m_process_manager.update_all_process_statistics();

View file

@ -56,10 +56,6 @@ public:
#endif
Optional<Process&> find_process(pid_t);
// FIXME: Should we just expose the ProcessManager via a getter?
void update_process_statistics();
String generate_process_statistics_html();
void send_updated_process_statistics_to_view(ViewImplementation&);
ErrorOr<LexicalPath> path_for_downloaded_file(StringView file) const;

View file

@ -6,7 +6,6 @@
#include <AK/JsonArraySerializer.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/NumberFormat.h>
#include <AK/String.h>
#include <LibCore/EventLoop.h>
#include <LibCore/System.h>
@ -121,89 +120,6 @@ void ProcessManager::update_all_process_statistics()
(void)update_process_statistics(m_statistics);
}
String ProcessManager::generate_html()
{
Threading::MutexLocker locker { m_lock };
StringBuilder builder;
builder.append(R"(
<html>
<head>
<title>Task Manager</title>
<style>
@media (prefers-color-scheme: dark) {
tr:nth-child(even) {
background: rgb(57, 57, 57);
}
}
@media (prefers-color-scheme: light) {
tr:nth-child(even) {
background: #f7f7f7;
}
}
html {
color-scheme: light dark;
}
table {
width: 100%;
border-collapse: collapse;
}
th {
text-align: left;
border-bottom: 1px solid #aaa;
}
td, th {
padding: 4px;
border: 1px solid #aaa;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>PID</th>
<th>Memory Usage</th>
<th>CPU %</th>
</tr>
</thead>
<tbody>
)"sv);
m_statistics.for_each_process([&](auto const& process) {
builder.append("<tr>"sv);
builder.append("<td>"sv);
auto& process_handle = this->find_process(process.pid).value();
builder.append(WebView::process_name_from_type(process_handle.type()));
if (process_handle.title().has_value())
builder.appendff(" - {}", escape_html_entities(*process_handle.title()));
builder.append("</td>"sv);
builder.append("<td>"sv);
builder.append(String::number(process.pid));
builder.append("</td>"sv);
builder.append("<td>"sv);
builder.append(human_readable_size(process.memory_usage_bytes));
builder.append("</td>"sv);
builder.append("<td>"sv);
builder.append(MUST(String::formatted("{:.1f}", process.cpu_percent)));
builder.append("</td>"sv);
builder.append("</tr>"sv);
});
builder.append(R"(
</tbody>
</table>
</body>
</html>
)"sv);
return builder.to_string_without_validation();
}
String ProcessManager::serialize_json()
{
Threading::MutexLocker locker { m_lock };

View file

@ -7,8 +7,6 @@
#pragma once
#include <AK/Types.h>
#include <AK/Vector.h>
#include <LibCore/EventReceiver.h>
#include <LibCore/Platform/ProcessStatistics.h>
#include <LibThreading/Mutex.h>
#include <LibWebView/Forward.h>
@ -36,7 +34,6 @@ public:
#endif
void update_all_process_statistics();
String generate_html();
String serialize_json();
Function<void(Process&&)> on_process_exited;