Charlie Reis | 9ce0ed22 | 2024-09-05 22:05:26 | [diff] [blame] | 1 | // Copyright 2024 The Chromium Authors |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CONTENT_BROWSER_PROCESS_REUSE_POLICY_H_ |
| 6 | #define CONTENT_BROWSER_PROCESS_REUSE_POLICY_H_ |
| 7 | |
| 8 | namespace content { |
| 9 | |
| 10 | // The policy to apply when selecting a RenderProcessHost for a SiteInstance. |
| 11 | // If no suitable RenderProcessHost for the SiteInstance exists according to the |
| 12 | // policy, and there are processes with unmatched service workers for the site, |
| 13 | // the newest process with an unmatched service worker is reused. If still no |
| 14 | // RenderProcessHost exists, a new RenderProcessHost will be created unless the |
| 15 | // soft process limit has been reached. When the limit has been reached, an |
| 16 | // existing suitable (e.g., same-site if Site Isolation is enabled) |
| 17 | // RenderProcessHost will be chosen randomly to be reused when possible. |
| 18 | enum class ProcessReusePolicy { |
| 19 | // In this mode, all instances of the site will be hosted in the same |
| 20 | // RenderProcessHost. |
| 21 | PROCESS_PER_SITE, |
| 22 | |
| 23 | // In this mode, the subframe's site will be rendered in a RenderProcessHost |
| 24 | // that is already in use for the site, either for a pending navigation or a |
| 25 | // committed navigation. If multiple such processes exist, ones that have |
| 26 | // foreground frames are given priority, and otherwise one is selected |
| 27 | // randomly. |
| 28 | REUSE_PENDING_OR_COMMITTED_SITE_SUBFRAME, |
| 29 | |
| 30 | // Similar to REUSE_PENDING_OR_COMMITTED_SITE_SUBFRAME, but only applied to |
| 31 | // workers. Reuse decisions may vary from those for |
| 32 | // REUSE_PENDING_OR_COMMITTED_SITE_SUBFRAME. |
| 33 | REUSE_PENDING_OR_COMMITTED_SITE_WORKER, |
| 34 | |
| 35 | // When used, this is similar to REUSE_PENDING_OR_COMMITTED_SITE_SUBFRAME, but |
| 36 | // for main frames, and limiting the number of main frames a RenderProcessHost |
| 37 | // can host to a certain threshold. |
| 38 | REUSE_PENDING_OR_COMMITTED_SITE_WITH_MAIN_FRAME_THRESHOLD, |
| 39 | |
| 40 | // In this mode, SiteInstances don't proactively reuse processes. An |
| 41 | // existing process with an unmatched service worker for the site is reused |
| 42 | // only for navigations, not for service workers. When the process limit has |
| 43 | // been reached, a randomly chosen RenderProcessHost is reused as in the |
| 44 | // other policies. |
| 45 | DEFAULT, |
| 46 | }; |
| 47 | |
| 48 | } // namespace content |
| 49 | |
| 50 | #endif // CONTENT_BROWSER_PROCESS_REUSE_POLICY_H_ |