| 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 #include "net/websockets/websocket_channel.h" | 5 #include "net/websockets/websocket_channel.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" // for size_t | 9 #include "base/basictypes.h" // for size_t |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 } | 646 } |
| 647 const WebSocketFrameHeader::OpCode opcode = frame->header.opcode; | 647 const WebSocketFrameHeader::OpCode opcode = frame->header.opcode; |
| 648 if (WebSocketFrameHeader::IsKnownControlOpCode(opcode) && | 648 if (WebSocketFrameHeader::IsKnownControlOpCode(opcode) && |
| 649 !frame->header.final) { | 649 !frame->header.final) { |
| 650 return FailChannel( | 650 return FailChannel( |
| 651 base::StringPrintf("Received fragmented control frame: opcode = %d", | 651 base::StringPrintf("Received fragmented control frame: opcode = %d", |
| 652 opcode), | 652 opcode), |
| 653 kWebSocketErrorProtocolError, | 653 kWebSocketErrorProtocolError, |
| 654 "Control message with FIN bit unset received"); | 654 "Control message with FIN bit unset received"); |
| 655 } | 655 } |
| 656 if (frame->header.reserved1 || frame->header.reserved2 || |
| 657 frame->header.reserved3) { |
| 658 return FailChannel("Received a frame with an invalid reserved bit set.", |
| 659 kWebSocketErrorProtocolError, |
| 660 "Invalid reserved bit"); |
| 661 } |
| 656 | 662 |
| 657 // Respond to the frame appropriately to its type. | 663 // Respond to the frame appropriately to its type. |
| 658 return HandleFrameByState( | 664 return HandleFrameByState( |
| 659 opcode, frame->header.final, frame->data, frame->header.payload_length); | 665 opcode, frame->header.final, frame->data, frame->header.payload_length); |
| 660 } | 666 } |
| 661 | 667 |
| 662 ChannelState WebSocketChannel::HandleFrameByState( | 668 ChannelState WebSocketChannel::HandleFrameByState( |
| 663 const WebSocketFrameHeader::OpCode opcode, | 669 const WebSocketFrameHeader::OpCode opcode, |
| 664 bool final, | 670 bool final, |
| 665 const scoped_refptr<IOBuffer>& data_buffer, | 671 const scoped_refptr<IOBuffer>& data_buffer, |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 942 | 948 |
| 943 void WebSocketChannel::CloseTimeout() { | 949 void WebSocketChannel::CloseTimeout() { |
| 944 stream_->Close(); | 950 stream_->Close(); |
| 945 DCHECK_NE(CLOSED, state_); | 951 DCHECK_NE(CLOSED, state_); |
| 946 state_ = CLOSED; | 952 state_ = CLOSED; |
| 947 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); | 953 AllowUnused(DoDropChannel(false, kWebSocketErrorAbnormalClosure, "")); |
| 948 // |this| has been deleted. | 954 // |this| has been deleted. |
| 949 } | 955 } |
| 950 | 956 |
| 951 } // namespace net | 957 } // namespace net |
| OLD | NEW |