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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // If frame header is incomplete, then carry over the remaining | 65 // If frame header is incomplete, then carry over the remaining |
66 // data to the next round of Decode(). | 66 // data to the next round of Decode(). |
67 if (!current_frame_header_.get()) | 67 if (!current_frame_header_.get()) |
68 break; | 68 break; |
69 first_chunk = true; | 69 first_chunk = true; |
70 } | 70 } |
71 | 71 |
72 scoped_ptr<WebSocketFrameChunk> frame_chunk = | 72 scoped_ptr<WebSocketFrameChunk> frame_chunk = |
73 DecodeFramePayload(first_chunk); | 73 DecodeFramePayload(first_chunk); |
74 DCHECK(frame_chunk.get()); | 74 DCHECK(frame_chunk.get()); |
75 frame_chunks->push_back(frame_chunk.release()); | 75 frame_chunks->push_back(frame_chunk.Pass()); |
76 | 76 |
77 if (current_frame_header_.get()) { | 77 if (current_frame_header_.get()) { |
78 DCHECK(current_read_pos_ == buffer_.size()); | 78 DCHECK(current_read_pos_ == buffer_.size()); |
79 break; | 79 break; |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 // Drain unnecessary data. TODO(yutak): Remove copy. (but how?) | 83 // Drain unnecessary data. TODO(yutak): Remove copy. (but how?) |
84 buffer_.erase(buffer_.begin(), buffer_.begin() + current_read_pos_); | 84 buffer_.erase(buffer_.begin(), buffer_.begin() + current_read_pos_); |
85 current_read_pos_ = 0; | 85 current_read_pos_ = 0; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (frame_offset_ == current_frame_header_->payload_length) { | 201 if (frame_offset_ == current_frame_header_->payload_length) { |
202 frame_chunk->final_chunk = true; | 202 frame_chunk->final_chunk = true; |
203 current_frame_header_.reset(); | 203 current_frame_header_.reset(); |
204 frame_offset_ = 0; | 204 frame_offset_ = 0; |
205 } | 205 } |
206 | 206 |
207 return frame_chunk.Pass(); | 207 return frame_chunk.Pass(); |
208 } | 208 } |
209 | 209 |
210 } // namespace net | 210 } // namespace net |
OLD | NEW |