Skip to content

Commit 6171175

Browse files
magomezspenap
authored andcommitted
Add API to manually check WebProcess responsiveness
1 parent 0bac8fe commit 6171175

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

58385838
return webView->priv->defaultContentSecurityPolicy.data();
58395839
}
5840+
5841+
void webkit_web_view_is_web_process_responsive_async(WebKitWebView *webView, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
5842+
{
5843+
g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
5844+
5845+
GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
5846+
getPage(webView).isWebProcessResponsive([task = WTFMove(task)] (bool isWebProcessResponsive) {
5847+
if (g_task_return_error_if_cancelled(task.get()))
5848+
return;
5849+
5850+
g_task_return_boolean(task.get(), isWebProcessResponsive);
5851+
});
5852+
}
5853+
5854+
gboolean webkit_web_view_is_web_process_responsive_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
5855+
{
5856+
g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), false);
5857+
g_return_val_if_fail(g_task_is_valid(result, webView), false);
5858+
5859+
return g_task_propagate_boolean(G_TASK(result), error);
5860+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,17 @@ webkit_web_view_get_theme_color (WebKitWebView
10561056
*/
10571057
#endif
10581058

1059+
WEBKIT_API void
1060+
webkit_web_view_is_web_process_responsive_async (WebKitWebView *web_view,
1061+
GCancellable *cancellable,
1062+
GAsyncReadyCallback callback,
1063+
gpointer user_data);
1064+
1065+
WEBKIT_API gboolean
1066+
webkit_web_view_is_web_process_responsive_finish (WebKitWebView *web_view,
1067+
GAsyncResult *result,
1068+
GError **error);
1069+
10591070
G_END_DECLS
10601071

10611072
#endif

Source/WebKit/UIProcess/WebPageProxy.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11176,6 +11176,21 @@ void WebPageProxy::didChangeProcessIsResponsive()
1117611176
protectedPageLoadState()->didChangeProcessIsResponsive();
1117711177
}
1117811178

11179+
void WebPageProxy::isWebProcessResponsive(CompletionHandler<void (bool)>&& callback)
11180+
{
11181+
if (m_isClosed) {
11182+
if (callback) {
11183+
RunLoop::main().dispatch([callback = WTFMove(callback)]() mutable {
11184+
bool isWebProcessResponsive = true;
11185+
callback(isWebProcessResponsive);
11186+
});
11187+
}
11188+
return;
11189+
}
11190+
11191+
legacyMainFrameProcess().isResponsive(WTFMove(callback));
11192+
}
11193+
1117911194
String WebPageProxy::currentURL() const
1118011195
{
1118111196
String url = protectedPageLoadState()->activeURL();

Source/WebKit/UIProcess/WebPageProxy.h

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

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

0 commit comments

Comments
 (0)