mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Add callbacks for unresponsive render process (fixes #3661)
The client can optionally wait or terminate the render process. Expose process exit codes via OnRenderProcessTerminated and CefGetExitCode (fixes #2126). cefclient: Add a new https://tests/hang page for testing hang behavior. cefclient: Move message and resource handling to a new BaseClientHandler class to support loading of test pages in default Chrome UI windows.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=736aa196beae8c3c35ef330eb78fb0908fccf70b$
|
||||
// $hash=da0fdd0a724301aa3ca12055bce970b9d3d0f708$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/browser_host_ctocpp.h"
|
||||
@@ -1296,6 +1296,24 @@ void CefBrowserHostCToCpp::ExecuteChromeCommand(
|
||||
_struct->execute_chrome_command(_struct, command_id, disposition);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefBrowserHostCToCpp::IsRenderProcessUnresponsive() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_browser_host_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, is_render_process_unresponsive)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->is_render_process_unresponsive(_struct);
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefBrowserHostCToCpp::CefBrowserHostCToCpp() {}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=8b1e4268c2b68437b5022e9baf3f1c56bf036fe7$
|
||||
// $hash=ec03d4b0c8e59ba8f8eb3060e374b4d76e22669b$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||
@@ -139,6 +139,7 @@ class CefBrowserHostCToCpp : public CefCToCppRefCounted<CefBrowserHostCToCpp,
|
||||
bool CanExecuteChromeCommand(int command_id) override;
|
||||
void ExecuteChromeCommand(int command_id,
|
||||
cef_window_open_disposition_t disposition) override;
|
||||
bool IsRenderProcessUnresponsive() override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_BROWSER_HOST_CTOCPP_H_
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=a93a6c9d3656f1c7fd70795abb89d608e996f834$
|
||||
// $hash=19b44051658f9e6419dc37d33ed9a70239b5f857$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "libcef_dll/cpptoc/request_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/x509certificate_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/resource_request_handler_ctocpp.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
@@ -340,10 +341,68 @@ void CefRequestHandlerCToCpp::OnRenderViewReady(CefRefPtr<CefBrowser> browser) {
|
||||
_struct->on_render_view_ready(_struct, CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestHandlerCToCpp::OnRenderProcessUnresponsive(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefUnresponsiveProcessCallback> callback) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_request_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_render_process_unresponsive)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get()) {
|
||||
return false;
|
||||
}
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback.get());
|
||||
if (!callback.get()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->on_render_process_unresponsive(
|
||||
_struct, CefBrowserCppToC::Wrap(browser),
|
||||
CefUnresponsiveProcessCallbackCppToC::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefRequestHandlerCToCpp::OnRenderProcessResponsive(
|
||||
CefRefPtr<CefBrowser> browser) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_request_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_render_process_responsive)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser.get());
|
||||
if (!browser.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->on_render_process_responsive(_struct,
|
||||
CefBrowserCppToC::Wrap(browser));
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefRequestHandlerCToCpp::OnRenderProcessTerminated(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
TerminationStatus status) {
|
||||
TerminationStatus status,
|
||||
int error_code,
|
||||
const CefString& error_string) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_request_handler_t* _struct = GetStruct();
|
||||
@@ -358,10 +417,16 @@ void CefRequestHandlerCToCpp::OnRenderProcessTerminated(
|
||||
if (!browser.get()) {
|
||||
return;
|
||||
}
|
||||
// Verify param: error_string; type: string_byref_const
|
||||
DCHECK(!error_string.empty());
|
||||
if (error_string.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
_struct->on_render_process_terminated(
|
||||
_struct, CefBrowserCppToC::Wrap(browser), status);
|
||||
_struct->on_render_process_terminated(_struct,
|
||||
CefBrowserCppToC::Wrap(browser), status,
|
||||
error_code, error_string.GetStruct());
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
|
@@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=272831fa944a45a447a333f81c9e5501a3a7db64$
|
||||
// $hash=af82af05fec824761f5ff735ff6c9831938deb16$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_HANDLER_CTOCPP_H_
|
||||
@@ -74,8 +74,14 @@ class CefRequestHandlerCToCpp
|
||||
const X509CertificateList& certificates,
|
||||
CefRefPtr<CefSelectClientCertificateCallback> callback) override;
|
||||
void OnRenderViewReady(CefRefPtr<CefBrowser> browser) override;
|
||||
bool OnRenderProcessUnresponsive(
|
||||
CefRefPtr<CefBrowser> browser,
|
||||
CefRefPtr<CefUnresponsiveProcessCallback> callback) override;
|
||||
void OnRenderProcessResponsive(CefRefPtr<CefBrowser> browser) override;
|
||||
void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
|
||||
TerminationStatus status) override;
|
||||
TerminationStatus status,
|
||||
int error_code,
|
||||
const CefString& error_string) override;
|
||||
void OnDocumentAvailableInMainFrame(CefRefPtr<CefBrowser> browser) override;
|
||||
};
|
||||
|
||||
|
74
libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.cc
Normal file
74
libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.cc
Normal file
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=c8f9d6f148a367be5eef1b3512ba023da0f9ac84$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall") void CefUnresponsiveProcessCallbackCToCpp::Wait() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_unresponsive_process_callback_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, wait)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
_struct->wait(_struct);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefUnresponsiveProcessCallbackCToCpp::Terminate() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
cef_unresponsive_process_callback_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, terminate)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
_struct->terminate(_struct);
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefUnresponsiveProcessCallbackCToCpp::CefUnresponsiveProcessCallbackCToCpp() {}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefUnresponsiveProcessCallbackCToCpp::~CefUnresponsiveProcessCallbackCToCpp() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
}
|
||||
|
||||
template <>
|
||||
cef_unresponsive_process_callback_t*
|
||||
CefCToCppRefCounted<CefUnresponsiveProcessCallbackCToCpp,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t>::
|
||||
UnwrapDerived(CefWrapperType type, CefUnresponsiveProcessCallback* c) {
|
||||
DCHECK(false) << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType
|
||||
CefCToCppRefCounted<CefUnresponsiveProcessCallbackCToCpp,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t>::kWrapperType =
|
||||
WT_UNRESPONSIVE_PROCESS_CALLBACK;
|
42
libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h
Normal file
42
libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool. If making changes by
|
||||
// hand only do so within the body of existing method and function
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=4c04a490cc0609560e711890eeb286431675bf54$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_UNRESPONSIVE_PROCESS_CALLBACK_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_UNRESPONSIVE_PROCESS_CALLBACK_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(WRAPPING_CEF_SHARED)
|
||||
#error This file can be included wrapper-side only
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_unresponsive_process_callback_capi.h"
|
||||
#include "include/cef_unresponsive_process_callback.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefUnresponsiveProcessCallbackCToCpp
|
||||
: public CefCToCppRefCounted<CefUnresponsiveProcessCallbackCToCpp,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t> {
|
||||
public:
|
||||
CefUnresponsiveProcessCallbackCToCpp();
|
||||
virtual ~CefUnresponsiveProcessCallbackCToCpp();
|
||||
|
||||
// CefUnresponsiveProcessCallback methods.
|
||||
void Wait() override;
|
||||
void Terminate() override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_UNRESPONSIVE_PROCESS_CALLBACK_CTOCPP_H_
|
Reference in New Issue
Block a user