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

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

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 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_stream_sequencer_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 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 <stdint.h>
9
10 #include "base/logging.h"
11 #include "base/macros.h"
12 #include "net/quic/quic_bandwidth.h"
13 #include "net/quic/quic_time.h"
14
15 namespace net {
16
17 namespace test {
18 class QuicSustainedBandwidthRecorderPeer;
19 } // namespace test
20
21 // This class keeps track of a sustained bandwidth estimate to ultimately send
22 // to the client in a server config update message. A sustained bandwidth
23 // estimate is only marked as valid if the QuicSustainedBandwidthRecorder has
24 // been given uninterrupted reliable estimates over a certain period of time.
25 class NET_EXPORT_PRIVATE QuicSustainedBandwidthRecorder {
26 public:
27 QuicSustainedBandwidthRecorder();
28
29 // As long as |in_recovery| is consistently false, multiple calls to this
30 // method over a 3 * srtt period results in storage of a valid sustained
31 // bandwidth estimate.
32 // |time_now| is used as a max bandwidth timestamp if needed.
33 void RecordEstimate(bool in_recovery,
34 bool in_slow_start,
35 QuicBandwidth bandwidth,
36 QuicTime estimate_time,
37 QuicWallTime wall_time,
38 QuicTime::Delta srtt);
39
40 bool HasEstimate() const { return has_estimate_; }
41
42 QuicBandwidth BandwidthEstimate() const {
43 DCHECK(has_estimate_);
44 return bandwidth_estimate_;
45 }
46
47 QuicBandwidth MaxBandwidthEstimate() const {
48 DCHECK(has_estimate_);
49 return max_bandwidth_estimate_;
50 }
51
52 int64_t MaxBandwidthTimestamp() const {
53 DCHECK(has_estimate_);
54 return max_bandwidth_timestamp_;
55 }
56
57 bool EstimateRecordedDuringSlowStart() const {
58 DCHECK(has_estimate_);
59 return bandwidth_estimate_recorded_during_slow_start_;
60 }
61
62 private:
63 friend class test::QuicSustainedBandwidthRecorderPeer;
64
65 // True if we have been able to calculate sustained bandwidth, over at least
66 // one recording period (3 * rtt).
67 bool has_estimate_;
68
69 // True if the last call to RecordEstimate had a reliable estimate.
70 bool is_recording_;
71
72 // True if the current sustained bandwidth estimate was generated while in
73 // slow start.
74 bool bandwidth_estimate_recorded_during_slow_start_;
75
76 // The latest sustained bandwidth estimate.
77 QuicBandwidth bandwidth_estimate_;
78
79 // The maximum sustained bandwidth seen over the lifetime of the connection.
80 QuicBandwidth max_bandwidth_estimate_;
81
82 // Timestamp indicating when the max_bandwidth_estimate_ was seen.
83 int64_t max_bandwidth_timestamp_;
84
85 // Timestamp marking the beginning of the latest recording period.
86 QuicTime start_time_;
87
88 DISALLOW_COPY_AND_ASSIGN(QuicSustainedBandwidthRecorder);
89 };
90
91 } // namespace net
92
93 #endif // NET_QUIC_QUIC_SUSTAINED_BANDWIDTH_RECORDER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_stream_sequencer_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