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=c1afe37bef47447905f9dc6b6ba56f550e24021f$
|
||||
// $hash=790f88d9d22bbef9882470f0980f5e7e446d30c5$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/browser_host_cpptoc.h"
|
||||
@ -1506,6 +1506,24 @@ browser_host_execute_chrome_command(struct _cef_browser_host_t* self,
|
||||
disposition);
|
||||
}
|
||||
|
||||
int CEF_CALLBACK
|
||||
browser_host_is_render_process_unresponsive(struct _cef_browser_host_t* self) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute
|
||||
bool _retval = CefBrowserHostCppToC::Get(self)->IsRenderProcessUnresponsive();
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
@ -1588,6 +1606,8 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() {
|
||||
GetStruct()->can_execute_chrome_command =
|
||||
browser_host_can_execute_chrome_command;
|
||||
GetStruct()->execute_chrome_command = browser_host_execute_chrome_command;
|
||||
GetStruct()->is_render_process_unresponsive =
|
||||
browser_host_is_render_process_unresponsive;
|
||||
}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=4a0c9cb5d77d315e067d07ed633b623a8e12a1fc$
|
||||
// $hash=436eb7d254d6edc452b8b529758967d274fa2f85$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
|
||||
@ -21,6 +21,7 @@
|
||||
#include "libcef_dll/ctocpp/request_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/unresponsive_process_callback_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/x509certificate_ctocpp.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
|
||||
@ -345,10 +346,42 @@ request_handler_on_render_view_ready(struct _cef_request_handler_t* self,
|
||||
CefBrowserCToCpp::Wrap(browser));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_handler_on_render_process_terminated(
|
||||
int CEF_CALLBACK request_handler_on_render_process_unresponsive(
|
||||
struct _cef_request_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_termination_status_t status) {
|
||||
struct _cef_unresponsive_process_callback_t* callback) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self) {
|
||||
return 0;
|
||||
}
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser) {
|
||||
return 0;
|
||||
}
|
||||
// Verify param: callback; type: refptr_diff
|
||||
DCHECK(callback);
|
||||
if (!callback) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Execute
|
||||
bool _retval =
|
||||
CefRequestHandlerCppToC::Get(self)->OnRenderProcessUnresponsive(
|
||||
CefBrowserCToCpp::Wrap(browser),
|
||||
CefUnresponsiveProcessCallbackCToCpp::Wrap(callback));
|
||||
|
||||
// Return type: bool
|
||||
return _retval;
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_handler_on_render_process_responsive(
|
||||
struct _cef_request_handler_t* self,
|
||||
cef_browser_t* browser) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
@ -363,9 +396,40 @@ void CEF_CALLBACK request_handler_on_render_process_terminated(
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefRequestHandlerCppToC::Get(self)->OnRenderProcessResponsive(
|
||||
CefBrowserCToCpp::Wrap(browser));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_handler_on_render_process_terminated(
|
||||
struct _cef_request_handler_t* self,
|
||||
cef_browser_t* browser,
|
||||
cef_termination_status_t status,
|
||||
int error_code,
|
||||
const cef_string_t* error_string) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
// Verify param: browser; type: refptr_diff
|
||||
DCHECK(browser);
|
||||
if (!browser) {
|
||||
return;
|
||||
}
|
||||
// Verify param: error_string; type: string_byref_const
|
||||
DCHECK(error_string);
|
||||
if (!error_string) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefRequestHandlerCppToC::Get(self)->OnRenderProcessTerminated(
|
||||
CefBrowserCToCpp::Wrap(browser), status);
|
||||
CefBrowserCToCpp::Wrap(browser), status, error_code,
|
||||
CefString(error_string));
|
||||
}
|
||||
|
||||
void CEF_CALLBACK request_handler_on_document_available_in_main_frame(
|
||||
@ -404,6 +468,10 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC() {
|
||||
GetStruct()->on_select_client_certificate =
|
||||
request_handler_on_select_client_certificate;
|
||||
GetStruct()->on_render_view_ready = request_handler_on_render_view_ready;
|
||||
GetStruct()->on_render_process_unresponsive =
|
||||
request_handler_on_render_process_unresponsive;
|
||||
GetStruct()->on_render_process_responsive =
|
||||
request_handler_on_render_process_responsive;
|
||||
GetStruct()->on_render_process_terminated =
|
||||
request_handler_on_render_process_terminated;
|
||||
GetStruct()->on_document_available_in_main_frame =
|
||||
|
82
libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.cc
Normal file
82
libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.cc
Normal file
@ -0,0 +1,82 @@
|
||||
// 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=d31cea8b172629a308a7d54f8dd6fccff4cc8823$
|
||||
//
|
||||
|
||||
#include "libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h"
|
||||
#include "libcef_dll/shutdown_checker.h"
|
||||
|
||||
namespace {
|
||||
|
||||
// MEMBER FUNCTIONS - Body may be edited by hand.
|
||||
|
||||
void CEF_CALLBACK unresponsive_process_callback_wait(
|
||||
struct _cef_unresponsive_process_callback_t* self) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefUnresponsiveProcessCallbackCppToC::Get(self)->Wait();
|
||||
}
|
||||
|
||||
void CEF_CALLBACK unresponsive_process_callback_terminate(
|
||||
struct _cef_unresponsive_process_callback_t* self) {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
DCHECK(self);
|
||||
if (!self) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute
|
||||
CefUnresponsiveProcessCallbackCppToC::Get(self)->Terminate();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefUnresponsiveProcessCallbackCppToC::CefUnresponsiveProcessCallbackCppToC() {
|
||||
GetStruct()->wait = unresponsive_process_callback_wait;
|
||||
GetStruct()->terminate = unresponsive_process_callback_terminate;
|
||||
}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefUnresponsiveProcessCallbackCppToC::~CefUnresponsiveProcessCallbackCppToC() {
|
||||
shutdown_checker::AssertNotShutdown();
|
||||
}
|
||||
|
||||
template <>
|
||||
CefRefPtr<CefUnresponsiveProcessCallback>
|
||||
CefCppToCRefCounted<CefUnresponsiveProcessCallbackCppToC,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t>::
|
||||
UnwrapDerived(CefWrapperType type, cef_unresponsive_process_callback_t* s) {
|
||||
DCHECK(false) << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType
|
||||
CefCppToCRefCounted<CefUnresponsiveProcessCallbackCppToC,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t>::kWrapperType =
|
||||
WT_UNRESPONSIVE_PROCESS_CALLBACK;
|
38
libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h
Normal file
38
libcef_dll/cpptoc/unresponsive_process_callback_cpptoc.h
Normal file
@ -0,0 +1,38 @@
|
||||
// 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=1816748407afd5599d8582de51b3289d1ea24a33$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CPPTOC_UNRESPONSIVE_PROCESS_CALLBACK_CPPTOC_H_
|
||||
#define CEF_LIBCEF_DLL_CPPTOC_UNRESPONSIVE_PROCESS_CALLBACK_CPPTOC_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(BUILDING_CEF_SHARED)
|
||||
#error This file can be included DLL-side only
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_unresponsive_process_callback_capi.h"
|
||||
#include "include/cef_unresponsive_process_callback.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc_ref_counted.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
// This class may be instantiated and accessed DLL-side only.
|
||||
class CefUnresponsiveProcessCallbackCppToC
|
||||
: public CefCppToCRefCounted<CefUnresponsiveProcessCallbackCppToC,
|
||||
CefUnresponsiveProcessCallback,
|
||||
cef_unresponsive_process_callback_t> {
|
||||
public:
|
||||
CefUnresponsiveProcessCallbackCppToC();
|
||||
virtual ~CefUnresponsiveProcessCallbackCppToC();
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CPPTOC_UNRESPONSIVE_PROCESS_CALLBACK_CPPTOC_H_
|
Reference in New Issue
Block a user