| 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/spdy/spdy_protocol.h" | 5 #include "net/spdy/spdy_protocol.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "net/spdy/spdy_bug_tracker.h" | 8 #include "net/spdy/spdy_bug_tracker.h" |
| 9 | 9 |
| 10 namespace net { | 10 namespace net { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return true; | 151 return true; |
| 152 case SETTINGS_MAX_HEADER_LIST_SIZE: | 152 case SETTINGS_MAX_HEADER_LIST_SIZE: |
| 153 *settings_id_string = "SETTINGS_MAX_HEADER_LIST_SIZE"; | 153 *settings_id_string = "SETTINGS_MAX_HEADER_LIST_SIZE"; |
| 154 return true; | 154 return true; |
| 155 } | 155 } |
| 156 | 156 |
| 157 *settings_id_string = "SETTINGS_UNKNOWN"; | 157 *settings_id_string = "SETTINGS_UNKNOWN"; |
| 158 return false; | 158 return false; |
| 159 } | 159 } |
| 160 | 160 |
| 161 SpdyRstStreamStatus ParseRstStreamStatus(int rst_stream_status_field) { | 161 SpdyErrorCode ParseErrorCode(uint32_t wire_error_code) { |
| 162 if (rst_stream_status_field < RST_STREAM_MIN || | 162 if (wire_error_code > ERROR_CODE_MAX) { |
| 163 rst_stream_status_field > RST_STREAM_MAX) { | 163 return ERROR_CODE_INTERNAL_ERROR; |
| 164 return RST_STREAM_INTERNAL_ERROR; | |
| 165 } | 164 } |
| 166 | 165 |
| 167 return static_cast<SpdyRstStreamStatus>(rst_stream_status_field); | 166 return static_cast<SpdyErrorCode>(wire_error_code); |
| 168 } | |
| 169 | |
| 170 SpdyGoAwayStatus ParseGoAwayStatus(int goaway_status_field) { | |
| 171 if (goaway_status_field < GOAWAY_MIN || goaway_status_field > GOAWAY_MAX) { | |
| 172 return GOAWAY_INTERNAL_ERROR; | |
| 173 } | |
| 174 | |
| 175 return static_cast<SpdyGoAwayStatus>(goaway_status_field); | |
| 176 } | 167 } |
| 177 | 168 |
| 178 const char* ErrorCodeToString(uint32_t error_code) { | 169 const char* ErrorCodeToString(uint32_t error_code) { |
| 179 switch (error_code) { | 170 switch (error_code) { |
| 180 case RST_STREAM_NO_ERROR: | 171 case ERROR_CODE_NO_ERROR: |
| 181 return "NO_ERROR"; | 172 return "NO_ERROR"; |
| 182 case RST_STREAM_PROTOCOL_ERROR: | 173 case ERROR_CODE_PROTOCOL_ERROR: |
| 183 return "PROTOCOL_ERROR"; | 174 return "PROTOCOL_ERROR"; |
| 184 case RST_STREAM_INTERNAL_ERROR: | 175 case ERROR_CODE_INTERNAL_ERROR: |
| 185 return "INTERNAL_ERROR"; | 176 return "INTERNAL_ERROR"; |
| 186 case RST_STREAM_FLOW_CONTROL_ERROR: | 177 case ERROR_CODE_FLOW_CONTROL_ERROR: |
| 187 return "FLOW_CONTROL_ERROR"; | 178 return "FLOW_CONTROL_ERROR"; |
| 188 case RST_STREAM_SETTINGS_TIMEOUT: | 179 case ERROR_CODE_SETTINGS_TIMEOUT: |
| 189 return "SETTINGS_TIMEOUT"; | 180 return "SETTINGS_TIMEOUT"; |
| 190 case RST_STREAM_STREAM_CLOSED: | 181 case ERROR_CODE_STREAM_CLOSED: |
| 191 return "STREAM_CLOSED"; | 182 return "STREAM_CLOSED"; |
| 192 case RST_STREAM_FRAME_SIZE_ERROR: | 183 case ERROR_CODE_FRAME_SIZE_ERROR: |
| 193 return "FRAME_SIZE_ERROR"; | 184 return "FRAME_SIZE_ERROR"; |
| 194 case RST_STREAM_REFUSED_STREAM: | 185 case ERROR_CODE_REFUSED_STREAM: |
| 195 return "REFUSED_STREAM"; | 186 return "REFUSED_STREAM"; |
| 196 case RST_STREAM_CANCEL: | 187 case ERROR_CODE_CANCEL: |
| 197 return "CANCEL"; | 188 return "CANCEL"; |
| 198 case RST_STREAM_COMPRESSION_ERROR: | 189 case ERROR_CODE_COMPRESSION_ERROR: |
| 199 return "COMPRESSION_ERROR"; | 190 return "COMPRESSION_ERROR"; |
| 200 case RST_STREAM_CONNECT_ERROR: | 191 case ERROR_CODE_CONNECT_ERROR: |
| 201 return "CONNECT_ERROR"; | 192 return "CONNECT_ERROR"; |
| 202 case RST_STREAM_ENHANCE_YOUR_CALM: | 193 case ERROR_CODE_ENHANCE_YOUR_CALM: |
| 203 return "ENHANCE_YOUR_CALM"; | 194 return "ENHANCE_YOUR_CALM"; |
| 204 case RST_STREAM_INADEQUATE_SECURITY: | 195 case ERROR_CODE_INADEQUATE_SECURITY: |
| 205 return "INADEQUATE_SECURITY"; | 196 return "INADEQUATE_SECURITY"; |
| 206 case RST_STREAM_HTTP_1_1_REQUIRED: | 197 case ERROR_CODE_HTTP_1_1_REQUIRED: |
| 207 return "HTTP_1_1_REQUIRED"; | 198 return "HTTP_1_1_REQUIRED"; |
| 208 } | 199 } |
| 209 return "UNKNOWN_ERROR_CODE"; | 200 return "UNKNOWN_ERROR_CODE"; |
| 210 } | 201 } |
| 211 | 202 |
| 212 const char* const kHttp2Npn = "h2"; | 203 const char* const kHttp2Npn = "h2"; |
| 213 | 204 |
| 214 SpdyFrameWithHeaderBlockIR::SpdyFrameWithHeaderBlockIR( | 205 SpdyFrameWithHeaderBlockIR::SpdyFrameWithHeaderBlockIR( |
| 215 SpdyStreamId stream_id, | 206 SpdyStreamId stream_id, |
| 216 SpdyHeaderBlock header_block) | 207 SpdyHeaderBlock header_block) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 245 padded_(false), | 236 padded_(false), |
| 246 padding_payload_len_(0) {} | 237 padding_payload_len_(0) {} |
| 247 | 238 |
| 248 SpdyDataIR::~SpdyDataIR() {} | 239 SpdyDataIR::~SpdyDataIR() {} |
| 249 | 240 |
| 250 void SpdyDataIR::Visit(SpdyFrameVisitor* visitor) const { | 241 void SpdyDataIR::Visit(SpdyFrameVisitor* visitor) const { |
| 251 return visitor->VisitData(*this); | 242 return visitor->VisitData(*this); |
| 252 } | 243 } |
| 253 | 244 |
| 254 SpdyRstStreamIR::SpdyRstStreamIR(SpdyStreamId stream_id, | 245 SpdyRstStreamIR::SpdyRstStreamIR(SpdyStreamId stream_id, |
| 255 SpdyRstStreamStatus status) | 246 SpdyErrorCode error_code) |
| 256 : SpdyFrameWithStreamIdIR(stream_id) { | 247 : SpdyFrameWithStreamIdIR(stream_id) { |
| 257 set_status(status); | 248 set_error_code(error_code); |
| 258 } | 249 } |
| 259 | 250 |
| 260 SpdyRstStreamIR::~SpdyRstStreamIR() {} | 251 SpdyRstStreamIR::~SpdyRstStreamIR() {} |
| 261 | 252 |
| 262 void SpdyRstStreamIR::Visit(SpdyFrameVisitor* visitor) const { | 253 void SpdyRstStreamIR::Visit(SpdyFrameVisitor* visitor) const { |
| 263 return visitor->VisitRstStream(*this); | 254 return visitor->VisitRstStream(*this); |
| 264 } | 255 } |
| 265 | 256 |
| 266 SpdySettingsIR::SpdySettingsIR() : is_ack_(false) {} | 257 SpdySettingsIR::SpdySettingsIR() : is_ack_(false) {} |
| 267 | 258 |
| 268 SpdySettingsIR::~SpdySettingsIR() {} | 259 SpdySettingsIR::~SpdySettingsIR() {} |
| 269 | 260 |
| 270 void SpdySettingsIR::Visit(SpdyFrameVisitor* visitor) const { | 261 void SpdySettingsIR::Visit(SpdyFrameVisitor* visitor) const { |
| 271 return visitor->VisitSettings(*this); | 262 return visitor->VisitSettings(*this); |
| 272 } | 263 } |
| 273 | 264 |
| 274 void SpdyPingIR::Visit(SpdyFrameVisitor* visitor) const { | 265 void SpdyPingIR::Visit(SpdyFrameVisitor* visitor) const { |
| 275 return visitor->VisitPing(*this); | 266 return visitor->VisitPing(*this); |
| 276 } | 267 } |
| 277 | 268 |
| 278 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, | 269 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
| 279 SpdyGoAwayStatus status, | 270 SpdyErrorCode error_code, |
| 280 base::StringPiece description) | 271 base::StringPiece description) |
| 281 : description_(description) { | 272 : description_(description) { |
| 282 set_last_good_stream_id(last_good_stream_id); | 273 set_last_good_stream_id(last_good_stream_id); |
| 283 set_status(status); | 274 set_error_code(error_code); |
| 284 } | 275 } |
| 285 | 276 |
| 286 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, | 277 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
| 287 SpdyGoAwayStatus status, | 278 SpdyErrorCode error_code, |
| 288 const char* description) | 279 const char* description) |
| 289 : SpdyGoAwayIR(last_good_stream_id, | 280 : SpdyGoAwayIR(last_good_stream_id, |
| 290 status, | 281 error_code, |
| 291 base::StringPiece(description)) {} | 282 base::StringPiece(description)) {} |
| 292 | 283 |
| 293 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, | 284 SpdyGoAwayIR::SpdyGoAwayIR(SpdyStreamId last_good_stream_id, |
| 294 SpdyGoAwayStatus status, | 285 SpdyErrorCode error_code, |
| 295 std::string description) | 286 std::string description) |
| 296 : description_store_(std::move(description)), | 287 : description_store_(std::move(description)), |
| 297 description_(description_store_) { | 288 description_(description_store_) { |
| 298 set_last_good_stream_id(last_good_stream_id); | 289 set_last_good_stream_id(last_good_stream_id); |
| 299 set_status(status); | 290 set_error_code(error_code); |
| 300 } | 291 } |
| 301 | 292 |
| 302 SpdyGoAwayIR::~SpdyGoAwayIR() {} | 293 SpdyGoAwayIR::~SpdyGoAwayIR() {} |
| 303 | 294 |
| 304 SpdyContinuationIR::SpdyContinuationIR(SpdyStreamId stream_id) | 295 SpdyContinuationIR::SpdyContinuationIR(SpdyStreamId stream_id) |
| 305 : SpdyFrameWithStreamIdIR(stream_id), end_headers_(false) { | 296 : SpdyFrameWithStreamIdIR(stream_id), end_headers_(false) { |
| 306 encoding_ = base::MakeUnique<std::string>(); | 297 encoding_ = base::MakeUnique<std::string>(); |
| 307 } | 298 } |
| 308 | 299 |
| 309 SpdyContinuationIR::~SpdyContinuationIR() {} | 300 SpdyContinuationIR::~SpdyContinuationIR() {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 332 |
| 342 void SpdyAltSvcIR::Visit(SpdyFrameVisitor* visitor) const { | 333 void SpdyAltSvcIR::Visit(SpdyFrameVisitor* visitor) const { |
| 343 return visitor->VisitAltSvc(*this); | 334 return visitor->VisitAltSvc(*this); |
| 344 } | 335 } |
| 345 | 336 |
| 346 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const { | 337 void SpdyPriorityIR::Visit(SpdyFrameVisitor* visitor) const { |
| 347 return visitor->VisitPriority(*this); | 338 return visitor->VisitPriority(*this); |
| 348 } | 339 } |
| 349 | 340 |
| 350 } // namespace net | 341 } // namespace net |
| OLD | NEW |