OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 5 #ifndef NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 6 #define NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 | 180 |
181 // Calls WebSocketStream::ReadFrames() with the appropriate arguments. | 181 // Calls WebSocketStream::ReadFrames() with the appropriate arguments. |
182 ChannelState ReadFrames() WARN_UNUSED_RESULT; | 182 ChannelState ReadFrames() WARN_UNUSED_RESULT; |
183 | 183 |
184 // Callback from WebSocketStream::ReadFrames. Handles any errors and processes | 184 // Callback from WebSocketStream::ReadFrames. Handles any errors and processes |
185 // the returned chunks appropriately to their type. |result| is a net error | 185 // the returned chunks appropriately to their type. |result| is a net error |
186 // code. If |synchronous| is true, then OnReadDone() is being called from | 186 // code. If |synchronous| is true, then OnReadDone() is being called from |
187 // within the ReadFrames() loop and does not need to call ReadFrames() itself. | 187 // within the ReadFrames() loop and does not need to call ReadFrames() itself. |
188 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; | 188 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; |
189 | 189 |
190 // Processes a single frame that has been read from the stream. | 190 // Handles a single frame that the object has received enough of to process. |
191 ChannelState ProcessFrame( | 191 // May call |event_interface_| methods, send responses to the server, and |
192 // change the value of |state_|. | |
193 // | |
194 // The top half of this method validates the masked bit and consistency | |
195 // between FIN bit and opcode. The bottom half is implemented by the | |
196 // HandleFrameBottomHalf() method below. | |
197 ChannelState HandleFrame( | |
192 scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT; | 198 scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT; |
193 | 199 |
194 // Handles a frame that the object has received enough of to process. May call | 200 // Implements bottom half of HandleFrame() method. |
195 // |event_interface_| methods, send responses to the server, and change the | 201 ChannelState HandleFrameBottomHalf( |
Adam Rice
2014/02/10 12:00:28
"BottomHalf" implies that it's just an arbitrary s
tyoshino (SeeGerritForStatus)
2014/02/12 02:31:25
Oh, got it!
| |
196 // value of |state_|. | 202 const WebSocketFrameHeader::OpCode opcode, |
197 ChannelState HandleFrame(const WebSocketFrameHeader::OpCode opcode, | 203 bool final, |
198 bool final, | 204 const scoped_refptr<IOBuffer>& data_buffer, |
199 const scoped_refptr<IOBuffer>& data_buffer, | 205 size_t size) WARN_UNUSED_RESULT; |
200 size_t size) WARN_UNUSED_RESULT; | |
201 | 206 |
202 // Low-level method to send a single frame. Used for both data and control | 207 // Low-level method to send a single frame. Used for both data and control |
203 // frames. Either sends the frame immediately or buffers it to be scheduled | 208 // frames. Either sends the frame immediately or buffers it to be scheduled |
204 // when the current write finishes. |fin| and |op_code| are defined as for | 209 // when the current write finishes. |fin| and |op_code| are defined as for |
205 // SendFrame() above, except that |op_code| may also be a control frame | 210 // SendFrame() above, except that |op_code| may also be a control frame |
206 // opcode. | 211 // opcode. |
207 ChannelState SendIOBuffer(bool fin, | 212 ChannelState SendIOBuffer(bool fin, |
208 WebSocketFrameHeader::OpCode op_code, | 213 WebSocketFrameHeader::OpCode op_code, |
209 const scoped_refptr<IOBuffer>& buffer, | 214 const scoped_refptr<IOBuffer>& buffer, |
210 size_t size) WARN_UNUSED_RESULT; | 215 size_t size) WARN_UNUSED_RESULT; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 | 296 |
292 // Timer for the closing handshake. | 297 // Timer for the closing handshake. |
293 base::OneShotTimer<WebSocketChannel> timer_; | 298 base::OneShotTimer<WebSocketChannel> timer_; |
294 | 299 |
295 // Timeout for the closing handshake. | 300 // Timeout for the closing handshake. |
296 base::TimeDelta timeout_; | 301 base::TimeDelta timeout_; |
297 | 302 |
298 // Storage for the status code and reason from the time the Close frame | 303 // Storage for the status code and reason from the time the Close frame |
299 // arrives until the connection is closed and they are passed to | 304 // arrives until the connection is closed and they are passed to |
300 // OnDropChannel(). | 305 // OnDropChannel(). |
301 uint16 closing_code_; | 306 uint16 received_close_code_; |
Adam Rice
2014/02/10 12:00:28
This rename is good.
| |
302 std::string closing_reason_; | 307 std::string received_close_reason_; |
303 | 308 |
304 // The current state of the channel. Mainly used for sanity checking, but also | 309 // The current state of the channel. Mainly used for sanity checking, but also |
305 // used to track the close state. | 310 // used to track the close state. |
306 State state_; | 311 State state_; |
307 | 312 |
308 // |notification_sender_| is owned by this object. | 313 // |notification_sender_| is owned by this object. |
309 scoped_ptr<HandshakeNotificationSender> notification_sender_; | 314 scoped_ptr<HandshakeNotificationSender> notification_sender_; |
310 | 315 |
311 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); | 316 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); |
312 }; | 317 }; |
313 | 318 |
314 } // namespace net | 319 } // namespace net |
315 | 320 |
316 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 321 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
OLD | NEW |