From 13a128b8cbd479e573670cfbc0b44f77cadeb0e3 Mon Sep 17 00:00:00 2001 From: Sorin Jianu <sorin@chromium.org> Date: Fri, 4 Aug 2023 22:12:32 +0000 Subject: [PATCH] updater: eliminate TimeTicks check which can fail at runtime. The reason for checking is unknown at the moment. Fixed: 1470361 Change-Id: I2c5632c01bf69d92831904d97fd1e7afcb8f708e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4754293 Reviewed-by: Joshua Pawlicki <waffles@chromium.org> Commit-Queue: Sorin Jianu <sorin@chromium.org> Code-Coverage: Findit <findit-for-me@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/main@{#1179874} --- components/update_client/component.cc | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/components/update_client/component.cc b/components/update_client/component.cc index 2703c133920b6..43170b796f328 100644 --- a/components/update_client/component.cc +++ b/components/update_client/component.cc @@ -602,15 +602,14 @@ void Component::NotifyObservers(UpdateClient::Observer::Events event) const { base::TimeDelta Component::GetUpdateDuration() const { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - - if (update_begin_.is_null()) + if (update_begin_.is_null()) { return base::TimeDelta(); - + } const base::TimeDelta update_cost(base::TimeTicks::Now() - update_begin_); - CHECK_GE(update_cost, base::TimeDelta()); - const base::TimeDelta max_update_delay = - update_context_->config->UpdateDelay(); - return std::min(update_cost, max_update_delay); + if (update_cost.is_negative()) { + return base::TimeDelta(); + } + return std::min(update_cost, update_context_->config->UpdateDelay()); } base::Value::Dict Component::MakeEventUpdateComplete() const {