| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef NET_QUIC_QUIC_FLOW_CONTROLLER_H_ | 5 #ifndef NET_QUIC_QUIC_FLOW_CONTROLLER_H_ |
| 6 #define NET_QUIC_QUIC_FLOW_CONTROLLER_H_ | 6 #define NET_QUIC_QUIC_FLOW_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
| 10 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 class NET_EXPORT_PRIVATE QuicFlowController { | 26 class NET_EXPORT_PRIVATE QuicFlowController { |
| 27 public: | 27 public: |
| 28 QuicFlowController(QuicVersion version, | 28 QuicFlowController(QuicVersion version, |
| 29 QuicStreamId id, | 29 QuicStreamId id, |
| 30 bool is_server, | 30 bool is_server, |
| 31 uint64 send_window_offset, | 31 uint64 send_window_offset, |
| 32 uint64 receive_window_offset, | 32 uint64 receive_window_offset, |
| 33 uint64 max_receive_window); | 33 uint64 max_receive_window); |
| 34 ~QuicFlowController() {} | 34 ~QuicFlowController() {} |
| 35 | 35 |
| 36 // Called when bytes are received from the peer, and buffered. | 36 // Called when we see a new highest received byte offset from the peer, either |
| 37 void AddBytesBuffered(uint64 bytes_buffered); | 37 // via a data frame or a RST. |
| 38 | 38 // Returns true if this call changes highest_received_byte_offset_, and false |
| 39 // Called when bytes currently buffered locally, are removed from the buffer. | 39 // in the case where |new_offset| is <= highest_received_byte_offset_. |
| 40 void RemoveBytesBuffered(uint64 bytes_buffered); | 40 bool UpdateHighestReceivedOffset(uint64 new_offset); |
| 41 | 41 |
| 42 // Called when bytes received from the peer are consumed locally. | 42 // Called when bytes received from the peer are consumed locally. |
| 43 void AddBytesConsumed(uint64 bytes_consumed); | 43 void AddBytesConsumed(uint64 bytes_consumed); |
| 44 | 44 |
| 45 // Called when bytes are sent to the peer. | 45 // Called when bytes are sent to the peer. |
| 46 void AddBytesSent(uint64 bytes_sent); | 46 void AddBytesSent(uint64 bytes_sent); |
| 47 | 47 |
| 48 // Set a new send window offset. | 48 // Set a new send window offset. |
| 49 // Returns true if this changes send_window_offset_, and false in the case | 49 // Returns true if this changes send_window_offset_, and false in the case |
| 50 // where |new_send_window| is <= send_window_offset_. | 50 // where |new_send_window| is <= send_window_offset_. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 | 64 |
| 65 // Returns true if flow control is enabled. | 65 // Returns true if flow control is enabled. |
| 66 bool IsEnabled() const; | 66 bool IsEnabled() const; |
| 67 | 67 |
| 68 // Returns true if flow control send limits have been reached. | 68 // Returns true if flow control send limits have been reached. |
| 69 bool IsBlocked() const; | 69 bool IsBlocked() const; |
| 70 | 70 |
| 71 // Returns true if flow control receive limits have been violated by the peer. | 71 // Returns true if flow control receive limits have been violated by the peer. |
| 72 bool FlowControlViolation(); | 72 bool FlowControlViolation(); |
| 73 | 73 |
| 74 uint64 highest_received_byte_offset() const { |
| 75 return highest_received_byte_offset_; |
| 76 } |
| 77 |
| 74 private: | 78 private: |
| 75 friend class test::QuicFlowControllerPeer; | 79 friend class test::QuicFlowControllerPeer; |
| 76 | 80 |
| 77 // Total received bytes is the sum of bytes buffered, and bytes consumed. | |
| 78 uint64 TotalReceivedBytes() const; | |
| 79 | |
| 80 // ID of stream this flow controller belongs to. This can be 0 if this is a | 81 // ID of stream this flow controller belongs to. This can be 0 if this is a |
| 81 // connection level flow controller. | 82 // connection level flow controller. |
| 82 QuicStreamId id_; | 83 QuicStreamId id_; |
| 83 | 84 |
| 84 // True if flow control is enabled. | 85 // True if flow control is enabled. |
| 85 bool is_enabled_; | 86 bool is_enabled_; |
| 86 | 87 |
| 87 // True if this is owned by a server. | 88 // True if this is owned by a server. |
| 88 bool is_server_; | 89 bool is_server_; |
| 89 | 90 |
| 90 // Track number of bytes received from the peer, which have been consumed | 91 // Track number of bytes received from the peer, which have been consumed |
| 91 // locally. | 92 // locally. |
| 92 uint64 bytes_consumed_; | 93 uint64 bytes_consumed_; |
| 93 | 94 |
| 94 // Tracks number of bytes received from the peer, and buffered locally. | 95 // The highest byte offset we have seen from the peer. This could be the |
| 95 uint64 bytes_buffered_; | 96 // highest offset in a data frame, or a final value in a RST. |
| 97 uint64 highest_received_byte_offset_; |
| 96 | 98 |
| 97 // Tracks number of bytes sent to the peer. | 99 // Tracks number of bytes sent to the peer. |
| 98 uint64 bytes_sent_; | 100 uint64 bytes_sent_; |
| 99 | 101 |
| 100 // The absolute offset in the outgoing byte stream. If this offset is reached | 102 // The absolute offset in the outgoing byte stream. If this offset is reached |
| 101 // then we become flow control blocked until we receive a WINDOW_UPDATE. | 103 // then we become flow control blocked until we receive a WINDOW_UPDATE. |
| 102 uint64 send_window_offset_; | 104 uint64 send_window_offset_; |
| 103 | 105 |
| 104 // The absolute offset in the incoming byte stream. The peer should never send | 106 // The absolute offset in the incoming byte stream. The peer should never send |
| 105 // us bytes which are beyond this offset. | 107 // us bytes which are beyond this offset. |
| 106 uint64 receive_window_offset_; | 108 uint64 receive_window_offset_; |
| 107 | 109 |
| 108 // Largest size the receive window can grow to. | 110 // Largest size the receive window can grow to. |
| 109 uint64 max_receive_window_; | 111 uint64 max_receive_window_; |
| 110 | 112 |
| 111 // Keep track of the last time we sent a BLOCKED frame. We should only send | 113 // Keep track of the last time we sent a BLOCKED frame. We should only send |
| 112 // another when the number of bytes we have sent has changed. | 114 // another when the number of bytes we have sent has changed. |
| 113 uint64 last_blocked_send_window_offset_; | 115 uint64 last_blocked_send_window_offset_; |
| 114 | 116 |
| 115 DISALLOW_COPY_AND_ASSIGN(QuicFlowController); | 117 DISALLOW_COPY_AND_ASSIGN(QuicFlowController); |
| 116 }; | 118 }; |
| 117 | 119 |
| 118 } // namespace net | 120 } // namespace net |
| 119 | 121 |
| 120 #endif // NET_QUIC_QUIC_FLOW_CONTROLLER_H_ | 122 #endif // NET_QUIC_QUIC_FLOW_CONTROLLER_H_ |
| OLD | NEW |