mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-08-16 17:00:35 +03: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:
parent
7c607a4749
commit
54f66c574c
Notes:
sideshowbarker
2024-07-16 21:34:08 +09:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/54f66c574c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/284 Reviewed-by: https://github.com/kalenikaliaksandr Reviewed-by: https://github.com/trflynn89
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user