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

Side by Side Diff: net/quic/quic_sustained_bandwidth_recorder.h

Issue 476023002: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0814_2
Patch Set: Created 6 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_session_test.cc ('k') | net/quic/quic_sustained_bandwidth_recorder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_QUIC_QUIC_SUSTAINED_BANDWIDTH_RECORDER_H_
6 #define NET_QUIC_QUIC_SUSTAINED_BANDWIDTH_RECORDER_H_
7
8 #include "base/logging.h"
9 #include "net/quic/quic_bandwidth.h"
10 #include "net/quic/quic_time.h"
11
12 namespace net {
13
14 // This class keeps track of a sustained bandwidth estimate to ultimately send
15 // to the client in a server config update message. A sustained bandwidth
16 // estimate is only marked as valid if the QuicSustainedBandwidthRecorder has
17 // been given uninterrupted reliable estimates over a certain period of time.
18 class NET_EXPORT_PRIVATE QuicSustainedBandwidthRecorder {
19 public:
20 QuicSustainedBandwidthRecorder();
21
22 // As long as |is_reliable_estimate| is consistently true, multiple calls to
23 // this method over a 3 * srtt period results in storage of a valid sustained
24 // bandwidth estimate.
25 // |time_now| is used as a max bandwidth timestamp if needed.
26 void RecordEstimate(bool is_reliable_estimate,
27 bool in_slow_start,
28 QuicBandwidth bandwidth,
29 QuicTime estimate_time,
30 QuicWallTime wall_time,
31 QuicTime::Delta srtt);
32
33 bool HasEstimate() const {
34 return has_estimate_;
35 }
36
37 QuicBandwidth BandwidthEstimate() const {
38 DCHECK(has_estimate_);
39 return bandwidth_estimate_;
40 }
41
42 QuicBandwidth MaxBandwidthEstimate() const {
43 DCHECK(has_estimate_);
44 return max_bandwidth_estimate_;
45 }
46
47 int32 MaxBandwidthTimestamp() const {
48 DCHECK(has_estimate_);
49 return max_bandwidth_timestamp_;
50 }
51
52 bool EstimateRecordedDuringSlowStart() const {
53 DCHECK(has_estimate_);
54 return bandwidth_estimate_recorded_during_slow_start_;
55 }
56
57 private:
58 // True if we have been able to calculate sustained bandwidth, over at least
59 // one recording period (3 * rtt).
60 bool has_estimate_;
61
62 // True if the last call to RecordEstimate had a reliable estimate.
63 bool is_recording_;
64
65 // True if the current sustained bandwidth estimate was generated while in
66 // slow start.
67 bool bandwidth_estimate_recorded_during_slow_start_;
68
69 // The latest sustained bandwidth estimate.
70 QuicBandwidth bandwidth_estimate_;
71
72 // The maximum sustained bandwidth seen over the lifetime of the connection.
73 QuicBandwidth max_bandwidth_estimate_;
74
75 // Timestamp indicating when the max_bandwidth_estimate_ was seen.
76 int32 max_bandwidth_timestamp_;
77
78 // Timestamp marking the beginning of the latest recording period.
79 QuicTime start_time_;
80
81 DISALLOW_COPY_AND_ASSIGN(QuicSustainedBandwidthRecorder);
82 };
83
84 } // namespace net
85
86 #endif // NET_QUIC_QUIC_SUSTAINED_BANDWIDTH_RECORDER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_session_test.cc ('k') | net/quic/quic_sustained_bandwidth_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698