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

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

Issue 761903003: Update from https://crrev.com/306655 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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_flags.cc ('k') | net/quic/quic_flow_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 21
22 // QuicFlowController allows a QUIC stream or connection to perform flow 22 // QuicFlowController allows a QUIC stream or connection to perform flow
23 // control. The stream/connection owns a QuicFlowController which keeps track of 23 // control. The stream/connection owns a QuicFlowController which keeps track of
24 // bytes sent/received, can tell the owner if it is flow control blocked, and 24 // bytes sent/received, can tell the owner if it is flow control blocked, and
25 // can send WINDOW_UPDATE or BLOCKED frames when needed. 25 // can send WINDOW_UPDATE or BLOCKED frames when needed.
26 class NET_EXPORT_PRIVATE QuicFlowController { 26 class NET_EXPORT_PRIVATE QuicFlowController {
27 public: 27 public:
28 QuicFlowController(QuicConnection* connection, 28 QuicFlowController(QuicConnection* connection,
29 QuicStreamId id, 29 QuicStreamId id,
30 bool is_server, 30 bool is_server,
31 uint64 send_window_offset, 31 QuicStreamOffset send_window_offset,
32 uint64 receive_window_offset, 32 QuicStreamOffset receive_window_offset,
33 uint64 max_receive_window); 33 QuicByteCount max_receive_window);
34 ~QuicFlowController() {} 34 ~QuicFlowController() {}
35 35
36 // Called when we see a new highest received byte offset from the peer, either 36 // Called when we see a new highest received byte offset from the peer, either
37 // via a data frame or a RST. 37 // via a data frame or a RST.
38 // Returns true if this call changes highest_received_byte_offset_, and false 38 // Returns true if this call changes highest_received_byte_offset_, and false
39 // in the case where |new_offset| is <= highest_received_byte_offset_. 39 // in the case where |new_offset| is <= highest_received_byte_offset_.
40 bool UpdateHighestReceivedOffset(uint64 new_offset); 40 bool UpdateHighestReceivedOffset(QuicStreamOffset new_offset);
41 41
42 // Called when bytes received from the peer are consumed locally. This may 42 // Called when bytes received from the peer are consumed locally. This may
43 // trigger the sending of a WINDOW_UPDATE frame using |connection|. 43 // trigger the sending of a WINDOW_UPDATE frame using |connection|.
44 void AddBytesConsumed(uint64 bytes_consumed); 44 void AddBytesConsumed(QuicByteCount bytes_consumed);
45 45
46 // Called when bytes are sent to the peer. 46 // Called when bytes are sent to the peer.
47 void AddBytesSent(uint64 bytes_sent); 47 void AddBytesSent(QuicByteCount bytes_sent);
48 48
49 // Set a new send window offset. 49 // Set a new send window offset.
50 // Returns true if this increases send_window_offset_ and is now blocked. 50 // Returns true if this increases send_window_offset_ and is now blocked.
51 bool UpdateSendWindowOffset(uint64 new_send_window_offset); 51 bool UpdateSendWindowOffset(QuicStreamOffset new_send_window_offset);
52 52
53 // Returns the current available send window. 53 // Returns the current available send window.
54 uint64 SendWindowSize() const; 54 QuicByteCount SendWindowSize() const;
55 55
56 // Send a BLOCKED frame if appropriate. 56 // Send a BLOCKED frame if appropriate.
57 void MaybeSendBlocked(); 57 void MaybeSendBlocked();
58 58
59 // Disable flow control. 59 // Disable flow control.
60 void Disable(); 60 void Disable();
61 61
62 // Returns true if flow control is enabled. 62 // Returns true if flow control is enabled.
63 bool IsEnabled() const; 63 bool IsEnabled() const;
64 64
65 // Returns true if flow control send limits have been reached. 65 // Returns true if flow control send limits have been reached.
66 bool IsBlocked() const; 66 bool IsBlocked() const;
67 67
68 // Returns true if flow control receive limits have been violated by the peer. 68 // Returns true if flow control receive limits have been violated by the peer.
69 bool FlowControlViolation(); 69 bool FlowControlViolation();
70 70
71 uint64 bytes_consumed() const { return bytes_consumed_; } 71 QuicByteCount bytes_consumed() const { return bytes_consumed_; }
72 72
73 uint64 highest_received_byte_offset() const { 73 QuicStreamOffset highest_received_byte_offset() const {
74 return highest_received_byte_offset_; 74 return highest_received_byte_offset_;
75 } 75 }
76 76
77 private: 77 private:
78 friend class test::QuicFlowControllerPeer; 78 friend class test::QuicFlowControllerPeer;
79 79
80 // Send a WINDOW_UPDATE frame if appropriate. 80 // Send a WINDOW_UPDATE frame if appropriate.
81 void MaybeSendWindowUpdate(); 81 void MaybeSendWindowUpdate();
82 82
83 // The parent connection, used to send connection close on flow control 83 // The parent connection, used to send connection close on flow control
84 // violation, and WINDOW_UPDATE and BLOCKED frames when appropriate. 84 // violation, and WINDOW_UPDATE and BLOCKED frames when appropriate.
85 // Not owned. 85 // Not owned.
86 QuicConnection* connection_; 86 QuicConnection* connection_;
87 87
88 // ID of stream this flow controller belongs to. This can be 0 if this is a 88 // ID of stream this flow controller belongs to. This can be 0 if this is a
89 // connection level flow controller. 89 // connection level flow controller.
90 QuicStreamId id_; 90 QuicStreamId id_;
91 91
92 // True if flow control is enabled. 92 // True if flow control is enabled.
93 bool is_enabled_; 93 bool is_enabled_;
94 94
95 // True if this is owned by a server. 95 // True if this is owned by a server.
96 bool is_server_; 96 bool is_server_;
97 97
98 // Track number of bytes received from the peer, which have been consumed 98 // Track number of bytes received from the peer, which have been consumed
99 // locally. 99 // locally.
100 uint64 bytes_consumed_; 100 QuicByteCount bytes_consumed_;
101 101
102 // The highest byte offset we have seen from the peer. This could be the 102 // The highest byte offset we have seen from the peer. This could be the
103 // highest offset in a data frame, or a final value in a RST. 103 // highest offset in a data frame, or a final value in a RST.
104 uint64 highest_received_byte_offset_; 104 QuicStreamOffset highest_received_byte_offset_;
105 105
106 // Tracks number of bytes sent to the peer. 106 // Tracks number of bytes sent to the peer.
107 uint64 bytes_sent_; 107 QuicByteCount bytes_sent_;
108 108
109 // The absolute offset in the outgoing byte stream. If this offset is reached 109 // The absolute offset in the outgoing byte stream. If this offset is reached
110 // then we become flow control blocked until we receive a WINDOW_UPDATE. 110 // then we become flow control blocked until we receive a WINDOW_UPDATE.
111 uint64 send_window_offset_; 111 QuicStreamOffset send_window_offset_;
112 112
113 // The absolute offset in the incoming byte stream. The peer should never send 113 // The absolute offset in the incoming byte stream. The peer should never send
114 // us bytes which are beyond this offset. 114 // us bytes which are beyond this offset.
115 uint64 receive_window_offset_; 115 QuicStreamOffset receive_window_offset_;
116 116
117 // Largest size the receive window can grow to. 117 // Largest size the receive window can grow to.
118 uint64 max_receive_window_; 118 QuicByteCount max_receive_window_;
119 119
120 // Keep track of the last time we sent a BLOCKED frame. We should only send 120 // Keep track of the last time we sent a BLOCKED frame. We should only send
121 // another when the number of bytes we have sent has changed. 121 // another when the number of bytes we have sent has changed.
122 uint64 last_blocked_send_window_offset_; 122 QuicStreamOffset last_blocked_send_window_offset_;
123 123
124 DISALLOW_COPY_AND_ASSIGN(QuicFlowController); 124 DISALLOW_COPY_AND_ASSIGN(QuicFlowController);
125 }; 125 };
126 126
127 } // namespace net 127 } // namespace net
128 128
129 #endif // NET_QUIC_QUIC_FLOW_CONTROLLER_H_ 129 #endif // NET_QUIC_QUIC_FLOW_CONTROLLER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_flags.cc ('k') | net/quic/quic_flow_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698