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

Unified Diff: components/search_engines/template_url_service.h

Issue 855633002: [Clean-up] Replace the final straggler use of MockTimeProvider with Clock. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore position of moved code, and extract a helper function for comparing timestamps Created 5 years, 11 months 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: components/search_engines/template_url_service.h
diff --git a/components/search_engines/template_url_service.h b/components/search_engines/template_url_service.h
index dda5de4f3dae0106193e2cc0a8aa2ee84d6e02d4..f93000f5af07d3debfc1b8995fcf36a05bbe3cc1 100644
--- a/components/search_engines/template_url_service.h
+++ b/components/search_engines/template_url_service.h
@@ -16,6 +16,7 @@
#include "base/memory/scoped_ptr.h"
#include "base/observer_list.h"
#include "base/prefs/pref_change_registrar.h"
+#include "base/time/clock.h"
#include "components/google/core/browser/google_url_tracker.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/search_engines/default_search_manager.h"
@@ -69,8 +70,6 @@ class TemplateURLService : public WebDataServiceConsumer,
public:
typedef std::map<std::string, std::string> QueryTerms;
typedef std::vector<TemplateURL*> TemplateURLVector;
- // Type for a static function pointer that acts as a time source.
- typedef base::Time(TimeProvider)();
typedef std::map<std::string, syncer::SyncData> SyncDataMap;
typedef base::CallbackList<void(void)>::Subscription Subscription;
@@ -366,11 +365,7 @@ class TemplateURLService : public WebDataServiceConsumer,
const syncer::SyncDataList& sync_data);
#if defined(UNIT_TEST)
- // Sets a different time provider function, such as
- // base::MockTimeProvider::StaticNow, for testing calls to base::Time::Now.
- void set_time_provider(TimeProvider* time_provider) {
- time_provider_ = time_provider;
- }
+ void set_clock(scoped_ptr<base::Clock> clock) { clock_ = clock.Pass(); }
#endif
private:
@@ -706,8 +701,8 @@ class TemplateURLService : public WebDataServiceConsumer,
// increasing integer that is initialized from the database.
TemplateURLID next_id_;
- // Function returning current time in base::Time units.
- TimeProvider* time_provider_;
+ // Used to retrieve the current time, in base::Time units.
+ scoped_ptr<base::Clock> clock_;
// Do we have an active association between the TemplateURLs and sync models?
// Set in MergeDataAndStartSyncing, reset in StopSyncing. While this is not

Powered by Google App Engine
This is Rietveld 408576698