OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_frame_parser.h" | 5 #include "net/websockets/websocket_frame_parser.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 WebSocketFrameParser::WebSocketFrameParser() | 36 WebSocketFrameParser::WebSocketFrameParser() |
37 : current_read_pos_(0), | 37 : current_read_pos_(0), |
38 frame_offset_(0), | 38 frame_offset_(0), |
39 websocket_error_(kWebSocketNormalClosure) { | 39 websocket_error_(kWebSocketNormalClosure) { |
40 std::fill(masking_key_.key, | 40 std::fill(masking_key_.key, |
41 masking_key_.key + WebSocketFrameHeader::kMaskingKeyLength, | 41 masking_key_.key + WebSocketFrameHeader::kMaskingKeyLength, |
42 '\0'); | 42 '\0'); |
43 } | 43 } |
44 | 44 |
45 WebSocketFrameParser::~WebSocketFrameParser() {} | 45 WebSocketFrameParser::~WebSocketFrameParser() { |
| 46 } |
46 | 47 |
47 bool WebSocketFrameParser::Decode( | 48 bool WebSocketFrameParser::Decode( |
48 const char* data, | 49 const char* data, |
49 size_t length, | 50 size_t length, |
50 ScopedVector<WebSocketFrameChunk>* frame_chunks) { | 51 ScopedVector<WebSocketFrameChunk>* frame_chunks) { |
51 if (websocket_error_ != kWebSocketNormalClosure) | 52 if (websocket_error_ != kWebSocketNormalClosure) |
52 return false; | 53 return false; |
53 if (!length) | 54 if (!length) |
54 return true; | 55 return true; |
55 | 56 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (frame_offset_ == current_frame_header_->payload_length) { | 204 if (frame_offset_ == current_frame_header_->payload_length) { |
204 frame_chunk->final_chunk = true; | 205 frame_chunk->final_chunk = true; |
205 current_frame_header_.reset(); | 206 current_frame_header_.reset(); |
206 frame_offset_ = 0; | 207 frame_offset_ = 0; |
207 } | 208 } |
208 | 209 |
209 return frame_chunk.Pass(); | 210 return frame_chunk.Pass(); |
210 } | 211 } |
211 | 212 |
212 } // namespace net | 213 } // namespace net |
OLD | NEW |