Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(250)

Unified Diff: chrome/browser/ui/app_list/search/app_result.cc

Issue 789623003: Use base::Clock instead of base::Time::Now in AppSearchProvider. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@now_source
Patch Set: rebase Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/app_search_provider.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/search/app_result.cc
diff --git a/chrome/browser/ui/app_list/search/app_result.cc b/chrome/browser/ui/app_list/search/app_result.cc
index ae0166af362a79a9508a78b45ed708fff8f20dc5..435dcf688bed431aeb37864d99332f22a33187f1 100644
--- a/chrome/browser/ui/app_list/search/app_result.cc
+++ b/chrome/browser/ui/app_list/search/app_result.cc
@@ -81,7 +81,13 @@ void AppResult::UpdateFromMatch(const TokenizedString& title,
void AppResult::UpdateFromLastLaunched(const base::Time& current_time,
const base::Time& last_launched) {
base::TimeDelta delta = current_time - last_launched;
- DCHECK_LE(0, delta.InSeconds());
+ // |current_time| can be before |last_launched| in weird cases such as users
+ // playing with their clocks. Handle this gracefully.
+ if (current_time < last_launched) {
+ set_relevance(1.0);
+ return;
+ }
+
const int kSecondsInWeek = 60 * 60 * 24 * 7;
// Set the relevance to a value between 0 and 1. This function decays as the
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/app_search_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698