- add sources.
[platform/framework/web/crosswalk.git] / src / net / quic / congestion_control / inter_arrival_probe.h
1 // Copyright (c) 2013 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 // Class that handle the initial probing phase of inter arrival congestion
6 // control.
7 #ifndef NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
8 #define NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_
9
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/net_export.h"
13 #include "net/quic/congestion_control/available_channel_estimator.h"
14 #include "net/quic/quic_bandwidth.h"
15
16 namespace net {
17
18 class NET_EXPORT_PRIVATE InterArrivalProbe {
19  public:
20   explicit InterArrivalProbe(QuicByteCount max_segment_size);
21   ~InterArrivalProbe();
22
23   void set_max_segment_size(QuicByteCount max_segment_size);
24
25   // Call every time a packet is sent to the network.
26   void OnPacketSent(QuicByteCount bytes);
27
28   // Call once for each sent packet that we receive an acknowledgement from
29   // the peer for.
30   void OnAcknowledgedPacket(QuicByteCount bytes);
31
32   // Call to get the number of bytes that can be sent as part of this probe.
33   QuicByteCount GetAvailableCongestionWindow();
34
35   // Call once for each sent packet we receive a congestion feedback from the
36   // peer for.
37   // If a peer sends both and ack and feedback for a sent packet, both
38   // OnAcknowledgedPacket and OnIncomingFeedback should be called.
39   void OnIncomingFeedback(QuicPacketSequenceNumber sequence_number,
40                           QuicByteCount bytes_sent,
41                           QuicTime time_sent,
42                           QuicTime time_received);
43
44   // Returns false as long as we are probing, available_channel_estimate is
45   // invalid during that time. When the probe is completed this function return
46   // true and available_channel_estimate contains the estimate.
47   bool GetEstimate(QuicBandwidth* available_channel_estimate);
48
49  private:
50   QuicByteCount max_segment_size_;
51   scoped_ptr<AvailableChannelEstimator> available_channel_estimator_;
52   QuicPacketSequenceNumber first_sequence_number_;
53   bool estimate_available_;
54   QuicBandwidth available_channel_estimate_;
55   QuicByteCount unacked_data_;
56
57   DISALLOW_COPY_AND_ASSIGN(InterArrivalProbe);
58 };
59
60 }  // namespace net
61 #endif  // NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_PROBE_H_