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

Side by Side Diff: net/websockets/websocket_channel.h

Issue 131333010: Rename closing_* in WebSocketChannel to received_close_ and do some refactoring (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/websockets/websocket_channel.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 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 // Calls WebSocketStream::ReadFrames() with the appropriate arguments. 182 // Calls WebSocketStream::ReadFrames() with the appropriate arguments.
183 ChannelState ReadFrames() WARN_UNUSED_RESULT; 183 ChannelState ReadFrames() WARN_UNUSED_RESULT;
184 184
185 // Callback from WebSocketStream::ReadFrames. Handles any errors and processes 185 // Callback from WebSocketStream::ReadFrames. Handles any errors and processes
186 // the returned chunks appropriately to their type. |result| is a net error 186 // the returned chunks appropriately to their type. |result| is a net error
187 // code. If |synchronous| is true, then OnReadDone() is being called from 187 // code. If |synchronous| is true, then OnReadDone() is being called from
188 // within the ReadFrames() loop and does not need to call ReadFrames() itself. 188 // within the ReadFrames() loop and does not need to call ReadFrames() itself.
189 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; 189 ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT;
190 190
191 // Processes a single frame that has been read from the stream. 191 // Handles a single frame that the object has received enough of to process.
192 ChannelState ProcessFrame( 192 // May call |event_interface_| methods, send responses to the server, and
193 // change the value of |state_|.
194 //
195 // This method performs sanity checks on the frame that are needed regardless
196 // of the current state. Then, calls the HandleFrameByState() method below
197 // which performs the appropriate action(s) depending on the current state.
198 ChannelState HandleFrame(
193 scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT; 199 scoped_ptr<WebSocketFrame> frame) WARN_UNUSED_RESULT;
194 200
195 // Handles a frame that the object has received enough of to process. May call 201 // Handles a single frame depending on the current state. It's used by the
196 // |event_interface_| methods, send responses to the server, and change the 202 // HandleFrame() method.
197 // value of |state_|. 203 ChannelState HandleFrameByState(
198 ChannelState HandleFrame(const WebSocketFrameHeader::OpCode opcode, 204 const WebSocketFrameHeader::OpCode opcode,
199 bool final, 205 bool final,
200 const scoped_refptr<IOBuffer>& data_buffer, 206 const scoped_refptr<IOBuffer>& data_buffer,
201 size_t size) WARN_UNUSED_RESULT; 207 size_t size) WARN_UNUSED_RESULT;
202 208
203 // Low-level method to send a single frame. Used for both data and control 209 // Low-level method to send a single frame. Used for both data and control
204 // frames. Either sends the frame immediately or buffers it to be scheduled 210 // frames. Either sends the frame immediately or buffers it to be scheduled
205 // when the current write finishes. |fin| and |op_code| are defined as for 211 // when the current write finishes. |fin| and |op_code| are defined as for
206 // SendFrame() above, except that |op_code| may also be a control frame 212 // SendFrame() above, except that |op_code| may also be a control frame
207 // opcode. 213 // opcode.
208 ChannelState SendIOBuffer(bool fin, 214 ChannelState SendIOBuffer(bool fin,
209 WebSocketFrameHeader::OpCode op_code, 215 WebSocketFrameHeader::OpCode op_code,
210 const scoped_refptr<IOBuffer>& buffer, 216 const scoped_refptr<IOBuffer>& buffer,
211 size_t size) WARN_UNUSED_RESULT; 217 size_t size) WARN_UNUSED_RESULT;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 300
295 // Timer for the closing handshake. 301 // Timer for the closing handshake.
296 base::OneShotTimer<WebSocketChannel> timer_; 302 base::OneShotTimer<WebSocketChannel> timer_;
297 303
298 // Timeout for the closing handshake. 304 // Timeout for the closing handshake.
299 base::TimeDelta timeout_; 305 base::TimeDelta timeout_;
300 306
301 // Storage for the status code and reason from the time the Close frame 307 // Storage for the status code and reason from the time the Close frame
302 // arrives until the connection is closed and they are passed to 308 // arrives until the connection is closed and they are passed to
303 // OnDropChannel(). 309 // OnDropChannel().
304 uint16 closing_code_; 310 uint16 received_close_code_;
305 std::string closing_reason_; 311 std::string received_close_reason_;
306 312
307 // The current state of the channel. Mainly used for sanity checking, but also 313 // The current state of the channel. Mainly used for sanity checking, but also
308 // used to track the close state. 314 // used to track the close state.
309 State state_; 315 State state_;
310 316
311 // |notification_sender_| is owned by this object. 317 // |notification_sender_| is owned by this object.
312 scoped_ptr<HandshakeNotificationSender> notification_sender_; 318 scoped_ptr<HandshakeNotificationSender> notification_sender_;
313 319
314 // UTF-8 validator for outgoing Text messages. 320 // UTF-8 validator for outgoing Text messages.
315 base::StreamingUtf8Validator outgoing_utf8_validator_; 321 base::StreamingUtf8Validator outgoing_utf8_validator_;
316 bool sending_text_message_; 322 bool sending_text_message_;
317 323
318 // UTF-8 validator for incoming Text messages. 324 // UTF-8 validator for incoming Text messages.
319 base::StreamingUtf8Validator incoming_utf8_validator_; 325 base::StreamingUtf8Validator incoming_utf8_validator_;
320 bool receiving_text_message_; 326 bool receiving_text_message_;
321 327
322 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); 328 DISALLOW_COPY_AND_ASSIGN(WebSocketChannel);
323 }; 329 };
324 330
325 } // namespace net 331 } // namespace net
326 332
327 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_ 333 #endif // NET_WEBSOCKETS_WEBSOCKET_CHANNEL_H_
OLDNEW
« no previous file with comments | « no previous file | net/websockets/websocket_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698