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 <queue> | 8 #include <queue> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // within the ReadFrames() loop and does not need to call ReadFrames() itself. | 234 // within the ReadFrames() loop and does not need to call ReadFrames() itself. |
235 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; | 235 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; |
236 | 236 |
237 // Handles a single frame that the object has received enough of to process. | 237 // Handles a single frame that the object has received enough of to process. |
238 // May call |event_interface_| methods, send responses to the server, and | 238 // May call |event_interface_| methods, send responses to the server, and |
239 // change the value of |state_|. | 239 // change the value of |state_|. |
240 // | 240 // |
241 // This method performs sanity checks on the frame that are needed regardless | 241 // This method performs sanity checks on the frame that are needed regardless |
242 // of the current state. Then, calls the HandleFrameByState() method below | 242 // of the current state. Then, calls the HandleFrameByState() method below |
243 // which performs the appropriate action(s) depending on the current state. | 243 // which performs the appropriate action(s) depending on the current state. |
244 ChannelState HandleFrame( | 244 ChannelState HandleFrame(scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT; |
245 scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT; | |
246 | 245 |
247 // Handles a single frame depending on the current state. It's used by the | 246 // Handles a single frame depending on the current state. It's used by the |
248 // HandleFrame() method. | 247 // HandleFrame() method. |
249 ChannelState HandleFrameByState( | 248 ChannelState HandleFrameByState(const WebSocketFrameHeader::OpCode opcode, |
250 const WebSocketFrameHeader::OpCode opcode, | 249 bool final, |
251 bool final, | 250 const scoped_refptr<IOBuffer>& data_buffer, |
252 const scoped_refptr<IOBuffer>& data_buffer, | 251 size_t size) WARN_UNUSED_RESULT; |
253 size_t size) WARN_UNUSED_RESULT; | |
254 | 252 |
255 // Forward a received data frame to the renderer, if connected. If | 253 // Forward a received data frame to the renderer, if connected. If |
256 // |expecting_continuation| is not equal to |expecting_to_read_continuation_|, | 254 // |expecting_continuation| is not equal to |expecting_to_read_continuation_|, |
257 // will fail the channel. Also checks the UTF-8 validity of text frames. | 255 // will fail the channel. Also checks the UTF-8 validity of text frames. |
258 ChannelState HandleDataFrame(WebSocketFrameHeader::OpCode opcode, | 256 ChannelState HandleDataFrame(WebSocketFrameHeader::OpCode opcode, |
259 bool final, | 257 bool final, |
260 const scoped_refptr<IOBuffer>& data_buffer, | 258 const scoped_refptr<IOBuffer>& data_buffer, |
261 size_t size) WARN_UNUSED_RESULT; | 259 size_t size) WARN_UNUSED_RESULT; |
262 | 260 |
263 // Low-level method to send a single frame. Used for both data and control | 261 // Low-level method to send a single frame. Used for both data and control |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // For UMA. The time when OnConnectSuccess() method was called and |stream_| | 396 // For UMA. The time when OnConnectSuccess() method was called and |stream_| |
399 // was set. | 397 // was set. |
400 base::TimeTicks established_on_; | 398 base::TimeTicks established_on_; |
401 | 399 |
402 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); | 400 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); |
403 }; | 401 }; |
404 | 402 |
405 } // namespace net | 403 } // namespace net |
406 | 404 |
407 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ | 405 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ |
OLD | NEW |