mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-13 11:16:53 +00:00
LibWebView: Allow querying and iterating all extant WebContentClients
This is mostly useful when some application-level logic needs to iterate over all child processes. A more robust Process abstraction would make this easier.
This commit is contained in:
committed by
Andrew Kaster
parent
7c607a4749
commit
54f66c574c
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace WebView {
|
||||
|
||||
static HashTable<WebContentClient*> s_clients;
|
||||
HashTable<WebContentClient*> WebContentClient::s_clients;
|
||||
|
||||
Optional<ViewImplementation&> WebContentClient::view_for_pid_and_page_id(pid_t pid, u64 page_id)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,11 @@ class WebContentClient final
|
||||
public:
|
||||
static Optional<ViewImplementation&> view_for_pid_and_page_id(pid_t pid, u64 page_id);
|
||||
|
||||
template<CallableAs<IterationDecision, WebContentClient&> Callback>
|
||||
static void for_each_client(Callback callback);
|
||||
|
||||
static size_t client_count() { return s_clients.size(); }
|
||||
|
||||
WebContentClient(NonnullOwnPtr<Core::LocalSocket>, ViewImplementation&);
|
||||
~WebContentClient();
|
||||
|
||||
@@ -121,6 +126,17 @@ private:
|
||||
HashMap<u64, ViewImplementation*> m_views;
|
||||
|
||||
ProcessHandle m_process_handle;
|
||||
|
||||
static HashTable<WebContentClient*> s_clients;
|
||||
};
|
||||
|
||||
template<CallableAs<IterationDecision, WebContentClient&> Callback>
|
||||
void WebContentClient::for_each_client(Callback callback)
|
||||
{
|
||||
for (auto& it : s_clients) {
|
||||
if (callback(*it) == IterationDecision::Break)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user