Commit 8b68cf88 authored by Shao-Chuan Lee's avatar Shao-Chuan Lee Committed by Commit Bot

ArcMetricsService: soft fail when unknown task_id is provided

The code assumes OnTaskCreated and OnTaskDestroyed are called in pairs
for the same task_id, soft fail if it's not the case.

Bug: 908308
Change-Id: I6d8bf5bdabbb601f53cf25e1d03edbc562613a84
Reviewed-on: https://chromium-review.googlesource.com/c/1351347Reviewed-by: default avatarMaajid <maajid@chromium.org>
Reviewed-by: default avatarKazuhiro Inaba <kinaba@chromium.org>
Commit-Queue: Shao-Chuan Lee <shaochuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611073}
parent fac397e9
......@@ -349,7 +349,10 @@ void ArcMetricsService::OnTaskCreated(int32_t task_id,
void ArcMetricsService::OnTaskDestroyed(int32_t task_id) {
UpdateEngagementTime();
auto it = std::find(task_ids_.begin(), task_ids_.end(), task_id);
DCHECK(it != task_ids_.end());
if (it == task_ids_.end()) {
LOG(WARNING) << "unknown task_id, background time might be undermeasured";
return;
}
task_ids_.erase(it);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment