Move cookie load/save callbacks to CefCookieAccessFilter (see issue #2622).

This change allows the NetworkService to handle cookie load/save in cases where
cookies will not be filtered (CefResourceRequestHandler::GetCookieAccessFilter
returns null) and the request will be handled by the default network loader.
This represents a minor performance improvement by reducing the volume of cross-
process messaging in the default (no filtering or custom handing) case. Cookie
load/save still needs to be routed through the browser process if a filter is
returned, or if a CefResourceHandler is used for the request.

To test: Test expectations are unchanged.
This commit is contained in:
Marshall Greenblatt
2019-04-26 13:02:47 -04:00
parent edd9efd1b3
commit 2ace33f8b7
16 changed files with 750 additions and 337 deletions

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=c3f205b1da3b2dc0651ca836dee242588068ceff$
// $hash=217e200e9197054500554d62765c3c145bebfea7$
//
#include "libcef_dll/ctocpp/resource_request_handler_ctocpp.h"
@@ -18,12 +18,42 @@
#include "libcef_dll/cpptoc/request_callback_cpptoc.h"
#include "libcef_dll/cpptoc/request_cpptoc.h"
#include "libcef_dll/cpptoc/response_cpptoc.h"
#include "libcef_dll/ctocpp/cookie_access_filter_ctocpp.h"
#include "libcef_dll/ctocpp/resource_handler_ctocpp.h"
#include "libcef_dll/ctocpp/response_filter_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
CefRefPtr<CefCookieAccessFilter>
CefResourceRequestHandlerCToCpp::GetCookieAccessFilter(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request) {
shutdown_checker::AssertNotShutdown();
cef_resource_request_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_cookie_access_filter))
return NULL;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: request; type: refptr_diff
DCHECK(request.get());
if (!request.get())
return NULL;
// Unverified params: browser, frame
// Execute
cef_cookie_access_filter_t* _retval = _struct->get_cookie_access_filter(
_struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
CefRequestCppToC::Wrap(request));
// Return type: refptr_same
return CefCookieAccessFilterCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefResourceRequestHandler::ReturnValue
CefResourceRequestHandlerCToCpp::OnBeforeResourceLoad(
@@ -252,70 +282,6 @@ void CefResourceRequestHandlerCToCpp::OnProtocolExecution(
allow_os_execution = allow_os_executionInt ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefResourceRequestHandlerCToCpp::CanSendCookie(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
const CefCookie& cookie) {
shutdown_checker::AssertNotShutdown();
cef_resource_request_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, can_send_cookie))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: request; type: refptr_diff
DCHECK(request.get());
if (!request.get())
return false;
// Unverified params: browser, frame
// Execute
int _retval = _struct->can_send_cookie(
_struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
CefRequestCppToC::Wrap(request), &cookie);
// Return type: bool
return _retval ? true : false;
}
NO_SANITIZE("cfi-icall")
bool CefResourceRequestHandlerCToCpp::CanSaveCookie(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefRefPtr<CefRequest> request,
CefRefPtr<CefResponse> response,
const CefCookie& cookie) {
shutdown_checker::AssertNotShutdown();
cef_resource_request_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, can_save_cookie))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: request; type: refptr_diff
DCHECK(request.get());
if (!request.get())
return false;
// Verify param: response; type: refptr_diff
DCHECK(response.get());
if (!response.get())
return false;
// Unverified params: browser, frame
// Execute
int _retval = _struct->can_save_cookie(
_struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
CefRequestCppToC::Wrap(request), CefResponseCppToC::Wrap(response),
&cookie);
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefResourceRequestHandlerCToCpp::CefResourceRequestHandlerCToCpp() {}