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

Unified Diff: net/quic/congestion_control/windowed_filter.h

Issue 2127153002: Allow WindowedFilter to use arbitrary time type instead of QuicTime. No functional change. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@126423259
Patch Set: Created 4 years, 5 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
« no previous file with comments | « net/quic/congestion_control/rtt_stats.cc ('k') | net/quic/congestion_control/windowed_filter_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/windowed_filter.h
diff --git a/net/quic/congestion_control/windowed_filter.h b/net/quic/congestion_control/windowed_filter.h
index 65dd866cb8ee27e8a99a859a4ccf7270239178f0..50a6b1c2fd4ab2b64cb1583f2b47ed4e1ef5e22c 100644
--- a/net/quic/congestion_control/windowed_filter.h
+++ b/net/quic/congestion_control/windowed_filter.h
@@ -51,24 +51,34 @@ struct MaxFilter {
};
// Use the following to construct a windowed filter object of type T.
-// For a min filter: WindowedFilter<T, MinFilter<T>> ObjectName;
-// For a max filter: WindowedFilter<T, MaxFilter<T>> ObjectName;
-template <class T, class Compare>
+// For example, a min filter using QuicTime as the time type:
+// WindowedFilter<T, MinFilter<T>, QuicTime, QuicTime::Delta> ObjectName;
+// A max filter using 64-bit integers as the time type:
+// WindowedFilter<T, MaxFilter<T>, uint64_t, int64_t> ObjectName;
+// Specifically, this template takes four arguments:
+// 1. T -- type of the measurement that is being filtered.
+// 2. Compare -- MinFilter<T> or MaxFilter<T>, depending on the type of filter
+// desired.
+// 3. TimeT -- the type used to represent timestamps.
+// 4. TimeDeltaT -- the type used to represent continuous time intervals between
+// two timestamps. Has to be the type of (a - b) if both |a| and |b| are
+// of type TimeT.
+template <class T, class Compare, typename TimeT, typename TimeDeltaT>
class WindowedFilter {
public:
// |window_length| is the period after which a best estimate expires.
// |zero_value| is used as the uninitialized value for objects of T.
// Importantly, |zero_value| should be an invalid value for a true sample.
- WindowedFilter(QuicTime::Delta window_length, T zero_value)
+ WindowedFilter(TimeDeltaT window_length, T zero_value, TimeT zero_time)
: window_length_(window_length),
zero_value_(zero_value),
- estimates_{Sample(zero_value_, QuicTime::Zero()),
- Sample(zero_value_, QuicTime::Zero()),
- Sample(zero_value_, QuicTime::Zero())} {}
+ estimates_{Sample(zero_value_, zero_time),
+ Sample(zero_value_, zero_time),
+ Sample(zero_value_, zero_time)} {}
// Updates best estimates with |sample|, and expires and updates best
// estimates as necessary.
- void Update(T new_sample, QuicTime new_time) {
+ void Update(T new_sample, TimeT new_time) {
// Reset all estimates if they have not yet been initialized, if new sample
// is a new best, or if the newest recorded estimate is too old.
if (estimates_[0].sample == zero_value_ ||
@@ -119,7 +129,7 @@ class WindowedFilter {
}
// Resets all estimates to new sample.
- void Reset(T new_sample, QuicTime new_time) {
+ void Reset(T new_sample, TimeT new_time) {
estimates_[0] = estimates_[1] = estimates_[2] =
Sample(new_sample, new_time);
}
@@ -131,14 +141,14 @@ class WindowedFilter {
private:
struct Sample {
T sample;
- QuicTime time;
- Sample(T init_sample, QuicTime init_time)
+ TimeT time;
+ Sample(T init_sample, TimeT init_time)
: sample(init_sample), time(init_time) {}
};
- QuicTime::Delta window_length_; // Time length of window.
- T zero_value_; // Uninitialized value of T.
- Sample estimates_[3]; // Best estimate is element 0.
+ TimeDeltaT window_length_; // Time length of window.
+ T zero_value_; // Uninitialized value of T.
+ Sample estimates_[3]; // Best estimate is element 0.
};
} // namespace net
« no previous file with comments | « net/quic/congestion_control/rtt_stats.cc ('k') | net/quic/congestion_control/windowed_filter_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698