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

Unified Diff: chrome/browser/ui/app_list/search/app_search_provider.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
Index: chrome/browser/ui/app_list/search/app_search_provider.cc
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index c9ea710c745d4f82caff0efe0d9dbf2d7db8f9ec..02f2667ca10fe8356b21994f51c3528b21db431a 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/strings/utf_string_conversions.h"
+#include "base/time/clock.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_ui_util.h"
#include "chrome/browser/extensions/extension_util.h"
@@ -46,10 +47,12 @@ class AppSearchProvider::App {
};
AppSearchProvider::AppSearchProvider(Profile* profile,
- AppListControllerDelegate* list_controller)
+ AppListControllerDelegate* list_controller,
+ scoped_ptr<base::Clock> clock)
: profile_(profile),
list_controller_(list_controller),
- extension_registry_observer_(this) {
+ extension_registry_observer_(this),
+ clock_(clock.Pass()) {
extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
RefreshApps();
}
@@ -57,16 +60,10 @@ AppSearchProvider::AppSearchProvider(Profile* profile,
AppSearchProvider::~AppSearchProvider() {}
void AppSearchProvider::Start(const base::string16& query) {
- StartImpl(base::Time::Now(), query);
-}
-
-void AppSearchProvider::Stop() {
-}
-
-void AppSearchProvider::StartImpl(const base::Time& current_time,
- const base::string16& query) {
query_ = query;
- search_time_ = current_time;
+ const TokenizedString query_terms(query);
+
+ ClearResults();
bool show_recommendations = query.empty();
// Refresh list of apps to ensure we have the latest launch time information.
@@ -77,6 +74,9 @@ void AppSearchProvider::StartImpl(const base::Time& current_time,
UpdateResults();
}
+void AppSearchProvider::Stop() {
+}
+
void AppSearchProvider::UpdateResults() {
const TokenizedString query_terms(query_);
bool show_recommendations = query_.empty();
@@ -89,7 +89,7 @@ void AppSearchProvider::UpdateResults() {
new AppResult(profile_, (*app_it)->app_id(), list_controller_));
if (show_recommendations) {
result->set_title((*app_it)->indexed_name().text());
- result->UpdateFromLastLaunched(search_time_,
+ result->UpdateFromLastLaunched(clock_->Now(),
(*app_it)->last_launch_time());
} else {
TokenizedStringMatch match;

Powered by Google App Engine
This is Rietveld 408576698