Fix issues with request callbacks during browser shutdown (see issue #2622).

The behavior has changed as follows with NetworkService enabled:
- All pending and in-progress requests will now be aborted when the CEF context
  or associated browser is destroyed. The OnResourceLoadComplete callback will
  now also be called in this case for in-progress requests that have a handler.
- The CefResourceHandler::Cancel method will now always be called when resource
  handling is complete, irrespective of whether handling completed successfully.
- Request callbacks that arrive after the OnBeforeClose callback for the
  associated browser (which may happen for in-progress requests that are aborted
  on browser destruction) will now always have a non-nullptr CefBrowser
  parameter.
- Allow empty parameters to CefRequest and CefResponse methods where it makes
  sense (e.g. resetting default response state, or clearing a referrer value).
- Fixed a reference loop that was keeping CefResourceHandler objects from being
  destroyed if they were holding a callback reference (from ProcessRequest,
  ReadResponse, etc.) during CEF context or associated browser destruction.
- Fixed an issue where the main frame was not detached on browser destruction
  which could cause a crash due to RFH use-after-free (see issue #2498).

To test: All unit tests pass as expected.
This commit is contained in:
Marshall Greenblatt
2019-05-31 12:50:12 +03:00
parent fd80e5c653
commit fa5268fa2d
21 changed files with 1458 additions and 369 deletions

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=8f57157cf8f05f46b5ae96335584b5e9df02b200$
// $hash=30da50026aa5654b04de874040b194dcc87a7e30$
//
#include "libcef_dll/ctocpp/request_ctocpp.h"
@@ -118,10 +118,7 @@ void CefRequestCToCpp::SetReferrer(const CefString& referrer_url,
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: referrer_url; type: string_byref_const
DCHECK(!referrer_url.empty());
if (referrer_url.empty())
return;
// Unverified params: referrer_url
// Execute
_struct->set_referrer(_struct, referrer_url.GetStruct(), policy);
@@ -274,10 +271,7 @@ void CefRequestCToCpp::SetHeaderByName(const CefString& name,
DCHECK(!name.empty());
if (name.empty())
return;
// Verify param: value; type: string_byref_const
DCHECK(!value.empty());
if (value.empty())
return;
// Unverified params: value
// Execute
_struct->set_header_by_name(_struct, name.GetStruct(), value.GetStruct(),
@@ -369,10 +363,7 @@ void CefRequestCToCpp::SetFirstPartyForCookies(const CefString& url) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: url; type: string_byref_const
DCHECK(!url.empty());
if (url.empty())
return;
// Unverified params: url
// Execute
_struct->set_first_party_for_cookies(_struct, url.GetStruct());

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=781ea7e9b24023e8bdcc80ed93b27eb7ef80aa69$
// $hash=0c197661e7e3e905b90bec127ff7b1ff23240fa2$
//
#include "libcef_dll/ctocpp/response_ctocpp.h"
@@ -118,10 +118,7 @@ void CefResponseCToCpp::SetStatusText(const CefString& statusText) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: statusText; type: string_byref_const
DCHECK(!statusText.empty());
if (statusText.empty())
return;
// Unverified params: statusText
// Execute
_struct->set_status_text(_struct, statusText.GetStruct());
@@ -151,10 +148,7 @@ void CefResponseCToCpp::SetMimeType(const CefString& mimeType) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: mimeType; type: string_byref_const
DCHECK(!mimeType.empty());
if (mimeType.empty())
return;
// Unverified params: mimeType
// Execute
_struct->set_mime_type(_struct, mimeType.GetStruct());
@@ -184,10 +178,7 @@ void CefResponseCToCpp::SetCharset(const CefString& charset) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: charset; type: string_byref_const
DCHECK(!charset.empty());
if (charset.empty())
return;
// Unverified params: charset
// Execute
_struct->set_charset(_struct, charset.GetStruct());
@@ -286,10 +277,7 @@ NO_SANITIZE("cfi-icall") void CefResponseCToCpp::SetURL(const CefString& url) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: url; type: string_byref_const
DCHECK(!url.empty());
if (url.empty())
return;
// Unverified params: url
// Execute
_struct->set_url(_struct, url.GetStruct());