Skip to content

Commit

Permalink
Convert legacy IPC messages to Mojo (fixes issue #3123)
Browse files Browse the repository at this point in the history
This change introduces a few minor CEF API behavior changes:

- A CefProcessMessage object cannot be reused after being passed to
  SendProcessMessage.
- The |extra_info| argument to CefRenderProcessHandler::OnBrowserCreated may
  now be NULL.

Where appropriate, we now utilize the default UTF string encoding format and
shared memory to reduce copies and conversions for the cross-process
transfer of arbitrary-length strings. For example, CefFrame::GetSource/GetText
now involves zero UTF conversions and zero copies in the browser process for
the CefString delivered to CefStringVisitor::Visit().
  • Loading branch information
magreenblatt committed May 19, 2021
1 parent 4f0b7b4 commit ebee847
Show file tree
Hide file tree
Showing 82 changed files with 1,614 additions and 2,385 deletions.
29 changes: 9 additions & 20 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,17 @@ static_library("libcef_static") {
"libcef/browser/browser_context.h",
"libcef/browser/browser_context_keyed_service_factories.cc",
"libcef/browser/browser_context_keyed_service_factories.h",
"libcef/browser/browser_frame.cc",
"libcef/browser/browser_frame.h",
"libcef/browser/browser_host_base.cc",
"libcef/browser/browser_host_base.h",
"libcef/browser/browser_host_create.cc",
"libcef/browser/browser_info.cc",
"libcef/browser/browser_info.h",
"libcef/browser/browser_info_manager.cc",
"libcef/browser/browser_info_manager.h",
"libcef/browser/browser_message_filter.cc",
"libcef/browser/browser_message_filter.h",
"libcef/browser/browser_manager.cc",
"libcef/browser/browser_manager.h",
"libcef/browser/browser_message_loop.cc",
"libcef/browser/browser_message_loop.h",
"libcef/browser/browser_platform_delegate.cc",
Expand Down Expand Up @@ -560,8 +562,6 @@ static_library("libcef_static") {
"libcef/browser/native/browser_platform_delegate_native.h",
"libcef/browser/native/cursor_util.h",
"libcef/browser/native/cursor_util.cc",
"libcef/browser/navigate_params.cc",
"libcef/browser/navigate_params.h",
"libcef/browser/navigation_entry_impl.cc",
"libcef/browser/navigation_entry_impl.h",
"libcef/browser/net/chrome_scheme_handler.cc",
Expand Down Expand Up @@ -675,10 +675,6 @@ static_library("libcef_static") {
"libcef/common/app_manager.cc",
"libcef/common/app_manager.h",
"libcef/common/base_impl.cc",
"libcef/common/cef_message_generator.cc",
"libcef/common/cef_message_generator.h",
"libcef/common/cef_messages.cc",
"libcef/common/cef_messages.h",
"libcef/common/cef_switches.cc",
"libcef/common/cef_switches.h",
"libcef/common/chrome/chrome_content_client_cef.cc",
Expand Down Expand Up @@ -715,10 +711,6 @@ static_library("libcef_static") {
"libcef/common/net/net_resource_provider.h",
"libcef/common/net/scheme_registration.cc",
"libcef/common/net/scheme_registration.h",
"libcef/common/net/upload_data.cc",
"libcef/common/net/upload_data.h",
"libcef/common/net/upload_element.cc",
"libcef/common/net/upload_element.h",
"libcef/common/net/url_util.cc",
"libcef/common/net/url_util.h",
"libcef/common/net_service/net_service_util.cc",
Expand All @@ -736,14 +728,14 @@ static_library("libcef_static") {
"libcef/common/resource_util.h",
"libcef/common/response_impl.cc",
"libcef/common/response_impl.h",
"libcef/common/response_manager.cc",
"libcef/common/response_manager.h",
"libcef/common/scheme_registrar_impl.cc",
"libcef/common/scheme_registrar_impl.h",
"libcef/common/string_list_impl.cc",
"libcef/common/string_map_impl.cc",
"libcef/common/string_multimap_impl.cc",
"libcef/common/string_types_impl.cc",
"libcef/common/string_util.cc",
"libcef/common/string_util.h",
"libcef/common/task_impl.cc",
"libcef/common/task_runner_impl.cc",
"libcef/common/task_runner_impl.h",
Expand All @@ -769,16 +761,12 @@ static_library("libcef_static") {
"libcef/features/runtime_checks.h",
"libcef/renderer/alloy/alloy_content_renderer_client.cc",
"libcef/renderer/alloy/alloy_content_renderer_client.h",
"libcef/renderer/alloy/alloy_render_frame_observer.cc",
"libcef/renderer/alloy/alloy_render_frame_observer.h",
"libcef/renderer/alloy/alloy_render_thread_observer.cc",
"libcef/renderer/alloy/alloy_render_thread_observer.h",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.cc",
"libcef/renderer/alloy/url_loader_throttle_provider_impl.h",
"libcef/renderer/browser_impl.cc",
"libcef/renderer/browser_impl.h",
"libcef/renderer/browser_manager.cc",
"libcef/renderer/browser_manager.h",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.cc",
"libcef/renderer/chrome/chrome_content_renderer_client_cef.h",
"libcef/renderer/dom_document_impl.cc",
Expand All @@ -797,8 +785,8 @@ static_library("libcef_static") {
"libcef/renderer/render_frame_observer.h",
"libcef/renderer/render_frame_util.cc",
"libcef/renderer/render_frame_util.h",
"libcef/renderer/render_thread_observer.cc",
"libcef/renderer/render_thread_observer.h",
"libcef/renderer/render_manager.cc",
"libcef/renderer/render_manager.h",
"libcef/renderer/render_urlrequest_impl.cc",
"libcef/renderer/render_urlrequest_impl.h",
"libcef/renderer/thread_util.h",
Expand Down Expand Up @@ -834,6 +822,7 @@ static_library("libcef_static") {

deps = [
":cef_make_headers",
"libcef/common/mojom",

":libcef_static_unittested",

Expand Down
12 changes: 7 additions & 5 deletions include/capi/cef_frame_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=bce865a34f45e6dee8f413f0d6bd7f4c37ab55c0$
// $hash=872fd1e811d41f56f03da0da75a8f2e89cad40cd$
//

#ifndef CEF_INCLUDE_CAPI_CEF_FRAME_CAPI_H_
Expand Down Expand Up @@ -242,10 +242,12 @@ typedef struct _cef_frame_t {
struct _cef_urlrequest_client_t* client);

///
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
///
void(CEF_CALLBACK* send_process_message)(
struct _cef_frame_t* self,
Expand Down
4 changes: 2 additions & 2 deletions include/capi/cef_render_process_handler_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
// $hash=41339414bca54054046a8f7fbce402a0e0dd8020$
// $hash=131544be2c5e916381f80854451538ad64a687a2$
//

#ifndef CEF_INCLUDE_CAPI_CEF_RENDER_PROCESS_HANDLER_CAPI_H_
Expand Down Expand Up @@ -73,7 +73,7 @@ typedef struct _cef_render_process_handler_t {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is a read-only value originating from
// destroyed. |extra_info| is an optional read-only value originating from
// cef_browser_host_t::cef_browser_host_create_browser(),
// cef_browser_host_t::cef_browser_host_create_browser_sync(),
// cef_life_span_handler_t::on_before_popup() or
Expand Down
10 changes: 6 additions & 4 deletions include/cef_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,12 @@ class CefFrame : public virtual CefBaseRefCounted {
CefRefPtr<CefURLRequestClient> client) = 0;

///
// Send a message to the specified |target_process|. Message delivery is not
// guaranteed in all cases (for example, if the browser is closing,
// navigating, or if the target process crashes). Send an ACK message back
// from the target process if confirmation is required.
// Send a message to the specified |target_process|. Ownership of the message
// contents will be transferred and the |message| reference will be
// invalidated. Message delivery is not guaranteed in all cases (for example,
// if the browser is closing, navigating, or if the target process crashes).
// Send an ACK message back from the target process if confirmation is
// required.
///
/*--cef()--*/
virtual void SendProcessMessage(CefProcessId target_process,
Expand Down
4 changes: 2 additions & 2 deletions include/cef_render_process_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class CefRenderProcessHandler : public virtual CefBaseRefCounted {
///
// Called after a browser has been created. When browsing cross-origin a new
// browser will be created before the old browser with the same identifier is
// destroyed. |extra_info| is a read-only value originating from
// destroyed. |extra_info| is an optional read-only value originating from
// CefBrowserHost::CreateBrowser(), CefBrowserHost::CreateBrowserSync(),
// CefLifeSpanHandler::OnBeforePopup() or CefBrowserView::CreateBrowserView().
///
/*--cef()--*/
/*--cef(optional_param=extra_info)--*/
virtual void OnBrowserCreated(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDictionaryValue> extra_info) {}

Expand Down
Loading

0 comments on commit ebee847

Please sign in to comment.