[battery] Don't assume that coalition_info_resource_usage will work if it worked before.
It was wrong to assume that coalition_info_resource_usage will return a value if it returned a value in a previous call. It can fail if the kernel can't allocate memory (https://github.com/apple/darwin-xnu/blob/main/osfmk/kern/coalition.c#L736). This CL makes the code resilient to that. Bug: 1298733 Change-Id: I3f6700dd6911eef06b9d2666e715a3a72e9ddcb9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3473471 Commit-Queue: Francois Pierre Doray <fdoray@chromium.org> Auto-Submit: Francois Pierre Doray <fdoray@chromium.org> Reviewed-by: Etienne Pierre-Doray <etiennep@chromium.org> Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org> Cr-Commit-Position: refs/heads/main@{#973002}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
bbd3540310
commit
cd1cf9729b
chrome/browser/metrics/power
components/power_metrics
@ -30,7 +30,8 @@ struct EnergyImpactCoefficients;
|
||||
absl::optional<uint64_t> GetProcessCoalitionId(base::ProcessId pid);
|
||||
|
||||
// Returns resource usage data for the coalition identified by |coalition_id|,
|
||||
// or nullptr if not available.
|
||||
// or nullptr if not available (e.g. if `coalition_id` is invalid or if the
|
||||
// kernel can't allocate memory).
|
||||
std::unique_ptr<coalition_resource_usage> GetCoalitionResourceUsage(
|
||||
int64_t coalition_id);
|
||||
|
||||
|
Reference in New Issue
Block a user