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

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

Issue 477053002: Add a QuicSustainedBandwidthEstimator class. Not yet used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@re-add_DCHECK_to_ensure_packets_73128051
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/net.gypi ('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 QuicBandwidth bandwidth,
28 QuicTime estimate_time,
29 QuicWallTime wall_time,
30 QuicTime::Delta srtt);
31
32 bool HasEstimate() const {
33 return has_estimate_;
34 }
35
36 QuicBandwidth BandwidthEstimate() const {
37 DCHECK(has_estimate_);
38 return bandwidth_estimate_;
39 }
40
41 QuicBandwidth MaxBandwidthEstimate() const {
42 DCHECK(has_estimate_);
43 return max_bandwidth_estimate_;
44 }
45
46 int32 MaxBandwidthTimestamp() const {
ramant (doing other things) 2014/08/15 02:35:35 rjshade@: should we use int64 instead of int32?
Robbie Shade 2014/08/15 12:08:38 Yep, thanks!
ramant (doing other things) 2014/08/15 17:54:18 Great. Will submit the change to the internal sour
47 DCHECK(has_estimate_);
48 return max_bandwidth_timestamp_;
49 }
50
51 private:
52 // True if we have been able to calculate sustained bandwidth, over at least
53 // one recording period (3 * rtt).
54 bool has_estimate_;
55
56 // True if the last call to RecordEstimate had a reliable estimate.
57 bool is_recording_;
58
59 // The latest sustained bandwidth estimate.
60 QuicBandwidth bandwidth_estimate_;
61
62 // The maximum sustained bandwidth seen over the lifetime of the connection.
63 QuicBandwidth max_bandwidth_estimate_;
64
65 // Timestamp indicating when the max_bandwidth_estimate_ was seen.
66 int32 max_bandwidth_timestamp_;
67
68 // Timestamp marking the beginning of the latest recording period.
69 QuicTime start_time_;
70
71 DISALLOW_COPY_AND_ASSIGN(QuicSustainedBandwidthRecorder);
72 };
73
74 } // namespace net
75
76 #endif // NET_QUIC_QUIC_SUSTAINED_BANDWIDTH_RECORDER_H_
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/quic_sustained_bandwidth_recorder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698