1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:27:35 +00:00

Browser+LibWeb+WebContent: Add action to clear resource cache

This commit is contained in:
Timothy Flynn 2021-03-29 15:31:09 -04:00 committed by Andreas Kling
parent 50a8e0e495
commit 855920fe13
4 changed files with 20 additions and 0 deletions

View file

@ -453,6 +453,13 @@ Tab::Tab(Type type)
m_web_content_view->debug_request("collect-garbage"); m_web_content_view->debug_request("collect-garbage");
} }
})); }));
debug_menu.add_action(GUI::Action::create("Clear cache", { Mod_Ctrl | Mod_Shift, Key_C }, [this](auto&) {
if (m_type == Type::InProcessWebView) {
Web::ResourceLoader::the().clear_cache();
} else {
m_web_content_view->debug_request("clear-cache");
}
}));
auto& help_menu = m_menubar->add_menu("Help"); auto& help_menu = m_menubar->add_menu("Help");
help_menu.add_action(WindowActions::the().about_action()); help_menu.add_action(WindowActions::the().about_action());

View file

@ -236,4 +236,10 @@ bool ResourceLoader::is_port_blocked(int port)
return false; return false;
} }
void ResourceLoader::clear_cache()
{
dbgln("Clearing {} items from ResourceLoader cache", s_resource_cache.size());
s_resource_cache.clear();
}
} }

View file

@ -56,6 +56,8 @@ public:
const String& user_agent() const { return m_user_agent; } const String& user_agent() const { return m_user_agent; }
void clear_cache();
private: private:
ResourceLoader(); ResourceLoader();
static bool is_port_blocked(int port); static bool is_port_blocked(int port);

View file

@ -37,6 +37,7 @@
#include <LibWeb/DOM/Document.h> #include <LibWeb/DOM/Document.h>
#include <LibWeb/Dump.h> #include <LibWeb/Dump.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h> #include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/Page/Frame.h> #include <LibWeb/Page/Frame.h>
#include <WebContent/ClientConnection.h> #include <WebContent/ClientConnection.h>
#include <WebContent/PageHost.h> #include <WebContent/PageHost.h>
@ -210,6 +211,10 @@ void ClientConnection::handle(const Messages::WebContentServer::DebugRequest& me
m_page_host->set_should_show_line_box_borders(state); m_page_host->set_should_show_line_box_borders(state);
page().main_frame().set_needs_display(page().main_frame().viewport_rect()); page().main_frame().set_needs_display(page().main_frame().viewport_rect());
} }
if (message.request() == "clear-cache") {
Web::ResourceLoader::the().clear_cache();
}
} }
void ClientConnection::handle(const Messages::WebContentServer::GetSource&) void ClientConnection::handle(const Messages::WebContentServer::GetSource&)