Skip to content

Commit 8830313

Browse files
magomezpgorszkowski-igalia
authored andcommitted
[Responsiveness] Add API to manually check WebProcess responsiveness
1 parent 3050220 commit 8830313

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5645,3 +5645,24 @@ webkit_web_view_get_default_content_security_policy(WebKitWebView* webView)
56455645

56465646
return webView->priv->defaultContentSecurityPolicy.data();
56475647
}
5648+
5649+
void webkit_web_view_is_web_process_responsive_async(WebKitWebView *webView, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
5650+
{
5651+
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
5652+
5653+
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
5654+
getPage(webView).isWebProcessResponsive([task = WTFMove(task)] (bool isWebProcessResponsive) {
5655+
if (g_task_return_error_if_cancelled(task.get()))
5656+
return;
5657+
5658+
g_task_return_boolean(task.get(), isWebProcessResponsive);
5659+
});
5660+
}
5661+
5662+
gboolean webkit_web_view_is_web_process_responsive_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
5663+
{
5664+
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
5665+
g_return_val_if_fail(g_task_is_valid(result, webView), false);
5666+
5667+
return g_task_propagate_boolean(G_TASK(result), error);
5668+
}

Source/WebKit/UIProcess/API/glib/WebKitWebView.h.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,17 @@ webkit_web_view_get_default_content_security_policy (WebKitWebView
10471047
*/
10481048
#endif
10491049

1050+
WEBKIT_API void
1051+
webkit_web_view_is_web_process_responsive_async (WebKitWebView *web_view,
1052+
GCancellable *cancellable,
1053+
GAsyncReadyCallback callback,
1054+
gpointer user_data);
1055+
1056+
WEBKIT_API gboolean
1057+
webkit_web_view_is_web_process_responsive_finish (WebKitWebView *web_view,
1058+
GAsyncResult *result,
1059+
GError **error);
1060+
10501061
G_END_DECLS
10511062

10521063
#endif

Source/WebKit/UIProcess/WebPageProxy.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9636,6 +9636,21 @@ void WebPageProxy::didChangeProcessIsResponsive()
96369636
internals().pageLoadState.didChangeProcessIsResponsive();
96379637
}
96389638

9639+
void WebPageProxy::isWebProcessResponsive(CompletionHandler<void (bool)>&& callback)
9640+
{
9641+
if (m_isClosed) {
9642+
if (callback) {
9643+
RunLoop::main().dispatch([callback = WTFMove(callback)]() mutable {
9644+
bool isWebProcessResponsive = true;
9645+
callback(isWebProcessResponsive);
9646+
});
9647+
}
9648+
return;
9649+
}
9650+
9651+
process().isResponsive(WTFMove(callback));
9652+
}
9653+
96399654
String WebPageProxy::currentURL() const
96409655
{
96419656
String url = internals().pageLoadState.activeURL();

Source/WebKit/UIProcess/WebPageProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,6 +1492,7 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>, publ
14921492
void dispatchProcessDidTerminate(ProcessTerminationReason);
14931493
void willChangeProcessIsResponsive();
14941494
void didChangeProcessIsResponsive();
1495+
void isWebProcessResponsive(CompletionHandler<void (bool isWebProcessResponsive)>&& callback);
14951496

14961497
#if PLATFORM(IOS_FAMILY)
14971498
void processWillBecomeSuspended();

0 commit comments

Comments
 (0)