Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[content] Make ContentMainParams and MainFunctionParams move-only
This is taking care of a long-standing TODO to move these OnceClosure holders rather than copy them around with their OnceClosure* members. This is a precursor to https://chromium-review.googlesource.com/c/chromium/src/+/3187153/35#message-fcc92e9f85e73f0e5ba6c03610a95cda8736f1f9 which highlighted a problem where some tests see a non-null MainFunctionParams::ui_task but running the closure results in a UAF. Logs show that the test hitting the UAF is not the one setting this field. This CL makes that impossible and fixes the issue in the follow-up CL. This CL is intended to be a logical no-op. This CL touches a lot of files and must happen all at once. The core change is that ContentMainParams and MainFunctionParams's moveable fields (ui_task, created_main_parts_closure, and startup_data) are now held by moveable types rather than raw pointers. This trickles in the following chain: main() (in various *_main.cc) (or SetUp() in !OS_ANDROID browser_test_base.cc) -> ContentMain() -> ContentMainRunnerImpl::Initialize() (forwards arg into MainFunctionParams) -> RunBrowser() -> BrowserMain() -> BrowserMainRunnerImpl::Initialize() -> BrowserMainLoop (stores MainFunctionParams) -> BrowserMainLoop::Init -> ContentBrowserClient::CreateBrowserMainParts() -> (Embedder)ContentBrowserClient::CreateBrowserMainParts() -> (Embedder)BrowserMainParts(Platform) -> (Embedder)BrowserMainParts -> RunOtherNamedProcessTypeMain() -> (Embedder)ContentMainDelegate::RunProcess() (or) -> FooMain() (kMainFunctions) (or) -> RunZygote() (creates its own MainFunctionParams) -> (Embedder)ContentMainDelegate::RunProcess() (on OS_ANDROID, browser_test_base.cc calls directly into ContentMainDelegate::RunProcess()) Few of these needed the params after passing them down so a move-only model was simple to adapt (even if invasive). The few exceptions like BrowserMainRunnerImpl::Initialize consuming |created_main_parts_closure| are better off in the new model (where they take the OnceClosure before passing down the params) because that prevents others down the chain from having access to a OnceClosure they shouldn't invoke anyways. Noteworthy: - ContentMainDelegate::RunProcess(): Returned an exit_code >= 0 to indicate the embedder elected to handle the run request given these params. With move-only semantics it is necessary to return the params back when the embedder declines handling this run request. An absl::variant return value is used to satisfy this requirement. - content/public/test/test_launcher.h : GetContentMainParams(): Becomes CopyContentMainParams() and only exposes a copy of copyable params. Uses new ContentMainParams::ShallowCopyForTesting() which verifies that moveable fields are still null by that time as should be the case in the order browser tests are initialized. - MainFunctionParams::command_line being const& violated the style-guide rule to "avoid defining functions that require a const reference parameter to outlive the call". This also prevented moving. The type was hence switched to a const CommandLine*. - BUILD.gn changes for nacl_helper_win_64 which requires static linking of its minimal //content deps (was previously missing a dep but was getting away with it because MainFunctionParams was .h only; required now with .cc). This was already done for static_switches and this CL adds static_main_function_params, reusing a similar static_features target that already existed but was no longer required in /c/nacl/broker, cleaning that up by replacing rather than copying that target's definition in this CL. - ContentMainParams::minimal_browser_mode was weirdly passed as a parameter to ContentMainRunner::Run(bool start_minimal_browser) but that method also has access to the ContentMainParams originally passed via ContentMainRunner::Init(). Passing the param again from Run() would be a use-after-move in content_main.cc, instead content_main_runner_impl.cc was updated to use the param it already has in store. Bug: 1175074 Change-Id: I3af90505525e426383c59107a3903d645d455682 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3244976 Commit-Queue: Gabriel Charette <gab@chromium.org> Auto-Submit: Gabriel Charette <gab@chromium.org> Reviewed-by: Alexander Timin <altimin@chromium.org> Reviewed-by: Brad Nelson <bradnelson@chromium.org> Reviewed-by: Scott Violet <sky@chromium.org> Reviewed-by: Clark DuVall <cduvall@chromium.org> Owners-Override: Alexander Timin <altimin@chromium.org> Cr-Commit-Position: refs/heads/main@{#940478}
- Loading branch information
Gabriel Charette
authored and
Chromium LUCI CQ
committed
Nov 10, 2021
1 parent
05f4160
commit fbeeb1c
Showing
137 changed files
with
612 additions
and
550 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.