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

Unified Diff: remoting/base/rate_counter.h

Issue 2561173004: Cleanup RateCounter (Closed)
Patch Set: Created 4 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 | remoting/base/rate_counter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/base/rate_counter.h
diff --git a/remoting/base/rate_counter.h b/remoting/base/rate_counter.h
index ee34edc0e38c87c282885ebbf86600271f8ce463..a7e0f35b3b6ea679acd0d72dc51e7ff90dcbb128 100644
--- a/remoting/base/rate_counter.h
+++ b/remoting/base/rate_counter.h
@@ -12,6 +12,8 @@
#include "base/macros.h"
#include "base/threading/non_thread_safe.h"
+#include "base/time/default_tick_clock.h"
+#include "base/time/tick_clock.h"
#include "base/time/time.h"
namespace remoting {
@@ -32,18 +34,16 @@ class RateCounter : public base::NonThreadSafe {
// Note that rates reported before |time_window| has elapsed are not accurate.
double Rate();
- // Overrides the current time for testing.
- void SetCurrentTimeForTest(base::Time current_time);
+ void set_tick_clock_for_tests(base::TickClock* tick_clock) {
+ tick_clock_ = tick_clock;
+ }
private:
// Type used to store data points with timestamps.
- typedef std::pair<base::Time, int64_t> DataPoint;
+ typedef std::pair<base::TimeTicks, int64_t> DataPoint;
// Removes data points more than |time_window| older than |current_time|.
- void EvictOldDataPoints(base::Time current_time);
-
- // Returns the current time specified for test, if set, or base::Time::Now().
- base::Time CurrentTime() const;
+ void EvictOldDataPoints(base::TimeTicks current_time);
// Time window over which to calculate the rate.
const base::TimeDelta time_window_;
@@ -54,8 +54,8 @@ class RateCounter : public base::NonThreadSafe {
// Sum of values in |data_points_|.
int64_t sum_;
- // If set, used to calculate the running average, in place of Now().
- base::Time current_time_for_test_;
+ base::DefaultTickClock default_tick_clock_;
+ base::TickClock* tick_clock_ = &default_tick_clock_;
DISALLOW_COPY_AND_ASSIGN(RateCounter);
};
« no previous file with comments | « no previous file | remoting/base/rate_counter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698