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

Side by Side Diff: webrtc/api/quicdatachannel.h

Issue 2089553002: Refactoring on QUIC (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Split the CL Created 4 years, 5 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 | « no previous file | webrtc/api/quicdatachannel.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 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // Message stores buffered data from the incoming QUIC stream. The QUIC stream 81 // Message stores buffered data from the incoming QUIC stream. The QUIC stream
82 // is provided so that remaining data can be received from the remote peer. 82 // is provided so that remaining data can be received from the remote peer.
83 struct Message { 83 struct Message {
84 uint64_t id; 84 uint64_t id;
85 rtc::CopyOnWriteBuffer buffer; 85 rtc::CopyOnWriteBuffer buffer;
86 cricket::ReliableQuicStream* stream; 86 cricket::ReliableQuicStream* stream;
87 }; 87 };
88 88
89 QuicDataChannel(rtc::Thread* signaling_thread, 89 QuicDataChannel(rtc::Thread* signaling_thread,
90 rtc::Thread* worker_thread, 90 rtc::Thread* worker_thread,
91 rtc::Thread* network_thread,
91 const std::string& label, 92 const std::string& label,
92 const DataChannelInit& config); 93 const DataChannelInit& config);
93 ~QuicDataChannel() override; 94 ~QuicDataChannel() override;
94 95
95 // DataChannelInterface overrides. 96 // DataChannelInterface overrides.
96 std::string label() const override { return label_; } 97 std::string label() const override { return label_; }
97 bool reliable() const override { return true; } 98 bool reliable() const override { return true; }
98 bool ordered() const override { return false; } 99 bool ordered() const override { return false; }
99 uint16_t maxRetransmitTime() const override { return -1; } 100 uint16_t maxRetransmitTime() const override { return -1; }
100 uint16_t maxRetransmits() const override { return -1; } 101 uint16_t maxRetransmits() const override { return -1; }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 void OnIncomingQueuedStreamClosed(net::QuicStreamId stream_id, int error); 149 void OnIncomingQueuedStreamClosed(net::QuicStreamId stream_id, int error);
149 // Called when a write blocked QUIC stream in |write_blocked_quic_streams_| 150 // Called when a write blocked QUIC stream in |write_blocked_quic_streams_|
150 // has written previously queued data. 151 // has written previously queued data.
151 void OnQueuedBytesWritten(net::QuicStreamId stream_id, 152 void OnQueuedBytesWritten(net::QuicStreamId stream_id,
152 uint64_t queued_bytes_written); 153 uint64_t queued_bytes_written);
153 154
154 // Callbacks from |quic_transport_channel_|. 155 // Callbacks from |quic_transport_channel_|.
155 void OnReadyToSend(cricket::TransportChannel* channel); 156 void OnReadyToSend(cricket::TransportChannel* channel);
156 void OnConnectionClosed(); 157 void OnConnectionClosed();
157 158
158 // Worker thread methods. 159 // Network thread methods.
159 // Sends the data buffer to the remote peer using an outgoing QUIC stream. 160 // Sends the data buffer to the remote peer using an outgoing QUIC stream.
160 // Returns true if the data buffer can be successfully sent, or if it is 161 // Returns true if the data buffer can be successfully sent, or if it is
161 // queued to be sent later. 162 // queued to be sent later.
162 bool Send_w(const DataBuffer& buffer); 163 bool Send_n(const DataBuffer& buffer);
164
165 // Worker thread methods.
163 // Connects the |quic_transport_channel_| signals to this QuicDataChannel, 166 // Connects the |quic_transport_channel_| signals to this QuicDataChannel,
164 // then returns the new QuicDataChannel state. 167 // then returns the new QuicDataChannel state.
165 DataState SetTransportChannel_w(); 168 DataState SetTransportChannel_w();
166 // Closes the QUIC streams associated with this QuicDataChannel. 169 // Closes the QUIC streams associated with this QuicDataChannel.
167 void Close_w(); 170 void Close_w();
168 // Sets |buffered_amount_|. 171 // Sets |buffered_amount_|.
169 void SetBufferedAmount_w(uint64_t buffered_amount); 172 void SetBufferedAmount_w(uint64_t buffered_amount);
170 173
171 // Signaling thread methods. 174 // Signaling thread methods.
172 // Triggers QuicDataChannelObserver::OnMessage when a message from the remote 175 // Triggers QuicDataChannelObserver::OnMessage when a message from the remote
173 // peer is ready to be read. 176 // peer is ready to be read.
174 void OnMessage_s(const DataBuffer& received_data); 177 void OnMessage_s(const DataBuffer& received_data);
175 // Triggers QuicDataChannel::OnStateChange if the state change is valid. 178 // Triggers QuicDataChannel::OnStateChange if the state change is valid.
176 // Otherwise does nothing if |state| == |state_| or |state| != kClosed when 179 // Otherwise does nothing if |state| == |state_| or |state| != kClosed when
177 // the data channel is closing. 180 // the data channel is closing.
178 void SetState_s(DataState state); 181 void SetState_s(DataState state);
179 // Triggers QuicDataChannelObserver::OnBufferedAmountChange when the total 182 // Triggers QuicDataChannelObserver::OnBufferedAmountChange when the total
180 // buffered data changes for a QUIC stream. 183 // buffered data changes for a QUIC stream.
181 void OnBufferedAmountChange_s(uint64_t buffered_amount); 184 void OnBufferedAmountChange_s(uint64_t buffered_amount);
182 185
183 // QUIC transport channel which owns the QUIC session. It is used to create 186 // QUIC transport channel which owns the QUIC session. It is used to create
184 // a QUIC stream for sending outgoing messages. 187 // a QUIC stream for sending outgoing messages.
185 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr; 188 cricket::QuicTransportChannel* quic_transport_channel_ = nullptr;
186 // Signaling thread for DataChannelInterface methods. 189 // Signaling thread for DataChannelInterface methods.
187 rtc::Thread* const signaling_thread_; 190 rtc::Thread* const signaling_thread_;
188 // Worker thread for sending data and |quic_transport_channel_| callbacks. 191 // Worker thread for |quic_transport_channel_| callbacks.
189 rtc::Thread* const worker_thread_; 192 rtc::Thread* const worker_thread_;
193 // Network thread for sending data and |quic_transport_channel_| callbacks.
194 rtc::Thread* const network_thread_;
190 rtc::AsyncInvoker invoker_; 195 rtc::AsyncInvoker invoker_;
191 // Map of QUIC stream ID => ReliableQuicStream* for write blocked QUIC 196 // Map of QUIC stream ID => ReliableQuicStream* for write blocked QUIC
192 // streams. 197 // streams.
193 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*> 198 std::unordered_map<net::QuicStreamId, cricket::ReliableQuicStream*>
194 write_blocked_quic_streams_; 199 write_blocked_quic_streams_;
195 // Map of QUIC stream ID => Message for each incoming QUIC stream. 200 // Map of QUIC stream ID => Message for each incoming QUIC stream.
196 std::unordered_map<net::QuicStreamId, Message> incoming_quic_messages_; 201 std::unordered_map<net::QuicStreamId, Message> incoming_quic_messages_;
197 // Handles received data from the remote peer and data channel state changes. 202 // Handles received data from the remote peer and data channel state changes.
198 DataChannelObserver* observer_ = nullptr; 203 DataChannelObserver* observer_ = nullptr;
199 // QuicDataChannel ID. 204 // QuicDataChannel ID.
200 int id_; 205 int id_;
201 // Connectivity state of the QuicDataChannel. 206 // Connectivity state of the QuicDataChannel.
202 DataState state_; 207 DataState state_;
203 // Total bytes that are buffered among the QUIC streams. 208 // Total bytes that are buffered among the QUIC streams.
204 uint64_t buffered_amount_; 209 uint64_t buffered_amount_;
205 // Counter for number of sent messages that is used for message IDs. 210 // Counter for number of sent messages that is used for message IDs.
206 uint64_t next_message_id_; 211 uint64_t next_message_id_;
207 212
208 // Variables for application use. 213 // Variables for application use.
209 const std::string& label_; 214 const std::string& label_;
210 const std::string& protocol_; 215 const std::string& protocol_;
211 }; 216 };
212 217
213 } // namespace webrtc 218 } // namespace webrtc
214 219
215 #endif // WEBRTC_API_QUICDATACHANNEL_H_ 220 #endif // WEBRTC_API_QUICDATACHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/api/quicdatachannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698