0
Commit Graph

81 Commits

Author SHA1 Message Date
Kramer Ge
c80f84e4c9 [tracing] Add trace-buffer-handle to child process launch
Add child process launch parameter --trace-buffer-handle to facilitate
writing tracing data before the child process is sandboxed.

This is [1/3] CL of enabling tracing prior to sandboxing.

Bug: 380411640
Change-Id: Ifadc5435c61cb2662ad3ee5b575ff477fccdb788
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6159045
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Reviewed-by: Alexander Timin <altimin@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Commit-Queue: Kramer Ge <fangzhoug@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1410401}
2025-01-23 09:19:53 -08:00
Roger McFarlane
2f246886a7 Improve management of command-line passed shared memory handle.
This CL changes the shared memory handle switch logic to allow the
browser process to retain its handle in order to properly dispose of it
when the child process assumes ownership and/or terminates.

On Windows, in particular, we are seeing evidence that these handles are
being leaked and/or perhaps being inadvertently being mapped twice.

Ownership of the handles is shared between the child process host and
the child process launcher/helper, which operate asynchronously to one
another. As such, the handles are managed as refcounted data.

Note: The handles are not accessed asynchronously. Either the launcher
(via command line) or the host (via IPC) passes the handle to the child,
but their destruction order is non-deterministic.

This is a reland of commit f9fc4f9fc7

It fixes a bug the original CL which prevented the histogram shared
memory from being passed to the browser child process via IPC when
passing it via shared memory is disabled.

Original change's description:

> Change-Id: Ie4d17ad7ce0d29218f926f137dda61d94983d22a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6098050
> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
> Commit-Queue: Roger McFarlane <rogerm@chromium.org>
> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
> Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1408794}

Bug: 351671612, 40109064, 40818143
Change-Id: I638e7b47acd35188782588abf425ed867bb71dc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6187263
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1409683}
2025-01-22 08:12:14 -08:00
Minoru Chikamune
095b122995 Revert "Improve management of command-line passed shared memory handle."
This reverts commit f9fc4f9fc7.

Reason for revert: LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5717672433025024

Sample build with failed test: https://ci.chromium.org/b/8725182265256599073
Affected test(s):
ninja://chrome/test:browser_tests/AdHeuristicTPCDBrowserTestSkipTopLevelTrialGrant.CookieBlocked
ninja://chrome/test:browser_tests/AdHeuristicTPCDBrowserTestSkipTrialGrant.CookieBlocked
ninja://chrome/test:browser_tests/EligibilityServiceBrowserTest.EligibilityChanged_NetworkContextUpdated/All.1
ninja://chrome/test:browser_tests/RequestStorageAccessForWithFirstPartySetsBrowserTest.AllowedByStorageAccessTypeUma_kStorageAccessOnly

Original change's description:
> Improve management of command-line passed shared memory handle.
>
> This CL changes the shared memory handle switch logic to allow the
> browser process to retain its handle in order to properly dispose of it
> when the child process assumes ownership and/or terminates.
>
> On Windows, in particular, we are seeing evidence that these handles are
> being leaked and/or perhaps being inadvertently being mapped twice.
>
> Ownership of the handles is shared between the child process host and
> the child process launcher/helper, which operate asynchronously to one
> another. As such, the handles are managed as refcounted data.
>
> Note: The handles are not accessed asynchronously. Either the launcher
> (via command line) or the host (via IPC) passes the handle to the child,
> but their destruction order is non-deterministic.
>
> Bug: 351671612, 40109064, 40818143
> Change-Id: Ie4d17ad7ce0d29218f926f137dda61d94983d22a
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6098050
> Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
> Commit-Queue: Roger McFarlane <rogerm@chromium.org>
> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
> Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1408794}

Bug: 351671612, 40109064, 40818143
Change-Id: Ifcdf686f4db214d44c35f952e8e481acefc0819f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6174715
Reviewed-by: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Reviewed-by: Keishi Hattori <keishi@chromium.org>
Owners-Override: Minoru Chikamune <chikamune@chromium.org>
Commit-Queue: Minoru Chikamune <chikamune@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1408841}
2025-01-20 19:38:15 -08:00
Roger McFarlane
f9fc4f9fc7 Improve management of command-line passed shared memory handle.
This CL changes the shared memory handle switch logic to allow the
browser process to retain its handle in order to properly dispose of it
when the child process assumes ownership and/or terminates.

On Windows, in particular, we are seeing evidence that these handles are
being leaked and/or perhaps being inadvertently being mapped twice.

Ownership of the handles is shared between the child process host and
the child process launcher/helper, which operate asynchronously to one
another. As such, the handles are managed as refcounted data.

Note: The handles are not accessed asynchronously. Either the launcher
(via command line) or the host (via IPC) passes the handle to the child,
but their destruction order is non-deterministic.

Bug: 351671612, 40109064, 40818143
Change-Id: Ie4d17ad7ce0d29218f926f137dda61d94983d22a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6098050
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1408794}
2025-01-20 14:49:59 -08:00
Mark Rowe
ced178d6b3 Clarify platform-specific code in Mach port rendezvous
Files are moved from //base/mac to //base/apple as they support both Mac and iOS.

Peer process validation will introduce more platform-specific APIs and
behavior into both the server and client. This refactoring makes it
easier to identify which code is platform-specific and which platform it
belongs to without having to search for the nearest `#if`.

The platform-specific subclasses of `MachPortRendezvousServerBase` are
renamed to include the platform. This makes it easier to see which code
in the implementation belongs to each platform, and better reflects the fact they provide different interfaces to callers.

`MachPortRendezvousClient` is split into a platform-independent base
class containing the API and implementation logic that is common to both
platforms. The platform-specific interfaces are exposed as static
methods on each subclass. These will diverge further when peer
validation is introduced.

Change-Id: I5435e91571eba7f751cc1d76262c1cf2fb2066a2
Bug: 362302761
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5905986
Commit-Queue: Mark Rowe <markrowe@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1365816}
2024-10-08 21:16:09 +00:00
Ben Bamesberger
1db126aa65 Reland "Parallel process launching"
This is a reland of 18905f7828

Reland changes: The change was reverted because
ChildProcessLancher::Notify was not called after a policy error,
causing the launch to hang. Now, the FinishStartSandboxedProcess
callback will always run ensuring that Notify will always run, too.
Also, a test was added to show that a failed launch will not hang.

Original change's description:
> Parallel process launching
>
> This change adds support for parallel process launching on Windows.
>
> Background: Processes are launched on a launcher thread, but this thread
> can become bottlenecked if launching multiple processes simultaneously.
> Most of the time spent in the launcher thread is observed to be in the
> CreateProcess call.
>
> This change makes process launching async by moving the target creation
> work to the thread pool. This frees up the launcher thread so it can
> accept tasks more quickly, and multiple target creations can now run in
> parallel.
>
> --enable-features=WinSboxParallelProcessLaunch
>
> Bug: 1499551
> Tests: sbox_integration_tests ParallelLaunchTest.*
> Change-Id: I7add6a6a68d31868a41fb433b223695ff36d8769
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5015584
> Reviewed-by: Will Harris <wfh@chromium.org>
> Commit-Queue: Ben Bamesberger <benb@microsoft.com>
> Reviewed-by: Alex Gough <ajgo@chromium.org>
> Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
> Reviewed-by: Bo Liu <boliu@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1348194}

  content_browsertests
  BrowserChildProcessObserverBrowserTest.LaunchPreSpawnFailed

Bug: 40287847
Change-Id: Ia200ec065a9540f9d4790e2c6e0ae98178fdf747
Tests: sbox_integration_tests ParallelLaunchTest.*,
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5852357
Reviewed-by: Mark Pearson <mpearson@chromium.org>
Reviewed-by: Will Harris <wfh@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1365065}
2024-10-07 18:52:12 +00:00
Will Harris
cb8c3da2d9 Revert "Parallel process launching"
This reverts commit 18905f7828.

Reason for revert: suspected cause of https://issues.chromium.org/362910001

Original change's description:
> Parallel process launching
>
> This change adds support for parallel process launching on Windows.
>
> Background: Processes are launched on a launcher thread, but this thread
> can become bottlenecked if launching multiple processes simultaneously.
> Most of the time spent in the launcher thread is observed to be in the
> CreateProcess call.
>
> This change makes process launching async by moving the target creation
> work to the thread pool. This frees up the launcher thread so it can
> accept tasks more quickly, and multiple target creations can now run in
> parallel.
>
> --enable-features=WinSboxParallelProcessLaunch
>
> Bug: 1499551
> Tests: sbox_integration_tests ParallelLaunchTest.*
> Change-Id: I7add6a6a68d31868a41fb433b223695ff36d8769
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5015584
> Reviewed-by: Will Harris <wfh@chromium.org>
> Commit-Queue: Ben Bamesberger <benb@microsoft.com>
> Reviewed-by: Alex Gough <ajgo@chromium.org>
> Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
> Reviewed-by: Bo Liu <boliu@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1348194}

Bug: 1499551, 362910001
Change-Id: I0f1a61945b48d4877d044a988f35b58a05076ac5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5836201
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
Cr-Commit-Position: refs/heads/main@{#1350864}
2024-09-04 16:43:22 +00:00
Ben Bamesberger
18905f7828 Parallel process launching
This change adds support for parallel process launching on Windows.

Background: Processes are launched on a launcher thread, but this thread
can become bottlenecked if launching multiple processes simultaneously.
Most of the time spent in the launcher thread is observed to be in the
CreateProcess call.

This change makes process launching async by moving the target creation
work to the thread pool. This frees up the launcher thread so it can
accept tasks more quickly, and multiple target creations can now run in
parallel.

--enable-features=WinSboxParallelProcessLaunch

Bug: 1499551
Tests: sbox_integration_tests ParallelLaunchTest.*
Change-Id: I7add6a6a68d31868a41fb433b223695ff36d8769
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5015584
Reviewed-by: Will Harris <wfh@chromium.org>
Commit-Queue: Ben Bamesberger <benb@microsoft.com>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1348194}
2024-08-28 19:21:47 +00:00
Ben Bamesberger
b36e80eb96 Add ChildProcessLauncher timing histograms
This change adds timing histograms to ChildProcessLauncher on Windows.
The first measurement records the total launch time from launch
requested to Notify() on the UI thread. The second measurement records
the time it takes from the launch request to start running on the
launcher thread.

Bug: 40287847
Change-Id: I0c56af891fb45e25ad7611dfe3af2a06aaf816bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5699425
Reviewed-by: Alex Gough <ajgo@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Caitlin Fischer <caitlinfischer@google.com>
Commit-Queue: Ben Bamesberger <benb@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#1334515}
2024-07-29 23:12:25 +00:00
Etienne Pierre-doray
25723fabb2 [tracing] Forward startup tracing config as shmem
Using base::shared_memory::AddToLaunchParameters() to
send config in a shmem at child process creation.

Related changes:
- Some reordering of operations in early startup to ensure dependencies
  are in place.
- TraceStartupConfig holds a perfetto::TraceConfig instead of
  a base::TraceConfig

Change-Id: Ic10f5e7cda39cd953bda5f08b617c4e4568a7773
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5581006
Reviewed-by: Mikhail Khokhlov <khokhlov@google.com>
Reviewed-by: Eric Seckler <eseckler@chromium.org>
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1320942}
2024-06-28 14:05:57 +00:00
Alison Gale
59c007a7ad Migrate TODOs referencing old crbug IDs to the new issue tracker IDs
The canonical bug format is TODO(crbug.com/<id>). TODOs of the
following forms will all be migrated to the new format:

- TODO(crbug.com/<old id>)
- TODO(https://crbug.com/<old id>)
- TODO(crbug/<old id>)
- TODO(crbug/monorail/<old id>)
- TODO(<old id>)
- TODO(issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/<old id>)
- TODO(https://issues.chromium.org/u/1/issues/<old id>)
- TODO(bugs.chromium.org/<old id>)

Bug id mapping is sourced from go/chrome-on-buganizer-prod-issues.
See go/crbug-todo-migration for details.

#crbug-todo-migration

Bug: b/321899722
Change-Id: Ifd155bbeff882ea939f74cf8b8f847f42847940b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5468156
Reviewed-by: Darryl James <dljames@chromium.org>
Owners-Override: Alison Gale <agale@chromium.org>
Commit-Queue: Alison Gale <agale@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1290297}
2024-04-20 03:05:40 +00:00
Shintaro Kawamura
f726c129d0 cros: cache process's priority sent to resourced
DBusSchedqosStateHandler caches the latest process priority in its
internal map because base::Process::GetPriority() is a synchronous API.

To prevent leak of cache, processes need to call
`base::Process::InitializePriority()` and
`base::Process::ForgetPriority()` explicitly. The browser process itself
and processes launched by `content::ChildProcessLauncher` support the
calls.

The examples of processes not launched by
`content::ChildProcessLauncher` are the second zygote process in sandbox
and broker processes launched by
`sandbox::policy::SandboxLinux::StartBrokerProcess()`. But they don't
update their scheduler settings anyway.

Bug: b:306246041
Change-Id: I2afe68fea1cbe981fced9520691a55a49d7e80a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5294979
Reviewed-by: Brian Geffon <bgeffon@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1279444}
2024-03-28 03:40:08 +00:00
Alex Gough
9d2b795f72 Reland "Allow child processes to inherit logging file handle on Windows"
This is a reland of commit b80a478f9f

Previously win_asan failed ContentBrowserTest.RendererCrashCallStack
as the stack was not being sent out on stderr. The Sanitizer
machinery in llvm only allows a single output handle to be provided
and the change caused a file rather than stderr to be used. This
is fixed by adding `--enable-logging=stderr` as an option that
content_shell understands (it does the same thing as chrome, and only
logs to stderr and any internal debuglog). Passing this argument from
the test launcher now allows the test to pass.

Original change's description:
> Allow child processes to inherit logging file handle on Windows
>
> Child processes on Windows cannot always open their log file
> (for instance if they cannot determine the user-data-dir) making
> configuration of logging complicated. Child processes also need
> a sandbox exception to open their log files.
>
> This CL replaces logging related flags to pass a handle to children
> in cases where a file would have been passed, allowing a later CL
> to remove the sandbox rule allowing direct access to the log file.
>
> If the browser is run with `--enable-logging --log-file=file`,
> children will now be run with `--enable-logging=handle --log-file=N`.
> It is not possible to mix stderr logging with file logging (it will
> still work for the browser process), but this already does not work
> in official builds as std handles are not passed into children.
>
> This also allows the CHROME_LOG_FILE to be useful again for renderer
> processes if Chrome is run using:
>
>  $env:CHROME_LOG_FILE="d:\temp\env-log.log"
>  chrome.exe --enable-logging
>
> the browser will inspect the env var and provide a handle to that
> file when starting renderer processes.
>
> Running the browser with --enable-logging=handle directly is not
> supported, these flags should only be provided by the browser when
> starting child processes.
>
> Tests: Manually tested results https://docs.google.com/document/d/1Hq37YReGM91fmcCcqkRbjtjwP62FVH_zpZtfpSPlLeY/edit?usp=sharing
> Bug: 328285906, 40270808
> Change-Id: Id79731b2d35ab3ee58f6c1612990bdec1485da68
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5337202
> Commit-Queue: Alex Gough <ajgo@chromium.org>
> Reviewed-by: Greg Thompson <grt@chromium.org>
> Reviewed-by: Peter Boström <pbos@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1272538}

Bug: 328285906, 40270808
Change-Id: I4a4f994e8afa22da84c81c02e9e786b94eec9aad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5373414
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Bruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1274336}
2024-03-18 18:51:53 +00:00
Alex Gough
09ed865dec Revert "Allow child processes to inherit logging file handle on Windows"
This reverts commit b80a478f9f.

Reason for revert: ContentBrowserTest.RendererCrashCallStack failing
on asan builds.

Original change's description:
> Allow child processes to inherit logging file handle on Windows
>
> Child processes on Windows cannot always open their log file
> (for instance if they cannot determine the user-data-dir) making
> configuration of logging complicated. Child processes also need
> a sandbox exception to open their log files.
>
> This CL replaces logging related flags to pass a handle to children
> in cases where a file would have been passed, allowing a later CL
> to remove the sandbox rule allowing direct access to the log file.
>
> If the browser is run with `--enable-logging --log-file=file`,
> children will now be run with `--enable-logging=handle --log-file=N`.
> It is not possible to mix stderr logging with file logging (it will
> still work for the browser process), but this already does not work
> in official builds as std handles are not passed into children.
>
> This also allows the CHROME_LOG_FILE to be useful again for renderer
> processes if Chrome is run using:
>
>  $env:CHROME_LOG_FILE="d:\temp\env-log.log"
>  chrome.exe --enable-logging
>
> the browser will inspect the env var and provide a handle to that
> file when starting renderer processes.
>
> Running the browser with --enable-logging=handle directly is not
> supported, these flags should only be provided by the browser when
> starting child processes.
>
> Tests: Manually tested results https://docs.google.com/document/d/1Hq37YReGM91fmcCcqkRbjtjwP62FVH_zpZtfpSPlLeY/edit?usp=sharing
> Bug: 328285906, 40270808
> Change-Id: Id79731b2d35ab3ee58f6c1612990bdec1485da68
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5337202
> Commit-Queue: Alex Gough <ajgo@chromium.org>
> Reviewed-by: Greg Thompson <grt@chromium.org>
> Reviewed-by: Peter Boström <pbos@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1272538}

Bug: 328285906, 40270808
Change-Id: Ib1cc6f5438ac4bae5cccfd7b83f9acebdd017594
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5373504
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Alex Gough <ajgo@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1273128}
2024-03-14 23:37:07 +00:00
Alex Gough
b80a478f9f Allow child processes to inherit logging file handle on Windows
Child processes on Windows cannot always open their log file
(for instance if they cannot determine the user-data-dir) making
configuration of logging complicated. Child processes also need
a sandbox exception to open their log files.

This CL replaces logging related flags to pass a handle to children
in cases where a file would have been passed, allowing a later CL
to remove the sandbox rule allowing direct access to the log file.

If the browser is run with `--enable-logging --log-file=file`,
children will now be run with `--enable-logging=handle --log-file=N`.
It is not possible to mix stderr logging with file logging (it will
still work for the browser process), but this already does not work
in official builds as std handles are not passed into children.

This also allows the CHROME_LOG_FILE to be useful again for renderer
processes if Chrome is run using:

 $env:CHROME_LOG_FILE="d:\temp\env-log.log"
 chrome.exe --enable-logging

the browser will inspect the env var and provide a handle to that
file when starting renderer processes.

Running the browser with --enable-logging=handle directly is not
supported, these flags should only be provided by the browser when
starting child processes.

Tests: Manually tested results https://docs.google.com/document/d/1Hq37YReGM91fmcCcqkRbjtjwP62FVH_zpZtfpSPlLeY/edit?usp=sharing
Bug: 328285906, 40270808
Change-Id: Id79731b2d35ab3ee58f6c1612990bdec1485da68
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5337202
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Greg Thompson <grt@chromium.org>
Reviewed-by: Peter Boström <pbos@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1272538}
2024-03-14 02:16:44 +00:00
Alex Gough
959137d239 Centralize handling of logging switches
This CL refactors where logging related command line switches
are propagated to child processes. Rather than being done by
process specific hosts these flags are centralized in the
child process launcher helper. This change may allow logging
from more process types but otherwise should have no functional
changes.

Affected flags:

      --disable-logging
      --enable-logging
      --log-file
      --log-level
      --v
      --vmodule

Bug: 328285906
Change-Id: Ib387839cb3f296b28cdecdc30b30572adf94c268
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5347180
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Alex Gough <ajgo@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1269097}
2024-03-06 18:39:50 +00:00
Dave Tapuska
0fc0919cde [ios] Make basic content shell process render content
Reuse the MachPortRendezvous code for iOS, but each content
process launch will instantiate its own server and there will
only be one set of ports registered for it. This avoids the
bootstrap code that isn't used on iOS and binds the mach send
port to the one passed across the initial XPC connection.

The motivation behind this is that we've been running the
rendezvous code on Mac for some time and we'd ideally like
to have common code passing the initial shared memory and
ports across on MacOS and iOS.

Introduce the handling of command line args and the initial
bootstrap mach send port across the initial XPC connection
with the renderer.

In summary, process launches and content renderers in the simulator.
It is untested on a device since I do not have a setup
that allows that.

Bug: 40254930
Change-Id: I0bdd770f46ec35b63b9b1d2d20afd4e38734f252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5328946
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Ali Juma <ajuma@chromium.org>
Reviewed-by: Mark Rowe <markrowe@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1267128}
2024-02-29 19:09:34 +00:00
Roger McFarlane
c104d940cd Refactor shared memory switch helper functions.
This CL extracts the serialization and deserialization of shared memory regions to/from command-line parameters into a helper module. The common code is sourced from:

  * base/metrics/field_trial.cc
  * base/metrics/histogram_shared_memory.cc

This CL also refactors field_trial.cc and histogram_shared_memory.cc,
and their clients, to use the histogram shared memory switch helper
functions.

Bug: 1028263
Change-Id: Ib044c66f71e66fb8b393a9b5cd3bd17236036521
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5254137
Reviewed-by: Brendon Tiszka <tiszka@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Mark Seaborn <mseaborn@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1261301}
2024-02-15 21:17:47 +00:00
Roger McFarlane
cba0e90d4f Pass the histogram shared memory region on child process launch.
This CL, behind a flag, updates the create/share flow for the histogram shared memory region between the browser process and its child processes. This allows the child processes to immediately allocate metrics from the shared memory region instead of waiting until the first browser/child IPC.

For the renderer, the shared memory region and allocator are created before the child is launched. This was already the case for the other child processes.

In the browser, the child process hosts expose the shared memory region to the ChildProcessLauncher/Helper so that the handle to the shared memory region passed to the child process on launch.

In the child, the metrics service initializes its histogram allocator to use the shared memory, on seeing the --histogram-shared-memory-region parameter.

See:

  * go/improve-chrome-subprocess-metrics

Bug: 1028263, 1290457
Change-Id: I3dc7d59c42b6588dbf8ea31ca05254470d0a8b30
Low-Coverage-Reason: COVERAGE_UNDERREPORTED (crbug.com/1512202)
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4568968
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Camille Lamy <clamy@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mark Seaborn <mseaborn@chromium.org>
Commit-Queue: Roger McFarlane <rogerm@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1251503}
2024-01-24 17:51:37 +00:00
Arthur Sonzogni
c686e8f4fd Rename {absl => std}::optional in //content/
Automated patch, intended to be effectively a no-op.

Context:
https://groups.google.com/a/chromium.org/g/cxx/c/nBD_1LaanTc/m/ghh-ZZhWAwAJ?utm_medium=email&utm_source=footer

As of https://crrev.com/1204351, absl::optional is now a type alias for
std::optional. We should migrate toward it.

Script:
```
function replace {
  echo "Replacing $1 by $2"
  git grep -l "$1" \
    | cut -f1 -d: \
    | grep \
      -e "^content" \
    | sort \
    | uniq \
    | grep \
      -e "\.h" \
      -e "\.cc" \
      -e "\.mm" \
      -e "\.py" \
    | xargs sed -i "s/$1/$2/g"
}
replace "absl::make_optional" "std::make_optional"
replace "absl::optional" "std::optional"
replace "absl::nullopt" "std::nullopt"
replace "absl::in_place" "std::in_place"
replace "absl::in_place_t" "std::in_place_t"
replace "\"third_party\/abseil-cpp\/absl\/types\/optional.h\"" "<optional>"
git cl format
```

# Skipping unrelated "check_network_annotation" errors.
NOTRY=True

Bug: chromium:1500249
Change-Id: Icfd31a71d8faf63a2e8d5401127e7ee74cc1c413
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5185537
Auto-Submit: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1245739}
2024-01-11 08:36:37 +00:00
weidongliu
eceedb76a9 Fix mojo connection for non-broker browser process and child process in ipcz mode.
On Lacros, Chrome is not always the broker. Therefore,
ContentBrowserClient provides a BindBrowserControlInterface to provide
an interface for communication between external processes and the
browser process. However, in ipcz mode, using this function will cause
the child process to be unable to establish a connection with the
browser process.

Bug: 1447576
Change-Id: I0d27cfe88e7d94685787c7936a510d5652a4c849
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4929586
Commit-Queue: Bo Liu <boliu@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209418}
2023-10-13 14:25:56 +00:00
Ziad Youssef
39ab668e59 Report variations seed version crash key for child processes
The previous change (https://crrev.com/c/4757080) added the crash key
for the browser crashes only. This adds a command line switch to pass
the seed version form the browser process to child processes. Child
processes use the command line switch value to report the value
of the variations seed version crash key.


Bug: 1445117
Change-Id: Idcb159933a41cc0436eb552fe252fd53f93cf4eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4900181
Commit-Queue: Ziad Youssef <ziadyoussef@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1206435}
2023-10-06 15:35:45 +00:00
Ian Vollick
07376dcb4f [ios] Enable field trial initialization for use_blink
With this CL, we enable field trial initialization which is required
for the content_browsertests which use multiprocess in the simulator.

For the base/* code,
   !BUILDFLAG(IS_IOS) -> BUILDFLAG(USE_BLINK)
   BUILDFLAG(IS_MAC) -> BUILDFLAG(IS_APPLE) && BUILDFLAG(USE_BLINK)

For content/browser/* since this code will only be use for multi-
process, the ios conditional has been removed.

credit: dtapuska@ noticed that this was disabled and suggested the
approach.

Bug: 1413706
Change-Id: I3e2d238ab85798c39e991b1217adaa010722bc5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4480670
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Commit-Queue: Ian Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1136734}
2023-04-27 19:50:26 +00:00
Michael Thiessen
2d864d931a Allow default initializing BrowserTaskTraits
Now that the circular dependency between browser_thread.h and
browser_task_traits.h has been resolved, browser_thread.h can include
browser_task_traits.h and provide a default ({}) for BrowserTaskTraits.

A bunch of includes in other files needed to be updated.

Bug: 1424788, 1026641, 1429044
Change-Id: Ibc44e495f743eee029fb45832b1084f03ca47555
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4402191
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1127199}
2023-04-06 15:20:56 +00:00
Will Harris
ee9f0a2db2 Add write sequence checker on base::CommandLine.
This CL adds a sequence checker that verifies if a command line
is being modified, it is done in on its owning sequence, since
multiple sequences modifying the same instance is unsafe.

Note: This CL does not make base::CommandLine entirely safe
as simultaneous reads across multiple sequences when the
owning sequence is performing a modification is still unsafe,
but adding a full sequence checker on every base::CommandLine
instance caused too many DCHECKs to be reasonable to land,
for now.

The one remaining instance when writes are done to a command
line instance on multiple sequences was updated to detach from
the current sequence in the constructor, all other instances
have already been fixed in previous CLs.

This CL also fixes a comment that had accidentally migrated
to the wrong place in the header file.

BUG=1344948

Change-Id: I2e2250ce739222ea143b5021f383720614d4bb90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4241879
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1112451}
2023-03-02 21:38:58 +00:00
Will Harris
5cb6a47ab9 Refactor logic determining untrusted mojo invitation flag.
Renderer processes use the MOJO_SEND_INVITATION_FLAG_UNTRUSTED_PROCESS
flag on their mojo invitation to ensure security constraints related to
Windows handles are respected by mojo.

Before this CL, this flag was being set in the renderer process host
code unconditionally, on all platforms.

This CL moves the decision on whether or not to set this flag to the
SandboxedProcessLauncherDelegate implementation specific to the
sandboxed process.

This allows more flexibility going forward about applying this
mitigation to more sandboxed process types.

This CL makes no functional changes as the same flag is just being
set in a different place, and still only for renderers, but now just
on Windows.

This CL also contains some cleanups for header files to specify
which interface is being implemented by which class, as well as
passing a const ref base::CommandLine to the Windows sandboxed
process launcher delegate to make it clear that it does not
modify the command line in the constructor.

BUG=1419544

Change-Id: I1df21dc0663a6cf541ab85fb08e66484b8155e96
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4291989
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1109927}
2023-02-25 01:56:14 +00:00
Will Harris
a7fb9d09b5 Move CreateNamedPlatformChannel logic to launcher thread.
The Named Platform Channel code manipulates the command line
but the command_line_ member is logically bound to the
launcher thread.

base::CommandLine will soon dcheck for unsafe accesses such
as these.

This CL moves all accesses of the command line member to the
launcher thread, so that there is no potential for a race.

BUG=1344948

Change-Id: I055cda5bf1c392c803a4e4202219e6dd86a13177
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4250178
Reviewed-by: Bo Liu <boliu@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1105447}
2023-02-15 02:08:24 +00:00
Dave Tapuska
a1cc370d96 [ios] Initial RenderWidgetHostViewIOS implementation.
- Rudimentary implementation that allows touch events and keyboard
events to be delivered to a renderer.
- For each RenderWidgetHostViewIOS we create a BrowserCompositorIOS
which will attach the layers to a parent ui::Compositor. This
architecture is similar to how Mac works and is sufficient for
the initial prototype now.
- Provide a stub for a ChildProcessLauncher for iOS since we do not
have fork everything runs in process for now.

Bug: 1411704
Change-Id: I5f498dff7866f0c728bb593eb993235afb94a143
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4221595
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1101174}
2023-02-03 20:43:24 +00:00
Matthew Denton
759d365387 Linux: Rename USE_ZYGOTE_HANDLE -> USE_ZYGOTE
USE_ZYGOTE_HANDLE refers to "whether or not to compile in zygote
support" so it should really just be named USE_ZYGOTE. Especially as
https://crrev.com/c/4167265 deletes the ZygoteHandle typedef entirely.

Bug: 1407326

Change-Id: Ife9dd310b7e2033aa1816fbeaff8ece9e9a1d0da
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4167344
Reviewed-by: Derek Schuff <dschuff@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1095316}
2023-01-21 02:05:37 +00:00
Avi Drissman
adac219925 Update header includes for /base/functional in /content
bind.h, callback.h, callback_forward.h, and callback_helpers.h
moved into /base/functional/. Update the include paths to
directly include them in their new location.

Bug: 1364441
Change-Id: I32ec425b9c0e52ec4b50047bf3290fecc5c905ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4148554
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Owners-Override: Avi Drissman <avi@chromium.org>
Owners-Override: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091567}
2023-01-11 23:46:39 +00:00
Matthew Denton
7f7c1f5c69 Cleanup child_process_launcher_helper*
This includes a number of cleanups to remove sharp edges from
child_process_launcher_helper:

1. Not all processes are launched with base::LaunchProcess, but
   base::LaunchOptions* is passed to every function. This has led to
   misunderstandings; for example Android adds
   `file_data_->additional_remapped_fds` to `options->fds_to_remap`, but
   Android never uses `options` and so this is pointless (Android
   has to use the app zygote and so it cannot use `options` or even
   remap FDs).
   In addition, on Linux, processes launched with a zygote do not
   use base::LaunchProcess().
   This CL adds an IsUsingLaunchOptions() to the
   child_process_launcher_helper* implementations and passes nullptr
   as `options` if IsUsingLaunchOptions() returns false.

2. `ChildProcessLauncherFileData::additional_remapped_fds` is removed
   entirely. It didn't work on Android as mentioned above, and nobody
   else uses it now that the Lacros startup data logic has changed.

3. `ChildProcessLauncherFileData::files_to_preload` is no longer
   #ifdef'd for Mac as it is ignored. (Unclear why it is ignored)

4. DCHECKs that `delegate_->GetEnvironment()` is empty on Linux when
   using the zygote, it isn't supported, though it could eventually be.

Change-Id: If805117bdf888cbcc21432aab665c66ea31fa3ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4141863
Reviewed-by: Luc Nguyen <lucnguyen@google.com>
Commit-Queue: Matthew Denton <mpdenton@chromium.org>
Reviewed-by: Bo Liu <boliu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091562}
2023-01-11 23:35:12 +00:00
Sean Maher
52fa5a7f26 task posting v3: moving away from SequencedTaskRunnerHandle
To continue the migration away from TaskRunnerHandles, the codebase
was refactored using the following scripts:
shell script:
https://paste.googleplex.com/4673967729147904
python:
https://paste.googleplex.com/5302682490241024

This will do a few sed-like modifications, changing calls to methods of
SequencedTaskRunnerHandle to calls to methods of
SequencedTaskRunner::CurrentDefaultHandle, and swapping includes.

Bug: 1026641
AX-Relnotes: n/a.
Change-Id: I49e50a2bd1e78b00e7c067219fff96d2e0bc0b46
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3983373
Commit-Queue: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Reviewed-by: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1071032}
2022-11-14 15:53:25 +00:00
Bryant Chandler
21bd58c507 [fuchsia] Wait for process to terminate before destroying sandbox policy
Without this change it is possible to have a sequence as follows:
1. Request termination of child process
2. Destroy sandbox_policy_
3. Additional FIDL calls that fail because of missing sandbox_policy_
3. Process actually terminates

Moving the sandbox_policy object to the child process object forces
that sequence to be:
1. Request termination of child process
2. Wait for termination to complete, during which additional FIDL calls
   will be successful
3. Destroy sandbox_policy_

Bug: 1369665
Change-Id: Idceb021f95f35de6cd8dad23a233ea3a73a06b86
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4009118
Auto-Submit: Bryant Chandler <bryantchandler@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1068907}
2022-11-09 00:58:34 +00:00
Ken Rockot
89903dec9a MojoIpcz: Full handle xfer for elevated processes
Adds a few additional bits of state to the MojoIpcz transport
implementation, in particular to track relative trust level across the
transport independent of broker/non-broker status.

Also introduces new Mojo invitation API flags to indicate when the
caller is inviting a process (or accepting an invitation as a process)
that is trustworthy, e.g. an elevated Windows process.

Combined these changes allow trusted non-broker nodes to transfer
pre-duplicated handles to brokers, rendering elevated processes
fully functional in a network of MojoIpcz processes. This turns out
to be necessary for existing elevated process usage in Chrome due
to how ipcz communication is bootstrapped.

TEST=browser_tests for ImageWriterUtilityClient* on Windows with MojoIpcz enabled

Bug: 1374611
Change-Id: Id9a6056e239c6ec0f258cd053489fd1771e3c850
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3963307
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Alex Gough <ajgo@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/main@{#1061775}
2022-10-20 20:21:03 +00:00
Avi Drissman
4e1b7bc33d Update copyright headers in content/
The methodology used to generate this CL is documented in
https://crbug.com/1098010#c34.

No-Try: true
No-Presubmit: true
Bug: 1098010
Change-Id: I8c0f009d16350271f07d8e5e561085822cc9dd27
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3895935
Owners-Override: Avi Drissman <avi@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
Auto-Submit: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1047456}
2022-09-15 14:03:50 +00:00
Eriko Kurimoto
9c83b40ac0 [Resource file sharing]: Pass BrowserInitParams to Utility process as File Descriptor
This CL passes BrowserInitParams to Utility process as Memory FD.
FD map is contained in BrowserChildProcessHost::DataToPassAsFD with
files_to_preload.

This CL also changes files_to_preload field to limit only on posix
platforms.
Note that files_to_preload value was only used from posix even without
this CL, so it won't affect the behavior.

This change aims to let utility process be able to obtain ash dir from BrowserInitParams. This feature will be implemented in the later CL.
This is a part of resource file sharing work and doesn't affect the
behavior for now.

Bug: 1253280
Change-Id: Ibd92217974e2e763c58ab71af85ee50a13d2c03e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3599393
Reviewed-by: Bo Liu <boliu@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Commit-Queue: Eriko Kurimoto <elkurin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1001877}
2022-05-11 02:36:32 +00:00
Gabriel Charette
bdd68018e8 [base] Remove unused post_task.h includes
This CL is a no-op.

Bug: 1026641
AX-Relnotes: n/a
Change-Id: If45d30e748b65097bb6be666dc305c27183d83ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3555247
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Reviewed-by: Francois Pierre Doray <fdoray@chromium.org>
Commit-Queue: Francois Pierre Doray <fdoray@chromium.org>
Owners-Override: Francois Pierre Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987328}
2022-03-31 04:00:05 +00:00
Xiaohan Wang
1ecfd006fd content: Use BUILDFLAG for OS checking
Use BUILDFLAG(IS_XXX) instead of defined(OS_XXX).

Generated by `os_buildflag_migration.py` (https://crrev.com/c/3311983).

R=thakis@chromium.org

Bug: 1234043
Test: No functionality change
Change-Id: Ia0eae6f9396065e190929d42600012c9324c07e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3399774
Commit-Queue: Xiaohan Wang <xhwang@chromium.org>
Owners-Override: Xiaohan Wang <xhwang@chromium.org>
Auto-Submit: Xiaohan Wang <xhwang@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Owners-Override: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#961157}
2022-01-19 22:33:10 +00:00
Will Harris
df8fcb48c2 Reland "Add launch failure notifications to BrowserChildProcessObserver"
This is a reland of 893230151e

The previous version of this CL mistakenly removed a default
case statement for an 'int' field, so an expected compile error
was not generated but instead an early return was skipped.

Original change's description:
> Add launch failure notifications to BrowserChildProcessObserver
>
> Also, fix a bug where the Windows sandbox would return SBOX_ALL_OK
> even if base::LaunchProcess failed, and launch_result was not
> being set for elevated processes.
>
> Add reporting of GetLastError on Windows in the
> ChildProcessTerminationInfo for failed launches.
>
> Also, clean up some switch statements to remove default cases.
>
> BUG=1280005
>
> Change-Id: I1001fc950b8456b78ef1a9a985ca07cf288e8a04
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3340072
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Commit-Queue: Will Harris <wfh@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#952182}

Bug: 1280005, 1280541
Change-Id: I81f3354e9870a455644e77144a40c4acbdf14ebe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3345720
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#952667}
2021-12-18 09:21:31 +00:00
Kush Sinha
d26f685ff4 [Sheriff] Revert "Add launch failure notifications to BrowserChildProcessObserver"
This reverts commit 893230151e.

Reason for revert: "browser_tests" failing on builder "Linux ChromiumOS MSan Tests"

Original change's description:
> Add launch failure notifications to BrowserChildProcessObserver
>
> Also, fix a bug where the Windows sandbox would return SBOX_ALL_OK
> even if base::LaunchProcess failed, and launch_result was not
> being set for elevated processes.
>
> Add reporting of GetLastError on Windows in the
> ChildProcessTerminationInfo for failed launches.
>
> Also, clean up some switch statements to remove default cases.
>
> BUG=1280005
>
> Change-Id: I1001fc950b8456b78ef1a9a985ca07cf288e8a04
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3340072
> Reviewed-by: John Abd-El-Malek <jam@chromium.org>
> Commit-Queue: Will Harris <wfh@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#952182}

Bug: 1280005, 1280541
Change-Id: I368d0c89ca6911cb4145bcec13edf2ad8bd4d829
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3344787
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Kush Sinha <sinhak@chromium.org>
Reviewed-by: Aya Elsayed <ayaelattar@chromium.org>
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Owners-Override: Kush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/main@{#952303}
2021-12-16 11:00:34 +00:00
Will Harris
893230151e Add launch failure notifications to BrowserChildProcessObserver
Also, fix a bug where the Windows sandbox would return SBOX_ALL_OK
even if base::LaunchProcess failed, and launch_result was not
being set for elevated processes.

Add reporting of GetLastError on Windows in the
ChildProcessTerminationInfo for failed launches.

Also, clean up some switch statements to remove default cases.

BUG=1280005

Change-Id: I1001fc950b8456b78ef1a9a985ca07cf288e8a04
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3340072
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#952182}
2021-12-16 01:17:22 +00:00
Will Harris
c5ee130a5b Remove fallback for case where remote process cannot be accessed.
For case where remote process is running elevated or in another
session the code would fallback to using a named pipe.

This CL changes this to be explicit by passing a null process
handle into the SendInvitation call and updating mojo to
cater for this gracefully

BUG=1268087

Change-Id: Ie40836ece3f246e475cb55154ee6fb404bd230d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3308391
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Will Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/main@{#948875}
2021-12-07 07:21:14 +00:00
Scott Violet
0e21474081 content: adds histogram Renderer.BrowserLaunchToRunLoopStart
This is logged once per renderer launch. It gives the time from when
the browser started the process launch, to time the renderer message
loop starts.

BUG=1271338
TEST=none

Change-Id: Ifb466ac86423057ea2ac5fd1523c2b4c70efaab4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3297170
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/main@{#946029}
2021-11-29 18:01:31 +00:00
Fabrice de Gans
24f4a80bee [field-trial] Refactor FieldTrial and add Fuchsia support
This refactors FieldTrial to simplify its public API and unify it
across all platforms so every public method has the same signature on
every platform.

This simplifies the call sites in the content layer by removing
per-platform specific call sites in favor of unified calls and moving
some of the logic done in //content to //base. In particular, command
line switches used only by FieldTrial have been moved to //base, from
//content. They are also no longer passed as parameters to the public
API of FieldTrial.

In addition, this adds supports for shared-memory distribution of
FieldTrial configuration to child processes on Fuchsia. This is
achieved by duplicating the handle for the VMO backing the FieldTrial
configuration in the parent process and passing it to the child
process startup handles.

This also changes the Windows child process launcher logic to make use
of the provided LaunchOptions argument, rather than initializing a new
object.

Finally, this cleans up header usage in //base/metrics/field_trial.h
and fixes missing includes in various parts of the code base.

Bug: 752368, 1262370
Change-Id: I9b0836b467790f1da96d85fe16a6e2c6d334f709
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3230582
Commit-Queue: Fabrice de Gans <fdegans@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: Alexei Svitkine <asvitkine@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Theresa  <twellington@chromium.org>
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Will Harris <wfh@chromium.org>
Reviewed-by: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/main@{#938902}
2021-11-05 19:57:14 +00:00
Patrick Monette
643cdf6190 Replace base/task/ temporary forward headers with their final locations
Note to QA: This merely changes includes and should not be blamed
for files it touched.

Bug: 1255932
Change-Id: I1ce4e31efd5792ebf2080812e665cae838a54972
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226943
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#932153}
2021-10-15 19:13:42 +00:00
Patrick Monette
3d7d70920a Replace task-related headers to their equivalent in base/task/
This CL was generated by using tools/git/move_source_file.py to change
the includes for those files:
base/bind_post_task.h
base/deferred_sequenced_task_runner.h
base/post_task_and_reply_with_result_internal.h
base/sequenced_task_runner.h
base/sequenced_task_runner_helpers.h
base/single_thread_task_runner.h
base/task_runner.h
base/task_runner_util.h
base/updateable_sequenced_task_runner.h

Then formatted using "git cl format". DEPS files were fixed with a
simple search and replace script.

Bug: 1255932
Change-Id: I0d9b5ddd9260fde5e4581e6c6e0080bdb0ed2c44
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3209175
Reviewed-by: Gabriel Charette <gab@chromium.org>
Owners-Override: Gabriel Charette <gab@chromium.org>
Commit-Queue: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/main@{#929867}
2021-10-08 20:27:23 +00:00
Gabriel Charette
59ff6f67c9 [base] Make LazyTaskRunner explicitly ThreadPool-specific
TBR=fdoray@chromium.org
(TBR for side-effects of mechanical change)

Bug: 1026641
Change-Id: Ic0805fa52bd28aa93780749842f094e92a3e2ba9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994069
Commit-Queue: Gabriel Charette <gab@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Auto-Submit: Gabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736016}
2020-01-28 20:16:35 +00:00
Ken Rockot
8dda8888b4 Reland "Reland "Move Renderer processes off Service Manager""
This reverts commit d10a4fc5f2.

Reason for revert: Reverting the revert which was only done make reverting an earlier CL possible. Earlier CL has been fixed and relanded.

Original change's description:
> Revert "Reland "Move Renderer processes off Service Manager""
> 
> This reverts commit 881a65d746.
> 
> Reason for revert: breaks graphics on some Chrome OS devices.
> 
> Original change's description:
> > Move Renderer processes off Service Manager
> >
> > Migrates Renderer processes to use the simpler ChildProcess IPC
> > interface in place of deprecated Service Manager IPC.
> >
> > Support for preloaded files in service manifest definitions is
> > effectively removed in favor of explicit parameters on
> > BrowserChildProcessHost and ChildProcessLauncher. The only use case (V8
> > snapshot files) has been migrated from manifest data to a simple map
> > definition, and it's used during renderer and utility process
> > launching.
> >
> > After this CL, only utility processes remain to be moved off of
> > Service
> > Manager IPC.
> >
> > NOPRESUBMIT=true
> >
> > Bug: 977637
> > Change-Id: I1d8205cb73ead904aa21b85d6cbee11cb3fc84f5
> > Tbr: boliu@chromium.org
> > Tbr: yucliu@chromium.org
> > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918375
> > Reviewed-by: Martin Barbella <mbarbella@chromium.org>
> > Reviewed-by: Robert Sesek <rsesek@chromium.org>
> > Reviewed-by: Avi Drissman <avi@chromium.org>
> > Commit-Queue: Ken Rockot <rockot@google.com>
> > Cr-Commit-Position: refs/heads/master@{#717920}
> 
> NOPRESUBMIT=true
> 
> Bug: 1028852
> Bug: 977637
> Tbr: rockot@google.com
> Tbr: boliu@chromium.org
> Tbr: yucliu@chromium.org
> Tbr: mbarbella@chromium.org
> Tbr: rsesek@chromium.org
> Tbr: avi@chromium.org
> Change-Id: I30a52d825cc156b066d7c2ec455c8fb588a408af
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948663
> Commit-Queue: Shuhei Takahashi <nya@chromium.org>
> Reviewed-by: Shuhei Takahashi <nya@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#720939}

TBR=avi@chromium.org,boliu@chromium.org,rockot@google.com,nya@chromium.org,mbarbella@chromium.org,rsesek@chromium.org,yucliu@chromium.org

Change-Id: I69de741d907abd790bdad3019abeeb9a8ca231aa
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1028852, 977637
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1949778
Reviewed-by: Ken Rockot <rockot@google.com>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#721377}
2019-12-04 05:56:22 +00:00
Shuhei Takahashi
d10a4fc5f2 Revert "Reland "Move Renderer processes off Service Manager""
This reverts commit 881a65d746.

Reason for revert: breaks graphics on some Chrome OS devices.

Original change's description:
> Move Renderer processes off Service Manager
>
> Migrates Renderer processes to use the simpler ChildProcess IPC
> interface in place of deprecated Service Manager IPC.
>
> Support for preloaded files in service manifest definitions is
> effectively removed in favor of explicit parameters on
> BrowserChildProcessHost and ChildProcessLauncher. The only use case (V8
> snapshot files) has been migrated from manifest data to a simple map
> definition, and it's used during renderer and utility process
> launching.
>
> After this CL, only utility processes remain to be moved off of
> Service
> Manager IPC.
>
> NOPRESUBMIT=true
>
> Bug: 977637
> Change-Id: I1d8205cb73ead904aa21b85d6cbee11cb3fc84f5
> Tbr: boliu@chromium.org
> Tbr: yucliu@chromium.org
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918375
> Reviewed-by: Martin Barbella <mbarbella@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: Ken Rockot <rockot@google.com>
> Cr-Commit-Position: refs/heads/master@{#717920}

NOPRESUBMIT=true

Bug: 1028852
Bug: 977637
Tbr: rockot@google.com
Tbr: boliu@chromium.org
Tbr: yucliu@chromium.org
Tbr: mbarbella@chromium.org
Tbr: rsesek@chromium.org
Tbr: avi@chromium.org
Change-Id: I30a52d825cc156b066d7c2ec455c8fb588a408af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1948663
Commit-Queue: Shuhei Takahashi <nya@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>
Cr-Commit-Position: refs/heads/master@{#720939}
2019-12-03 13:35:16 +00:00
Ken Rockot
881a65d746 Reland "Move Renderer processes off Service Manager"
This is a reland of 45cef59a78

Original change's description:
> Move Renderer processes off Service Manager
>
> Migrates Renderer processes to use the simpler ChildProcess IPC
> interface in place of deprecated Service Manager IPC.
>
> Support for preloaded files in service manifest definitions is
> effectively removed in favor of explicit parameters on
> BrowserChildProcessHost and ChildProcessLauncher. The only use case (V8
> snapshot files) has been migrated from manifest data to a simple map
> definition, and it's used during renderer and utility process launching.
>
> After this CL, only utility processes remain to be moved off of Service
> Manager IPC.
>
> NOPRESUBMIT=true
>
> Bug: 977637
> Change-Id: I1d8205cb73ead904aa21b85d6cbee11cb3fc84f5
> Tbr: boliu@chromium.org
> Tbr: yucliu@chromium.org
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1918375
> Reviewed-by: Martin Barbella <mbarbella@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Avi Drissman <avi@chromium.org>
> Commit-Queue: Ken Rockot <rockot@google.com>
> Cr-Commit-Position: refs/heads/master@{#717920}

NOPRESUBMIT=true

Bug: 977637
Change-Id: I9dd89104626ef73f81abd93c8a35310a2d6997a2
Tbr: boliu@chromium.org
Tbr: yucliu@chromium.org
Tbr: mbarbella@chromium.org
Tbr: avi@chromium.org
Tbr: rsesek@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1930104
Reviewed-by: Ken Rockot <rockot@google.com>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Cr-Commit-Position: refs/heads/master@{#718334}
2019-11-22 22:49:07 +00:00