X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fnet%2Fwebsockets%2Fwebsocket_channel.h;h=c5c67bf50b5412457986b805f3abaf3cf644d567;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=64cf91defeca5b150ce942aab4778d84b1e0f899;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/net/websockets/websocket_channel.h b/src/net/websockets/websocket_channel.h index 64cf91d..c5c67bf 100644 --- a/src/net/websockets/websocket_channel.h +++ b/src/net/websockets/websocket_channel.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/callback.h" #include "base/compiler_specific.h" // for WARN_UNUSED_RESULT +#include "base/i18n/streaming_utf8_validator.h" #include "base/memory/scoped_ptr.h" #include "base/memory/scoped_vector.h" #include "base/time/time.h" @@ -187,17 +188,23 @@ class NET_EXPORT WebSocketChannel { // within the ReadFrames() loop and does not need to call ReadFrames() itself. ChannelState OnReadDone(bool synchronous, int result) WARN_UNUSED_RESULT; - // Processes a single frame that has been read from the stream. - ChannelState ProcessFrame( + // Handles a single frame that the object has received enough of to process. + // May call |event_interface_| methods, send responses to the server, and + // change the value of |state_|. + // + // This method performs sanity checks on the frame that are needed regardless + // of the current state. Then, calls the HandleFrameByState() method below + // which performs the appropriate action(s) depending on the current state. + ChannelState HandleFrame( scoped_ptr frame) WARN_UNUSED_RESULT; - // Handles a frame that the object has received enough of to process. May call - // |event_interface_| methods, send responses to the server, and change the - // value of |state_|. - ChannelState HandleFrame(const WebSocketFrameHeader::OpCode opcode, - bool final, - const scoped_refptr& data_buffer, - size_t size) WARN_UNUSED_RESULT; + // Handles a single frame depending on the current state. It's used by the + // HandleFrame() method. + ChannelState HandleFrameByState( + const WebSocketFrameHeader::OpCode opcode, + bool final, + const scoped_refptr& data_buffer, + size_t size) WARN_UNUSED_RESULT; // Low-level method to send a single frame. Used for both data and control // frames. Either sends the frame immediately or buffers it to be scheduled @@ -244,7 +251,9 @@ class NET_EXPORT WebSocketChannel { // Drop this channel. // If there are pending opening handshake notifications, notify them // before dropping. - ChannelState DoDropChannel(uint16 code, const std::string& reason); + ChannelState DoDropChannel(bool was_clean, + uint16 code, + const std::string& reason); // Called if the closing handshake times out. Closes the connection and // informs the |event_interface_| if appropriate. @@ -298,8 +307,8 @@ class NET_EXPORT WebSocketChannel { // Storage for the status code and reason from the time the Close frame // arrives until the connection is closed and they are passed to // OnDropChannel(). - uint16 closing_code_; - std::string closing_reason_; + uint16 received_close_code_; + std::string received_close_reason_; // The current state of the channel. Mainly used for sanity checking, but also // used to track the close state. @@ -308,6 +317,14 @@ class NET_EXPORT WebSocketChannel { // |notification_sender_| is owned by this object. scoped_ptr notification_sender_; + // UTF-8 validator for outgoing Text messages. + base::StreamingUtf8Validator outgoing_utf8_validator_; + bool sending_text_message_; + + // UTF-8 validator for incoming Text messages. + base::StreamingUtf8Validator incoming_utf8_validator_; + bool receiving_text_message_; + DISALLOW_COPY_AND_ASSIGN(WebSocketChannel); };