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_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/metrics/stats_counters.h" | 9 #include "base/metrics/stats_counters.h" |
10 #include "base/third_party/valgrind/memcheck.h" | 10 #include "base/third_party/valgrind/memcheck.h" |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 case RST_STREAM_STREAM_ALREADY_CLOSED: | 473 case RST_STREAM_STREAM_ALREADY_CLOSED: |
474 return "STREAM_ALREADY_CLOSED"; | 474 return "STREAM_ALREADY_CLOSED"; |
475 case RST_STREAM_INVALID_CREDENTIALS: | 475 case RST_STREAM_INVALID_CREDENTIALS: |
476 return "INVALID_CREDENTIALS"; | 476 return "INVALID_CREDENTIALS"; |
477 case RST_STREAM_FRAME_TOO_LARGE: | 477 case RST_STREAM_FRAME_TOO_LARGE: |
478 return "FRAME_TOO_LARGE"; | 478 return "FRAME_TOO_LARGE"; |
479 case RST_STREAM_CONNECT_ERROR: | 479 case RST_STREAM_CONNECT_ERROR: |
480 return "CONNECT_ERROR"; | 480 return "CONNECT_ERROR"; |
481 case RST_STREAM_ENHANCE_YOUR_CALM: | 481 case RST_STREAM_ENHANCE_YOUR_CALM: |
482 return "ENHANCE_YOUR_CALM"; | 482 return "ENHANCE_YOUR_CALM"; |
| 483 case RST_STREAM_INADEQUATE_SECURITY: |
| 484 return "INADEQUATE_SECURITY"; |
| 485 case RST_STREAM_HTTP_1_1_REQUIRED: |
| 486 return "HTTP_1_1_REQUIRED"; |
483 } | 487 } |
484 return "UNKNOWN_STATUS"; | 488 return "UNKNOWN_STATUS"; |
485 } | 489 } |
486 | 490 |
487 const char* SpdyFramer::FrameTypeToString(SpdyFrameType type) { | 491 const char* SpdyFramer::FrameTypeToString(SpdyFrameType type) { |
488 switch (type) { | 492 switch (type) { |
489 case DATA: | 493 case DATA: |
490 return "DATA"; | 494 return "DATA"; |
491 case SYN_STREAM: | 495 case SYN_STREAM: |
492 return "SYN_STREAM"; | 496 return "SYN_STREAM"; |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 // TODO(jgraettinger): Process dependency rather than ignoring it. | 1494 // TODO(jgraettinger): Process dependency rather than ignoring it. |
1491 reader.Seek(kPriorityDependencyPayloadSize); | 1495 reader.Seek(kPriorityDependencyPayloadSize); |
1492 uint8 weight = 0; | 1496 uint8 weight = 0; |
1493 successful_read = reader.ReadUInt8(&weight); | 1497 successful_read = reader.ReadUInt8(&weight); |
1494 if (successful_read) { | 1498 if (successful_read) { |
1495 priority = MapWeightToPriority(weight); | 1499 priority = MapWeightToPriority(weight); |
1496 } | 1500 } |
1497 } | 1501 } |
1498 DCHECK(reader.IsDoneReading()); | 1502 DCHECK(reader.IsDoneReading()); |
1499 if (debug_visitor_) { | 1503 if (debug_visitor_) { |
1500 // SPDY 4 reports HEADERS with PRIORITY as SYN_STREAM. | |
1501 SpdyFrameType reported_type = current_frame_type_; | |
1502 if (protocol_version() > SPDY3 && has_priority) { | |
1503 reported_type = SYN_STREAM; | |
1504 } | |
1505 debug_visitor_->OnReceiveCompressedFrame( | 1504 debug_visitor_->OnReceiveCompressedFrame( |
1506 current_frame_stream_id_, | 1505 current_frame_stream_id_, |
1507 reported_type, | 1506 current_frame_type_, |
1508 current_frame_length_); | 1507 current_frame_length_); |
1509 } | 1508 } |
1510 if (current_frame_type_ == SYN_REPLY) { | 1509 if (current_frame_type_ == SYN_REPLY) { |
1511 visitor_->OnSynReply( | 1510 visitor_->OnSynReply( |
1512 current_frame_stream_id_, | 1511 current_frame_stream_id_, |
1513 (current_frame_flags_ & CONTROL_FLAG_FIN) != 0); | 1512 (current_frame_flags_ & CONTROL_FLAG_FIN) != 0); |
1514 } else if (protocol_version() > SPDY3 && | |
1515 current_frame_flags_ & HEADERS_FLAG_PRIORITY) { | |
1516 // SPDY 4+ is missing SYN_STREAM. Simulate it so that API changes | |
1517 // can be made independent of wire changes. | |
1518 visitor_->OnSynStream( | |
1519 current_frame_stream_id_, | |
1520 0, // associated_to_stream_id | |
1521 priority, | |
1522 current_frame_flags_ & CONTROL_FLAG_FIN, | |
1523 false); // unidirectional | |
1524 } else { | 1513 } else { |
1525 visitor_->OnHeaders( | 1514 visitor_->OnHeaders( |
1526 current_frame_stream_id_, | 1515 current_frame_stream_id_, |
| 1516 (current_frame_flags_ & HEADERS_FLAG_PRIORITY) != 0, priority, |
1527 (current_frame_flags_ & CONTROL_FLAG_FIN) != 0, | 1517 (current_frame_flags_ & CONTROL_FLAG_FIN) != 0, |
1528 expect_continuation_ == 0); | 1518 expect_continuation_ == 0); |
1529 } | 1519 } |
1530 } | 1520 } |
1531 CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); | 1521 CHANGE_STATE(SPDY_CONTROL_FRAME_HEADER_BLOCK); |
1532 break; | 1522 break; |
1533 case PUSH_PROMISE: | 1523 case PUSH_PROMISE: |
1534 { | 1524 { |
1535 DCHECK_LT(SPDY3, protocol_version()); | 1525 DCHECK_LT(SPDY3, protocol_version()); |
1536 if (current_frame_stream_id_ == 0) { | 1526 if (current_frame_stream_id_ == 0) { |
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3298 builder->Seek(compressed_size); | 3288 builder->Seek(compressed_size); |
3299 builder->RewriteLength(*this); | 3289 builder->RewriteLength(*this); |
3300 | 3290 |
3301 pre_compress_bytes.Add(uncompressed_len); | 3291 pre_compress_bytes.Add(uncompressed_len); |
3302 post_compress_bytes.Add(compressed_size); | 3292 post_compress_bytes.Add(compressed_size); |
3303 | 3293 |
3304 compressed_frames.Increment(); | 3294 compressed_frames.Increment(); |
3305 } | 3295 } |
3306 | 3296 |
3307 } // namespace net | 3297 } // namespace net |
OLD | NEW |