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}
The Service Manager is no longer used in upstream Chromium or any
upstream embedders other than Cast Shell. This moves ownership of the
browser-process Service Manager instance into //chromecast/browser.
Subsequent changes will also move the implementation into //chromecast
and eliminate other Service Manager public APIs from the rest of the
tree.
Bug: 977637
Change-Id: I9d6351dad1d0ce47f8fcf2594f674ac1b1541e31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545764
Reviewed-by: Sean Topping <seantopping@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#830321}
This introduces a new MojoDedicatedThread feature to Content which, when
enabled, changes Mojo to use a dedicated background thread for receiving
incoming IPCs rather than using Content's IO thread.
The feature is disabled by default.
Bug: 1082761
Change-Id: Ia68f288309a316be14b5254e9c4f006b6f8c74cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2202143
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#768903}
This ensures the Service Manager is always initialized by
ContentMainRunnerImpl early in process startup, rather than potentially
deferring until BrowserMainLoop runs. The main motivation here is to
have only one place in browser code where the Service Manager is
initialized.
This also begins peeling away at some of the unnecessary dependencies on
ServiceManagerConnection and ServiceManagerContext, since both are slated
for deletion.
Finally, this adds a public content::GetSystemConnector API to
content/public/browser as a drop-in replacement for
ServiceManagerConnection::GetForProcess()->GetConnector(). Moving
forward, this is the API that new browser code should use when
connecting to services. The API is available very early in browser
startup, even before BrowserMainLoop is instantiated.
Bug: 904240, 968147
Change-Id: I933dc8a4bf268cec92eaa4cbdc452c1fc2a08898
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1650155
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: Olga Sharonova <olka@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668977}
Currently the globally accessible PowerMonitor is created and owned by
BrowserMainLoop which is not created/run in reduced. In order to allow
PowerMonitor to be used in reduced mode, it is created in
ContentMainRunner and passed to BrowserMainLoop once full browser
starts.
Bug: 968247
Change-Id: If307dcbfb7f8ff0c7d34c2f4740f4a19ec77bf20
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1635861
Reviewed-by: Xi Han <hanxi@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664566}
This relands commit f481306ad9. The CL
got reverted because BrowserMainLoopTest.CreateThreadsInSingleProcess
is falling on Windows. In this CL, we remove the call of
BrowserMainLoop#InitilaizeMojo() which isn't necessary for the test.
Beside, also re-enable two tests which were disabled when the reverting
CL landed:
* RenderThreadImplBrowserTest.NonResourceDispatchIPCTasksDontGoThroughScheduler
The original cl description is:
This CL instantiates the ServiceManagerContext before creating
the BrowserMainRunner. It splits the startup path into two,
with/without starting the full browser. The changes are implemented
behind a flag "allow-start-service-manager-only".
Bug: 846846,902311
Change-Id: I6e3f6518e414e1298e57b55bd188879461d8f342
Reviewed-on: https://chromium-review.googlesource.com/c/1327413
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611340}
This reverts commit f481306ad9 and
disables following tests on Windows:
* RenderThreadImplBrowserTest.NonResourceDispatchIPCTasksDontGoThroughScheduler
* UserScriptListenerTest.NavigationWaitsForContentScriptsToLoad
Reason for revert: Causes BrowserMainLoopTest, CreateThreadsInSingleProcess to fail every time content_unittests is run, if DCHECKs are enabled.
Original change's description:
> Reland "Start ServiceManger before creating BrowserMainLoop."
>
> This relands commit aa60c21940. The original CL
> (https://crrev.com/c/1113802) got reverted becuase FeatureList and field
> trials are not setup properly in early startup in Android WebView, but
> ServiceMangerContext has checked features. See crbug.com/899376. The fix is
> in a separate CL: https://crrev.com/c/1305876. Another related precursor CL
> is: https://crrev.com/c/1308096.
>
> This CL is an exact copy of the original CL.
>
> The original cl description is:
> This CL instantiates the ServiceManagerContext before creating
> the BrowserMainRunner. It splits the startup path into two,
> with/without starting the full browser. The changes are implemented
> behind a flag "allow-start-service-manager-only".
>
> Bug: 846846,729596
> TBR: jam@chromium.org
> Change-Id: I5214af850d4ef256c9d223db059ed009a42de714
> Reviewed-on: https://chromium-review.googlesource.com/c/1305822
> Commit-Queue: Xi Han <hanxi@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#604969}
TBR=gab@chromium.org,jam@chromium.org,hanxi@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: 846846, 729596, 902311
Change-Id: I8b46711602a240023f4a03a69aa70f66d4eee726
Reviewed-on: https://chromium-review.googlesource.com/c/1322343
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606004}
This relands commit aa60c21940. The original CL
(https://crrev.com/c/1113802) got reverted becuase FeatureList and field
trials are not setup properly in early startup in Android WebView, but
ServiceMangerContext has checked features. See crbug.com/899376. The fix is
in a separate CL: https://crrev.com/c/1305876. Another related precursor CL
is: https://crrev.com/c/1308096.
This CL is an exact copy of the original CL.
The original cl description is:
This CL instantiates the ServiceManagerContext before creating
the BrowserMainRunner. It splits the startup path into two,
with/without starting the full browser. The changes are implemented
behind a flag "allow-start-service-manager-only".
Bug: 846846,729596
TBR: jam@chromium.org
Change-Id: I5214af850d4ef256c9d223db059ed009a42de714
Reviewed-on: https://chromium-review.googlesource.com/c/1305822
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604969}
This reverts commit aa60c21940.
Reason for revert: it breaks network_service_webview_instrumentation_test_apk on Mojo Android Build:
https://bugs.chromium.org/p/chromium/issues/detail?id=899376
Bug:899376
Original change's description:
> Start ServiceManger before creating BrowserMainLoop.
>
> This CL instantiates the ServiceManagerContext before creating
> the BrowserMainRunner. It splits the startup path into two,
> with/without starting the full browser. The changes are implemented
> behind a flag "allow-start-service-manager-only".
>
> Bug: 846846,729596
> Change-Id: I3584db0d89a10e59d6041e0f4412aaffdc840568
> Reviewed-on: https://chromium-review.googlesource.com/c/1113802
> Commit-Queue: Xi Han <hanxi@chromium.org>
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Reviewed-by: Gabriel Charette <gab@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#603092}
TBR=gab@chromium.org,jam@chromium.org,hanxi@chromium.org
Change-Id: I866cc2148d529d0d7a02d0ac75b2817d1695a8c9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 846846, 729596
Reviewed-on: https://chromium-review.googlesource.com/c/1303042
Reviewed-by: Xi Han <hanxi@chromium.org>
Commit-Queue: Xi Han <hanxi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603194}
This CL instantiates the ServiceManagerContext before creating
the BrowserMainRunner. It splits the startup path into two,
with/without starting the full browser. The changes are implemented
behind a flag "allow-start-service-manager-only".
Bug: 846846,729596
Change-Id: I3584db0d89a10e59d6041e0f4412aaffdc840568
Reviewed-on: https://chromium-review.googlesource.com/c/1113802
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603092}
Introduce StartupData in /content/public/browser, and
StartupDataImpl in /content/browser.
This is a precursor CL for: https://crrev.com/c/1108178. In the
follow up CL, StartupData* will be plumbed via
MainFunctionParams to create the browser main loop.
Bug: 846846, 853308
Change-Id: Ic192cfa696439996dec07435f1980d78282f15db
Reviewed-on: https://chromium-review.googlesource.com/1117471
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573943}