Rakina Zata Amni | 07b0ce5d | 2023-06-01 05:15:15 | [diff] [blame] | 1 | # What is content/browser/renderer_host? |
| 2 | |
| 3 | This directory contains code that can be loosely categorized as "handling the |
| 4 | renderer," covering a wide range of topics (navigation, compositing, input, |
| 5 | etc). Many of the classes represent a browser-side version of a renderer |
| 6 | concept (e.g., RenderFrameHostImpl is the browser-side equivalent of |
| 7 | RenderFrameImpl). Refer to the class-level comments on how each class relates |
| 8 | to or interacts with the renderer. |
| 9 | |
| 10 | Note that many of the key classes here are defined in `content/public` and |
| 11 | exposed to `//content` embedders, with implementations living in |
| 12 | `content/browser/renderer_host`. |
| 13 | |
| 14 | ## Rough Categories |
| 15 | |
| 16 | A non-exhaustive list of rough categories and descriptions for the code within |
| 17 | `renderer_host` is below. When adding something that falls into the |
| 18 | miscellaneous category, consider if it belongs in a separate directory, either |
| 19 | under `content/browser/` or under `content/browser/renderer_host`. |
| 20 | |
| 21 | ### Browser-side representation of documents and frame-tree-related renderer-side objects |
| 22 | Allows the browser-side code to represent document and frame-tree related |
| 23 | concepts, and communicate with the renderer-side. |
| 24 | |
| 25 | Some important classes include: |
| 26 | - **FrameTree** and **FrameTreeNode**: Represents the frames in the frame tree |
| 27 | of a page. |
| 28 | - **RenderFrameHost**: Roughly represents a document within a frame, although |
| 29 | it does not (yet) change for every new document. |
| 30 | - **RenderFrameProxyHost**: A placeholder for a frame in other |
| 31 | SiteInstanceGroups and renderer processes. |
| 32 | - **RenderViewHost**: Represents a page within a given SiteInstanceGroup. |
| 33 | - **RenderWidgetHost**: A group of contiguous same-SiteInstanceGroup frames |
| 34 | that can paint or handle input events as a single unit. |
| 35 | |
| 36 | For diagrams and explanations of how those classes fit with each other, see also |
| 37 | [this documentation](https://www.chromium.org/developers/design-documents/oop-iframes/) |
Alex Moshchuk | dd260a2e | 2024-02-08 19:04:25 | [diff] [blame] | 38 | and [docs/frame_trees.md](https://chromium.googlesource.com/chromium/src/+/main/docs/frame_trees.md). |
Rakina Zata Amni | 07b0ce5d | 2023-06-01 05:15:15 | [diff] [blame] | 39 | |
| 40 | ### Connections between browser and renderer/GPU processes, process-related code |
| 41 | Represents child processes (e.g., renderers, GPU, etc) and their connection to |
| 42 | the browser process. |
| 43 | |
| 44 | An important class in this category is **RenderProcessHost**, which represents |
| 45 | the browser side of the browser <-> renderer communication channel. There will |
| 46 | be one RenderProcessHost per renderer process. |
| 47 | |
| 48 | ### Navigation |
| 49 | Navigation handling code, coordinating the browser & renderer from navigation |
| 50 | start to finish. Also keeps track of the session history entries created by the |
| 51 | committed navigations. |
| 52 | |
| 53 | Some important classes include: |
| 54 | - **NavigationRequest**: Represents a navigation attempt, and tracks information |
| 55 | related to it. |
| 56 | - **NavigationController**: Manages the joint session history for a frame tree. |
| 57 | - **NavigationEntry** and **FrameNavigationEntry**: Represents joint session |
| 58 | history items (for pages), made up of a tree of session history items (for |
| 59 | frames). |
| 60 | |
Alex Moshchuk | dd260a2e | 2024-02-08 19:04:25 | [diff] [blame] | 61 | See also [docs/navigation.md](https://chromium.googlesource.com/chromium/src/+/main/docs/navigation.md) |
| 62 | and [docs/session_history.md](https://chromium.googlesource.com/chromium/src/+/main/docs/session_history.md). |
Rakina Zata Amni | 07b0ce5d | 2023-06-01 05:15:15 | [diff] [blame] | 63 | |
| 64 | ### Compositing, input, display |
| 65 | Coordinates handling of input, display, and compositing between the browser, |
| 66 | renderer, and GPU processes. |
| 67 | |
| 68 | Some important classes include: |
| 69 | - **RenderWidgetHostView\***: The browser owned object that mediates the |
| 70 | blink::VisualProperties to be used by an embedded Renderer. |
| 71 | - **DelegatedFrameHost**: Used by RenderWidgetHostView to control which |
| 72 | viz::Surface of an embedded Renderer the GPU process will display |
| 73 | EmbeddedFrameSinkImpl: The browser owned object that mediates between an |
| 74 | embedded Renderer and the GPU process. Allowing for the creation of |
| 75 | Renderer-GPU Mojo connections. |
| 76 | - **viz::HostFrameSinkManager**: The browser owned object, accessed via |
| 77 | GetHostFrameSinkManager, that controls the Browser-GPU Mojo connection. Used to |
| 78 | establish future connections for Renderers, as well as to control what |
| 79 | viz::Surfaces to display. |
| 80 | |
| 81 | ### Misc features that heavily interact with the renderer |
| 82 | Examples: loading/networking, file/storage, plugins, UI, fonts, media, |
| 83 | accessibility. |
| 84 | |
| 85 | ## Layering restriction with WebContents |
| 86 | Code in this directory can't call up to the WebContents "layer," except through |
| 87 | delegate interfaces (e.g. RenderFrameHostDelegate). This is to separate out |
| 88 | code that deals with the renderer process and code that deals with the tab. |
Alex Moshchuk | dd260a2e | 2024-02-08 19:04:25 | [diff] [blame] | 89 | This is enforced by the [DEPS](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/renderer_host/DEPS). |