Skip to content

Commit b5a51fe

Browse files
committed
Add API to manually check WebProcess responsiveness
1 parent 917a120 commit b5a51fe

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
@@ -5844,3 +5844,24 @@ webkit_web_view_get_default_content_security_policy(WebKitWebView* webView)
58445844

58455845
return webView->priv->defaultContentSecurityPolicy.data();
58465846
}
5847+
5848+
void webkit_web_view_is_web_process_responsive_async(WebKitWebView *webView, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
5849+
{
5850+
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
5851+
5852+
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
5853+
getPage(webView).isWebProcessResponsive([task = WTFMove(task)] (bool isWebProcessResponsive) {
5854+
if (g_task_return_error_if_cancelled(task.get()))
5855+
return;
5856+
5857+
g_task_return_boolean(task.get(), isWebProcessResponsive);
5858+
});
5859+
}
5860+
5861+
gboolean webkit_web_view_is_web_process_responsive_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
5862+
{
5863+
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
5864+
g_return_val_if_fail(g_task_is_valid(result, webView), false);
5865+
5866+
return g_task_propagate_boolean(G_TASK(result), error);
5867+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,17 @@ webkit_web_view_get_theme_color (WebKitWebView
10621062
*/
10631063
#endif
10641064

1065+
WEBKIT_API void
1066+
webkit_web_view_is_web_process_responsive_async (WebKitWebView *web_view,
1067+
GCancellable *cancellable,
1068+
GAsyncReadyCallback callback,
1069+
gpointer user_data);
1070+
1071+
WEBKIT_API gboolean
1072+
webkit_web_view_is_web_process_responsive_finish (WebKitWebView *web_view,
1073+
GAsyncResult *result,
1074+
GError **error);
1075+
10651076
G_END_DECLS
10661077

10671078
#endif

Source/WebKit/UIProcess/WebPageProxy.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11206,6 +11206,21 @@ void WebPageProxy::didChangeProcessIsResponsive()
1120611206
protectedPageLoadState()->didChangeProcessIsResponsive();
1120711207
}
1120811208

11209+
void WebPageProxy::isWebProcessResponsive(CompletionHandler<void (bool)>&& callback)
11210+
{
11211+
if (m_isClosed) {
11212+
if (callback) {
11213+
RunLoop::main().dispatch([callback = WTFMove(callback)]() mutable {
11214+
bool isWebProcessResponsive = true;
11215+
callback(isWebProcessResponsive);
11216+
});
11217+
}
11218+
return;
11219+
}
11220+
11221+
legacyMainFrameProcess().isResponsive(WTFMove(callback));
11222+
}
11223+
1120911224
String WebPageProxy::currentURL() const
1121011225
{
1121111226
String url = protectedPageLoadState()->activeURL();

Source/WebKit/UIProcess/WebPageProxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,7 @@ class WebPageProxy final : public API::ObjectImpl<API::Object::Type::Page>, publ
16471647
void dispatchProcessDidTerminate(WebProcessProxy&, ProcessTerminationReason);
16481648
void willChangeProcessIsResponsive();
16491649
void didChangeProcessIsResponsive();
1650+
void isWebProcessResponsive(CompletionHandler<void (bool isWebProcessResponsive)>&& callback);
16501651

16511652
#if PLATFORM(IOS_FAMILY)
16521653
void processWillBecomeSuspended();

0 commit comments

Comments
 (0)