OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/api/cast_channel/cast_framer.h" | 5 #include "extensions/browser/api/cast_channel/cast_framer.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 DCHECK_EQ(base::checked_cast<int32_t>(message_bytes_received_), | 126 DCHECK_EQ(base::checked_cast<int32_t>(message_bytes_received_), |
127 input_buffer_->offset()); | 127 input_buffer_->offset()); |
128 CHECK_LE(num_bytes, BytesRequested()); | 128 CHECK_LE(num_bytes, BytesRequested()); |
129 message_bytes_received_ += num_bytes; | 129 message_bytes_received_ += num_bytes; |
130 *error = CHANNEL_ERROR_NONE; | 130 *error = CHANNEL_ERROR_NONE; |
131 *message_length = 0; | 131 *message_length = 0; |
132 switch (current_element_) { | 132 switch (current_element_) { |
133 case HEADER: | 133 case HEADER: |
134 if (BytesRequested() == 0) { | 134 if (BytesRequested() == 0) { |
135 MessageHeader header; | 135 MessageHeader header; |
136 MessageHeader::Deserialize(input_buffer_.get()->StartOfBuffer(), | 136 MessageHeader::Deserialize(input_buffer_->StartOfBuffer(), &header); |
137 &header); | |
138 if (header.message_size > MessageHeader::max_message_size()) { | 137 if (header.message_size > MessageHeader::max_message_size()) { |
139 VLOG(1) << "Error parsing header (message size too large)."; | 138 VLOG(1) << "Error parsing header (message size too large)."; |
140 *error = CHANNEL_ERROR_INVALID_MESSAGE; | 139 *error = CHANNEL_ERROR_INVALID_MESSAGE; |
141 error_ = true; | 140 error_ = true; |
142 return nullptr; | 141 return nullptr; |
143 } | 142 } |
144 current_element_ = BODY; | 143 current_element_ = BODY; |
145 body_size_ = header.message_size; | 144 body_size_ = header.message_size; |
146 } | 145 } |
147 break; | 146 break; |
(...skipping 25 matching lines...) Expand all Loading... |
173 void MessageFramer::Reset() { | 172 void MessageFramer::Reset() { |
174 current_element_ = HEADER; | 173 current_element_ = HEADER; |
175 message_bytes_received_ = 0; | 174 message_bytes_received_ = 0; |
176 body_size_ = 0; | 175 body_size_ = 0; |
177 input_buffer_->set_offset(0); | 176 input_buffer_->set_offset(0); |
178 } | 177 } |
179 | 178 |
180 } // namespace cast_channel | 179 } // namespace cast_channel |
181 } // namespace api | 180 } // namespace api |
182 } // namespace extensions | 181 } // namespace extensions |
OLD | NEW |