Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: net/spdy/spdy_deframer_visitor.cc

Issue 2561963002: base: Remove the string logging from CHECK(). (Closed)
Patch Set: checkstring: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_deframer_visitor.h" 5 #include "net/spdy/spdy_deframer_visitor.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 std::move(*goaway_description_))); 278 std::move(*goaway_description_)));
279 CHECK_EQ(0u, goaway_description_->size()); 279 CHECK_EQ(0u, goaway_description_->size());
280 } 280 }
281 goaway_description_.reset(); 281 goaway_description_.reset();
282 goaway_ir_.reset(); 282 goaway_ir_.reset();
283 frame_type_ = UNSET; 283 frame_type_ = UNSET;
284 } 284 }
285 285
286 void SpdyTestDeframerImpl::AtHeadersEnd() { 286 void SpdyTestDeframerImpl::AtHeadersEnd() {
287 DVLOG(1) << "AtDataEnd"; 287 DVLOG(1) << "AtDataEnd";
288 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION) 288 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION);
289 << " frame_type_=" << Http2FrameTypeToString(frame_type_); 289 CHECK(end_);
290 CHECK(end_) << " frame_type_=" << Http2FrameTypeToString(frame_type_);
291 CHECK(got_hpack_end_); 290 CHECK(got_hpack_end_);
292 291
293 CHECK(headers_ir_); 292 CHECK(headers_ir_);
294 CHECK(headers_); 293 CHECK(headers_);
295 CHECK(headers_handler_); 294 CHECK(headers_handler_);
296 295
297 CHECK_LE(0u, padding_len_); 296 CHECK_LE(0u, padding_len_);
298 CHECK_LE(padding_len_, 256u); 297 CHECK_LE(padding_len_, 256u);
299 if (padding_len_ > 0) { 298 if (padding_len_ > 0) {
300 headers_ir_->set_padding_len(padding_len_); 299 headers_ir_->set_padding_len(padding_len_);
301 } 300 }
302 padding_len_ = 0; 301 padding_len_ = 0;
303 302
304 headers_ir_->set_header_block(headers_handler_->decoded_block().Clone()); 303 headers_ir_->set_header_block(headers_handler_->decoded_block().Clone());
305 headers_handler_.reset(); 304 headers_handler_.reset();
306 listener_->OnHeaders(std::move(headers_ir_), std::move(headers_)); 305 listener_->OnHeaders(std::move(headers_ir_), std::move(headers_));
307 306
308 frame_type_ = UNSET; 307 frame_type_ = UNSET;
309 fin_ = false; 308 fin_ = false;
310 end_ = false; 309 end_ = false;
311 got_hpack_end_ = false; 310 got_hpack_end_ = false;
312 } 311 }
313 312
314 void SpdyTestDeframerImpl::AtPushPromiseEnd() { 313 void SpdyTestDeframerImpl::AtPushPromiseEnd() {
315 DVLOG(1) << "AtDataEnd"; 314 DVLOG(1) << "AtDataEnd";
316 CHECK(frame_type_ == PUSH_PROMISE || frame_type_ == CONTINUATION) 315 CHECK(frame_type_ == PUSH_PROMISE || frame_type_ == CONTINUATION);
317 << " frame_type_=" << Http2FrameTypeToString(frame_type_); 316 CHECK(end_);
318 CHECK(end_) << " frame_type_=" << Http2FrameTypeToString(frame_type_);
319 317
320 CHECK(push_promise_ir_); 318 CHECK(push_promise_ir_);
321 CHECK(headers_); 319 CHECK(headers_);
322 CHECK(headers_handler_); 320 CHECK(headers_handler_);
323 321
324 CHECK_EQ(headers_ir_.get(), nullptr); 322 CHECK_EQ(headers_ir_.get(), nullptr);
325 323
326 CHECK_LE(0u, padding_len_); 324 CHECK_LE(0u, padding_len_);
327 CHECK_LE(padding_len_, 256u); 325 CHECK_LE(padding_len_, 256u);
328 if (padding_len_ > 0) { 326 if (padding_len_ > 0) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 return true; 407 return true;
410 } 408 }
411 409
412 // Overridden methods from SpdyFramerVisitorInterface in alpha order... 410 // Overridden methods from SpdyFramerVisitorInterface in alpha order...
413 411
414 void SpdyTestDeframerImpl::OnAltSvc( 412 void SpdyTestDeframerImpl::OnAltSvc(
415 SpdyStreamId stream_id, 413 SpdyStreamId stream_id,
416 StringPiece origin, 414 StringPiece origin,
417 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { 415 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {
418 DVLOG(1) << "OnAltSvc stream_id: " << stream_id; 416 DVLOG(1) << "OnAltSvc stream_id: " << stream_id;
419 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 417 CHECK_EQ(frame_type_, UNSET);
420 << Http2FrameTypeToString(frame_type_);
421 CHECK_GT(stream_id, 0u); 418 CHECK_GT(stream_id, 0u);
422 auto ptr = MakeUnique<SpdyAltSvcIR>(stream_id); 419 auto ptr = MakeUnique<SpdyAltSvcIR>(stream_id);
423 ptr->set_origin(origin.as_string()); 420 ptr->set_origin(origin.as_string());
424 for (auto& altsvc : altsvc_vector) { 421 for (auto& altsvc : altsvc_vector) {
425 ptr->add_altsvc(altsvc); 422 ptr->add_altsvc(altsvc);
426 } 423 }
427 listener_->OnAltSvc(std::move(ptr)); 424 listener_->OnAltSvc(std::move(ptr));
428 } 425 }
429 426
430 // Frame type BLOCKED was removed in draft 12 of HTTP/2. The intent appears to 427 // Frame type BLOCKED was removed in draft 12 of HTTP/2. The intent appears to
431 // have been to support debugging; it is not expected to be seen except if the 428 // have been to support debugging; it is not expected to be seen except if the
432 // peer "thinks" that a bug exists in the flow control such that the peer can't 429 // peer "thinks" that a bug exists in the flow control such that the peer can't
433 // send because the receiver hasn't sent WINDOW_UPDATE frames. Since we might 430 // send because the receiver hasn't sent WINDOW_UPDATE frames. Since we might
434 // be talking to multiple backends, it is quite plausible that one backend 431 // be talking to multiple backends, it is quite plausible that one backend
435 // is unable to take more input from the client (hence no WINDOW_UPDATE), yet 432 // is unable to take more input from the client (hence no WINDOW_UPDATE), yet
436 // other backends can take more input. 433 // other backends can take more input.
437 void SpdyTestDeframerImpl::OnBlocked(SpdyStreamId stream_id) { 434 void SpdyTestDeframerImpl::OnBlocked(SpdyStreamId stream_id) {
438 LOG(FATAL) << "OnBlocked stream_id: " << stream_id; 435 LOG(FATAL) << "OnBlocked stream_id: " << stream_id;
439 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 436 CHECK_EQ(frame_type_, UNSET);
440 << Http2FrameTypeToString(frame_type_);
441 CHECK_GT(stream_id, 0u); 437 CHECK_GT(stream_id, 0u);
442 frame_type_ = UNSET; 438 frame_type_ = UNSET;
443 stream_id_ = stream_id; 439 stream_id_ = stream_id;
444 } 440 }
445 441
446 // A CONTINUATION frame contains a Header Block Fragment, and immediately 442 // A CONTINUATION frame contains a Header Block Fragment, and immediately
447 // follows another frame that contains a Header Block Fragment (HEADERS, 443 // follows another frame that contains a Header Block Fragment (HEADERS,
448 // PUSH_PROMISE or CONTINUATION). The last such frame has the END flag set. 444 // PUSH_PROMISE or CONTINUATION). The last such frame has the END flag set.
449 // SpdyFramer ensures that the behavior is correct before calling the visitor. 445 // SpdyFramer ensures that the behavior is correct before calling the visitor.
450 void SpdyTestDeframerImpl::OnContinuation(SpdyStreamId stream_id, bool end) { 446 void SpdyTestDeframerImpl::OnContinuation(SpdyStreamId stream_id, bool end) {
451 DVLOG(1) << "OnContinuation stream_id: " << stream_id; 447 DVLOG(1) << "OnContinuation stream_id: " << stream_id;
452 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 448 CHECK_EQ(frame_type_, UNSET);
453 << Http2FrameTypeToString(frame_type_);
454 CHECK_GT(stream_id, 0u); 449 CHECK_GT(stream_id, 0u);
455 CHECK_NE(nullptr, headers_.get()); 450 CHECK_NE(nullptr, headers_.get());
456 frame_type_ = CONTINUATION; 451 frame_type_ = CONTINUATION;
457 452
458 stream_id_ = stream_id; 453 stream_id_ = stream_id;
459 end_ = end; 454 end_ = end;
460 } 455 }
461 456
462 // Note that length includes the padding length (0 to 256, when the optional 457 // Note that length includes the padding length (0 to 256, when the optional
463 // padding length field is counted). Padding comes after the payload, both 458 // padding length field is counted). Padding comes after the payload, both
464 // for DATA frames and for control frames. 459 // for DATA frames and for control frames.
465 void SpdyTestDeframerImpl::OnDataFrameHeader(SpdyStreamId stream_id, 460 void SpdyTestDeframerImpl::OnDataFrameHeader(SpdyStreamId stream_id,
466 size_t length, 461 size_t length,
467 bool fin) { 462 bool fin) {
468 DVLOG(1) << "OnDataFrameHeader stream_id: " << stream_id; 463 DVLOG(1) << "OnDataFrameHeader stream_id: " << stream_id;
469 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 464 CHECK_EQ(frame_type_, UNSET);
470 << Http2FrameTypeToString(frame_type_);
471 CHECK_GT(stream_id, 0u); 465 CHECK_GT(stream_id, 0u);
472 CHECK_EQ(data_.get(), nullptr); 466 CHECK_EQ(data_.get(), nullptr);
473 frame_type_ = DATA; 467 frame_type_ = DATA;
474 468
475 stream_id_ = stream_id; 469 stream_id_ = stream_id;
476 fin_ = fin; 470 fin_ = fin;
477 data_len_ = length; 471 data_len_ = length;
478 data_.reset(new string()); 472 data_.reset(new string());
479 } 473 }
480 474
481 // The SpdyFramer will not process any more data at this point. 475 // The SpdyFramer will not process any more data at this point.
482 void SpdyTestDeframerImpl::OnError(SpdyFramer* framer) { 476 void SpdyTestDeframerImpl::OnError(SpdyFramer* framer) {
483 DVLOG(1) << "SpdyFramer detected an error in the stream: " 477 DVLOG(1) << "SpdyFramer detected an error in the stream: "
484 << SpdyFramer::ErrorCodeToString(framer->error_code()) 478 << SpdyFramer::ErrorCodeToString(framer->error_code())
485 << " frame_type_: " << Http2FrameTypeToString(frame_type_); 479 << " frame_type_: " << Http2FrameTypeToString(frame_type_);
486 listener_->OnError(framer, this); 480 listener_->OnError(framer, this);
487 } 481 }
488 482
489 // Received a GOAWAY frame from the peer. The last stream id it accepted from us 483 // Received a GOAWAY frame from the peer. The last stream id it accepted from us
490 // is |last_accepted_stream_id|. |status| is a protocol defined error code. 484 // is |last_accepted_stream_id|. |status| is a protocol defined error code.
491 // The frame may also contain data. After this OnGoAwayFrameData will be called 485 // The frame may also contain data. After this OnGoAwayFrameData will be called
492 // for any non-zero amount of data, and after that it will be called with len==0 486 // for any non-zero amount of data, and after that it will be called with len==0
493 // to indicate the end of the GOAWAY frame. 487 // to indicate the end of the GOAWAY frame.
494 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id, 488 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id,
495 SpdyGoAwayStatus status) { 489 SpdyGoAwayStatus status) {
496 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id 490 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id
497 << " status: " << status; 491 << " status: " << status;
498 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 492 CHECK_EQ(frame_type_, UNSET);
499 << Http2FrameTypeToString(frame_type_);
500 frame_type_ = GOAWAY; 493 frame_type_ = GOAWAY;
501 goaway_ir_ = MakeUnique<SpdyGoAwayIR>(last_good_stream_id, status, ""); 494 goaway_ir_ = MakeUnique<SpdyGoAwayIR>(last_good_stream_id, status, "");
502 goaway_description_.reset(new string()); 495 goaway_description_.reset(new string());
503 } 496 }
504 497
505 // If len==0 then we've reached the end of the GOAWAY frame. 498 // If len==0 then we've reached the end of the GOAWAY frame.
506 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data, 499 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data,
507 size_t len) { 500 size_t len) {
508 DVLOG(1) << "OnGoAwayFrameData"; 501 DVLOG(1) << "OnGoAwayFrameData";
509 CHECK_EQ(frame_type_, GOAWAY) << " frame_type_=" 502 CHECK_EQ(frame_type_, GOAWAY);
510 << Http2FrameTypeToString(frame_type_);
511 CHECK(goaway_description_); 503 CHECK(goaway_description_);
512 StringPiece(goaway_data, len).AppendToString(goaway_description_.get()); 504 StringPiece(goaway_data, len).AppendToString(goaway_description_.get());
513 return true; 505 return true;
514 } 506 }
515 507
516 SpdyHeadersHandlerInterface* SpdyTestDeframerImpl::OnHeaderFrameStart( 508 SpdyHeadersHandlerInterface* SpdyTestDeframerImpl::OnHeaderFrameStart(
517 SpdyStreamId stream_id) { 509 SpdyStreamId stream_id) {
518 return this; 510 return this;
519 } 511 }
520 512
(...skipping 11 matching lines...) Expand all
532 // frame; else if true then there will be CONTINATION frames(s) immediately 524 // frame; else if true then there will be CONTINATION frames(s) immediately
533 // following this frame, terminated by a CONTINUATION frame with end==true. 525 // following this frame, terminated by a CONTINUATION frame with end==true.
534 void SpdyTestDeframerImpl::OnHeaders(SpdyStreamId stream_id, 526 void SpdyTestDeframerImpl::OnHeaders(SpdyStreamId stream_id,
535 bool has_priority, 527 bool has_priority,
536 int weight, 528 int weight,
537 SpdyStreamId parent_stream_id, 529 SpdyStreamId parent_stream_id,
538 bool exclusive, 530 bool exclusive,
539 bool fin, 531 bool fin,
540 bool end) { 532 bool end) {
541 DVLOG(1) << "OnHeaders stream_id: " << stream_id; 533 DVLOG(1) << "OnHeaders stream_id: " << stream_id;
542 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 534 CHECK_EQ(frame_type_, UNSET);
543 << Http2FrameTypeToString(frame_type_);
544 CHECK_GT(stream_id, 0u); 535 CHECK_GT(stream_id, 0u);
545 frame_type_ = HEADERS; 536 frame_type_ = HEADERS;
546 537
547 stream_id_ = stream_id; 538 stream_id_ = stream_id;
548 fin_ = fin; 539 fin_ = fin;
549 end_ = end; 540 end_ = end;
550 541
551 headers_.reset(new StringPairVector()); 542 headers_.reset(new StringPairVector());
552 headers_handler_.reset(new TestHeadersHandler()); 543 headers_handler_.reset(new TestHeadersHandler());
553 headers_ir_ = MakeUnique<SpdyHeadersIR>(stream_id); 544 headers_ir_ = MakeUnique<SpdyHeadersIR>(stream_id);
554 headers_ir_->set_fin(fin); 545 headers_ir_->set_fin(fin);
555 if (has_priority) { 546 if (has_priority) {
556 headers_ir_->set_has_priority(true); 547 headers_ir_->set_has_priority(true);
557 headers_ir_->set_weight(weight); 548 headers_ir_->set_weight(weight);
558 headers_ir_->set_parent_stream_id(parent_stream_id); 549 headers_ir_->set_parent_stream_id(parent_stream_id);
559 headers_ir_->set_exclusive(exclusive); 550 headers_ir_->set_exclusive(exclusive);
560 } 551 }
561 } 552 }
562 553
563 // The HTTP/2 protocol refers to the payload, |unique_id| here, as 8 octets of 554 // The HTTP/2 protocol refers to the payload, |unique_id| here, as 8 octets of
564 // opaque data that is to be echoed back to the sender, with the ACK bit added. 555 // opaque data that is to be echoed back to the sender, with the ACK bit added.
565 // It isn't defined as a counter, 556 // It isn't defined as a counter,
566 // or frame id, as the SpdyPingId naming might imply. 557 // or frame id, as the SpdyPingId naming might imply.
567 // Responding to a PING is supposed to be at the highest priority. 558 // Responding to a PING is supposed to be at the highest priority.
568 void SpdyTestDeframerImpl::OnPing(uint64_t unique_id, bool is_ack) { 559 void SpdyTestDeframerImpl::OnPing(uint64_t unique_id, bool is_ack) {
569 DVLOG(1) << "OnPing unique_id: " << unique_id 560 DVLOG(1) << "OnPing unique_id: " << unique_id
570 << " is_ack: " << (is_ack ? "true" : "false"); 561 << " is_ack: " << (is_ack ? "true" : "false");
571 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 562 CHECK_EQ(frame_type_, UNSET);
572 << Http2FrameTypeToString(frame_type_);
573 auto ptr = MakeUnique<SpdyPingIR>(unique_id); 563 auto ptr = MakeUnique<SpdyPingIR>(unique_id);
574 if (is_ack) { 564 if (is_ack) {
575 ptr->set_is_ack(is_ack); 565 ptr->set_is_ack(is_ack);
576 listener_->OnPingAck(std::move(ptr)); 566 listener_->OnPingAck(std::move(ptr));
577 } else { 567 } else {
578 listener_->OnPing(std::move(ptr)); 568 listener_->OnPing(std::move(ptr));
579 } 569 }
580 } 570 }
581 571
582 void SpdyTestDeframerImpl::OnPriority(SpdyStreamId stream_id, 572 void SpdyTestDeframerImpl::OnPriority(SpdyStreamId stream_id,
583 SpdyStreamId parent_stream_id, 573 SpdyStreamId parent_stream_id,
584 int weight, 574 int weight,
585 bool exclusive) { 575 bool exclusive) {
586 DVLOG(1) << "OnPriority stream_id: " << stream_id; 576 DVLOG(1) << "OnPriority stream_id: " << stream_id;
587 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 577 CHECK_EQ(frame_type_, UNSET);
588 << Http2FrameTypeToString(frame_type_);
589 CHECK_GT(stream_id, 0u); 578 CHECK_GT(stream_id, 0u);
590 579
591 listener_->OnPriority(MakeUnique<SpdyPriorityIR>(stream_id, parent_stream_id, 580 listener_->OnPriority(MakeUnique<SpdyPriorityIR>(stream_id, parent_stream_id,
592 weight, exclusive)); 581 weight, exclusive));
593 } 582 }
594 583
595 void SpdyTestDeframerImpl::OnPushPromise(SpdyStreamId stream_id, 584 void SpdyTestDeframerImpl::OnPushPromise(SpdyStreamId stream_id,
596 SpdyStreamId promised_stream_id, 585 SpdyStreamId promised_stream_id,
597 bool end) { 586 bool end) {
598 DVLOG(1) << "OnPushPromise stream_id: " << stream_id; 587 DVLOG(1) << "OnPushPromise stream_id: " << stream_id;
599 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 588 CHECK_EQ(frame_type_, UNSET);
600 << Http2FrameTypeToString(frame_type_);
601 CHECK_GT(stream_id, 0u); 589 CHECK_GT(stream_id, 0u);
602 590
603 frame_type_ = PUSH_PROMISE; 591 frame_type_ = PUSH_PROMISE;
604 stream_id_ = stream_id; 592 stream_id_ = stream_id;
605 end_ = end; 593 end_ = end;
606 594
607 headers_.reset(new StringPairVector()); 595 headers_.reset(new StringPairVector());
608 headers_handler_.reset(new TestHeadersHandler()); 596 headers_handler_.reset(new TestHeadersHandler());
609 push_promise_ir_ = 597 push_promise_ir_ =
610 MakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id); 598 MakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id);
611 } 599 }
612 600
613 // Closes the specified stream. After this the sender may still send PRIORITY 601 // Closes the specified stream. After this the sender may still send PRIORITY
614 // frames for this stream, which we can ignore. 602 // frames for this stream, which we can ignore.
615 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id, 603 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id,
616 SpdyRstStreamStatus status) { 604 SpdyRstStreamStatus status) {
617 DVLOG(1) << "OnRstStream stream_id: " << stream_id 605 DVLOG(1) << "OnRstStream stream_id: " << stream_id
618 << " status: " << status; 606 << " status: " << status;
619 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 607 CHECK_EQ(frame_type_, UNSET);
620 << Http2FrameTypeToString(frame_type_);
621 CHECK_GT(stream_id, 0u); 608 CHECK_GT(stream_id, 0u);
622 609
623 listener_->OnRstStream(MakeUnique<SpdyRstStreamIR>(stream_id, status)); 610 listener_->OnRstStream(MakeUnique<SpdyRstStreamIR>(stream_id, status));
624 } 611 }
625 612
626 // The HTTP/2 spec states that there is no data in the frame other that the 613 // The HTTP/2 spec states that there is no data in the frame other that the
627 // SpdyRstStreamStatus passed to OnRstStream, so it appears that SpdyFramer's 614 // SpdyRstStreamStatus passed to OnRstStream, so it appears that SpdyFramer's
628 // comments w.r.t. this method are obsolete. We still receive a zero length 615 // comments w.r.t. this method are obsolete. We still receive a zero length
629 // invocation when RST_STREAM frame processing completes. 616 // invocation when RST_STREAM frame processing completes.
630 bool SpdyTestDeframerImpl::OnRstStreamFrameData(const char* rst_stream_data, 617 bool SpdyTestDeframerImpl::OnRstStreamFrameData(const char* rst_stream_data,
631 size_t len) { 618 size_t len) {
632 DVLOG(1) << "OnRstStreamFrameData"; 619 DVLOG(1) << "OnRstStreamFrameData";
633 CHECK_EQ(0u, len); 620 CHECK_EQ(0u, len);
634 return true; 621 return true;
635 } 622 }
636 623
637 // Called for an individual setting. There is no negotiation, the sender is 624 // Called for an individual setting. There is no negotiation, the sender is
638 // stating the value that the sender is using. 625 // stating the value that the sender is using.
639 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id, 626 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id,
640 uint8_t flags, 627 uint8_t flags,
641 uint32_t value) { 628 uint32_t value) {
642 DVLOG(1) << "OnSetting id: " << id << std::hex << " flags: " << flags 629 DVLOG(1) << "OnSetting id: " << id << std::hex << " flags: " << flags
643 << " value: " << value; 630 << " value: " << value;
644 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_=" 631 CHECK_EQ(frame_type_, SETTINGS);
645 << Http2FrameTypeToString(frame_type_);
646 CHECK(settings_); 632 CHECK(settings_);
647 settings_->push_back(std::make_pair(id, value)); 633 settings_->push_back(std::make_pair(id, value));
648 settings_ir_->AddSetting(id, true, true, value); 634 settings_ir_->AddSetting(id, true, true, value);
649 } 635 }
650 636
651 // Called at the start of a SETTINGS frame with setting entries, but not the 637 // Called at the start of a SETTINGS frame with setting entries, but not the
652 // (required) ACK of a SETTINGS frame. There is no stream_id because 638 // (required) ACK of a SETTINGS frame. There is no stream_id because
653 // the settings apply to the entire connection, not to an individual stream. 639 // the settings apply to the entire connection, not to an individual stream.
654 // The |clear_persisted| flag is a pre-HTTP/2 remnant. 640 // The |clear_persisted| flag is a pre-HTTP/2 remnant.
655 void SpdyTestDeframerImpl::OnSettings(bool /*clear_persisted*/) { 641 void SpdyTestDeframerImpl::OnSettings(bool /*clear_persisted*/) {
656 DVLOG(1) << "OnSettings"; 642 DVLOG(1) << "OnSettings";
657 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 643 CHECK_EQ(frame_type_, UNSET);
658 << Http2FrameTypeToString(frame_type_);
659 CHECK_EQ(nullptr, settings_ir_.get()); 644 CHECK_EQ(nullptr, settings_ir_.get());
660 CHECK_EQ(nullptr, settings_.get()); 645 CHECK_EQ(nullptr, settings_.get());
661 frame_type_ = SETTINGS; 646 frame_type_ = SETTINGS;
662 ack_ = false; 647 ack_ = false;
663 648
664 settings_.reset(new SettingVector()); 649 settings_.reset(new SettingVector());
665 settings_ir_.reset(new SpdySettingsIR()); 650 settings_ir_.reset(new SpdySettingsIR());
666 } 651 }
667 652
668 void SpdyTestDeframerImpl::OnSettingsAck() { 653 void SpdyTestDeframerImpl::OnSettingsAck() {
669 DVLOG(1) << "OnSettingsAck"; 654 DVLOG(1) << "OnSettingsAck";
670 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 655 CHECK_EQ(frame_type_, UNSET);
671 << Http2FrameTypeToString(frame_type_);
672 auto ptr = MakeUnique<SpdySettingsIR>(); 656 auto ptr = MakeUnique<SpdySettingsIR>();
673 ptr->set_is_ack(true); 657 ptr->set_is_ack(true);
674 listener_->OnSettingsAck(std::move(ptr)); 658 listener_->OnSettingsAck(std::move(ptr));
675 } 659 }
676 660
677 void SpdyTestDeframerImpl::OnSettingsEnd() { 661 void SpdyTestDeframerImpl::OnSettingsEnd() {
678 DVLOG(1) << "OnSettingsEnd"; 662 DVLOG(1) << "OnSettingsEnd";
679 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_=" 663 CHECK_EQ(frame_type_, SETTINGS);
680 << Http2FrameTypeToString(frame_type_);
681 CHECK(!ack_); 664 CHECK(!ack_);
682 CHECK_NE(nullptr, settings_ir_.get()); 665 CHECK_NE(nullptr, settings_ir_.get());
683 CHECK_NE(nullptr, settings_.get()); 666 CHECK_NE(nullptr, settings_.get());
684 listener_->OnSettings(std::move(settings_ir_), std::move(settings_)); 667 listener_->OnSettings(std::move(settings_ir_), std::move(settings_));
685 frame_type_ = UNSET; 668 frame_type_ = UNSET;
686 } 669 }
687 670
688 // Called for a zero length DATA frame with the END_STREAM flag set, or at the 671 // Called for a zero length DATA frame with the END_STREAM flag set, or at the
689 // end a complete HPACK block (and its padding) that started with a HEADERS 672 // end a complete HPACK block (and its padding) that started with a HEADERS
690 // frame with the END_STREAM flag set. Doesn't apply to PUSH_PROMISE frames 673 // frame with the END_STREAM flag set. Doesn't apply to PUSH_PROMISE frames
691 // because they don't have END_STREAM flags. 674 // because they don't have END_STREAM flags.
692 void SpdyTestDeframerImpl::OnStreamEnd(SpdyStreamId stream_id) { 675 void SpdyTestDeframerImpl::OnStreamEnd(SpdyStreamId stream_id) {
693 DVLOG(1) << "OnStreamEnd stream_id: " << stream_id; 676 DVLOG(1) << "OnStreamEnd stream_id: " << stream_id;
694 CHECK_EQ(stream_id_, stream_id); 677 CHECK_EQ(stream_id_, stream_id);
695 CHECK(frame_type_ == DATA || frame_type_ == HEADERS || 678 CHECK(frame_type_ == DATA || frame_type_ == HEADERS ||
696 frame_type_ == CONTINUATION) 679 frame_type_ == CONTINUATION);
697 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
698 CHECK(fin_); 680 CHECK(fin_);
699 } 681 }
700 682
701 // The data arg points into the non-padding payload of a DATA frame. 683 // The data arg points into the non-padding payload of a DATA frame.
702 // This must be a DATA frame (i.e. this method will not be 684 // This must be a DATA frame (i.e. this method will not be
703 // called for HEADERS or CONTINUATION frames). 685 // called for HEADERS or CONTINUATION frames).
704 // This method may be called multiple times for a single DATA frame, depending 686 // This method may be called multiple times for a single DATA frame, depending
705 // upon buffer boundaries. 687 // upon buffer boundaries.
706 void SpdyTestDeframerImpl::OnStreamFrameData(SpdyStreamId stream_id, 688 void SpdyTestDeframerImpl::OnStreamFrameData(SpdyStreamId stream_id,
707 const char* data, 689 const char* data,
708 size_t len) { 690 size_t len) {
709 DVLOG(1) << "OnStreamFrameData stream_id: " << stream_id 691 DVLOG(1) << "OnStreamFrameData stream_id: " << stream_id
710 << " len: " << len; 692 << " len: " << len;
711 CHECK_EQ(stream_id_, stream_id); 693 CHECK_EQ(stream_id_, stream_id);
712 CHECK_EQ(frame_type_, DATA); 694 CHECK_EQ(frame_type_, DATA);
713 StringPiece(data, len).AppendToString(data_.get()); 695 StringPiece(data, len).AppendToString(data_.get());
714 } 696 }
715 697
716 // Called when padding is skipped over, including the padding length field at 698 // Called when padding is skipped over, including the padding length field at
717 // the start of the frame payload, and the actual padding at the end. len will 699 // the start of the frame payload, and the actual padding at the end. len will
718 // be in the range 1 to 255. 700 // be in the range 1 to 255.
719 void SpdyTestDeframerImpl::OnStreamPadding(SpdyStreamId stream_id, size_t len) { 701 void SpdyTestDeframerImpl::OnStreamPadding(SpdyStreamId stream_id, size_t len) {
720 DVLOG(1) << "OnStreamPadding stream_id: " << stream_id << " len: " << len; 702 DVLOG(1) << "OnStreamPadding stream_id: " << stream_id << " len: " << len;
721 CHECK(frame_type_ == DATA || frame_type_ == HEADERS || 703 CHECK(frame_type_ == DATA || frame_type_ == HEADERS ||
722 frame_type_ == PUSH_PROMISE) 704 frame_type_ == PUSH_PROMISE);
723 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
724 CHECK_EQ(stream_id_, stream_id); 705 CHECK_EQ(stream_id_, stream_id);
725 CHECK_LE(1u, len); 706 CHECK_LE(1u, len);
726 CHECK_GE(255u, len); 707 CHECK_GE(255u, len);
727 padding_len_ += len; 708 padding_len_ += len;
728 CHECK_LE(padding_len_, 256u) << "len=" << len; 709 CHECK_LE(padding_len_, 256u);
729 } 710 }
730 711
731 // WINDOW_UPDATE is supposed to be hop-by-hop, according to the spec. 712 // WINDOW_UPDATE is supposed to be hop-by-hop, according to the spec.
732 // stream_id is 0 if the update applies to the connection, else stream_id 713 // stream_id is 0 if the update applies to the connection, else stream_id
733 // will be the id of a stream previously seen, which maybe half or fully 714 // will be the id of a stream previously seen, which maybe half or fully
734 // closed. 715 // closed.
735 void SpdyTestDeframerImpl::OnWindowUpdate(SpdyStreamId stream_id, 716 void SpdyTestDeframerImpl::OnWindowUpdate(SpdyStreamId stream_id,
736 int delta_window_size) { 717 int delta_window_size) {
737 DVLOG(1) << "OnWindowUpdate stream_id: " << stream_id 718 DVLOG(1) << "OnWindowUpdate stream_id: " << stream_id
738 << " delta_window_size: " << delta_window_size; 719 << " delta_window_size: " << delta_window_size;
739 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 720 CHECK_EQ(frame_type_, UNSET);
740 << Http2FrameTypeToString(frame_type_);
741 CHECK_NE(0, delta_window_size); 721 CHECK_NE(0, delta_window_size);
742 722
743 listener_->OnWindowUpdate( 723 listener_->OnWindowUpdate(
744 MakeUnique<SpdyWindowUpdateIR>(stream_id, delta_window_size)); 724 MakeUnique<SpdyWindowUpdateIR>(stream_id, delta_window_size));
745 } 725 }
746 726
747 // Return true to indicate that the stream_id is valid; if not valid then 727 // Return true to indicate that the stream_id is valid; if not valid then
748 // SpdyFramer considers the connection corrupted. Requires keeping track 728 // SpdyFramer considers the connection corrupted. Requires keeping track
749 // of the set of currently open streams. For now we'll assume that unknown 729 // of the set of currently open streams. For now we'll assume that unknown
750 // frame types are unsupported. 730 // frame types are unsupported.
751 bool SpdyTestDeframerImpl::OnUnknownFrame(SpdyStreamId stream_id, 731 bool SpdyTestDeframerImpl::OnUnknownFrame(SpdyStreamId stream_id,
752 int frame_type) { 732 int frame_type) {
753 DVLOG(1) << "OnAltSvc stream_id: " << stream_id; 733 DVLOG(1) << "OnAltSvc stream_id: " << stream_id;
754 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 734 CHECK_EQ(frame_type_, UNSET);
755 << Http2FrameTypeToString(frame_type_);
756 frame_type_ = UNKNOWN; 735 frame_type_ = UNKNOWN;
757 736
758 stream_id_ = stream_id; 737 stream_id_ = stream_id;
759 return false; 738 return false;
760 } 739 }
761 740
762 // Callbacks defined in SpdyHeadersHandlerInterface. 741 // Callbacks defined in SpdyHeadersHandlerInterface.
763 742
764 void SpdyTestDeframerImpl::OnHeaderBlockStart() { 743 void SpdyTestDeframerImpl::OnHeaderBlockStart() {
765 CHECK(frame_type_ == HEADERS || frame_type_ == PUSH_PROMISE) 744 CHECK(frame_type_ == HEADERS || frame_type_ == PUSH_PROMISE);
766 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
767 CHECK(headers_); 745 CHECK(headers_);
768 CHECK_EQ(0u, headers_->size()); 746 CHECK_EQ(0u, headers_->size());
769 got_hpack_end_ = false; 747 got_hpack_end_ = false;
770 } 748 }
771 749
772 void SpdyTestDeframerImpl::OnHeader(StringPiece key, StringPiece value) { 750 void SpdyTestDeframerImpl::OnHeader(StringPiece key, StringPiece value) {
773 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || 751 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION ||
774 frame_type_ == PUSH_PROMISE) 752 frame_type_ == PUSH_PROMISE);
775 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
776 CHECK(!got_hpack_end_); 753 CHECK(!got_hpack_end_);
777 CHECK(headers_); 754 CHECK(headers_);
778 headers_->emplace_back(key.as_string(), value.as_string()); 755 headers_->emplace_back(key.as_string(), value.as_string());
779 CHECK(headers_handler_); 756 CHECK(headers_handler_);
780 headers_handler_->OnHeader(key, value); 757 headers_handler_->OnHeader(key, value);
781 } 758 }
782 759
783 void SpdyTestDeframerImpl::OnHeaderBlockEnd(size_t header_bytes_parsed) { 760 void SpdyTestDeframerImpl::OnHeaderBlockEnd(size_t header_bytes_parsed) {
784 CHECK(headers_); 761 CHECK(headers_);
785 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || 762 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION ||
786 frame_type_ == PUSH_PROMISE) 763 frame_type_ == PUSH_PROMISE);
787 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
788 CHECK(end_); 764 CHECK(end_);
789 CHECK(!got_hpack_end_); 765 CHECK(!got_hpack_end_);
790 got_hpack_end_ = true; 766 got_hpack_end_ = true;
791 } 767 }
792 768
793 void SpdyTestDeframerImpl::OnHeaderBlockEnd( 769 void SpdyTestDeframerImpl::OnHeaderBlockEnd(
794 size_t /* header_bytes_parsed */, 770 size_t /* header_bytes_parsed */,
795 size_t /* compressed_header_bytes_parsed */) { 771 size_t /* compressed_header_bytes_parsed */) {
796 CHECK(headers_); 772 CHECK(headers_);
797 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION || 773 CHECK(frame_type_ == HEADERS || frame_type_ == CONTINUATION ||
798 frame_type_ == PUSH_PROMISE) 774 frame_type_ == PUSH_PROMISE);
799 << " frame_type_=" << Http2FrameTypeToString(frame_type_);
800 CHECK(end_); 775 CHECK(end_);
801 CHECK(!got_hpack_end_); 776 CHECK(!got_hpack_end_);
802 got_hpack_end_ = true; 777 got_hpack_end_ = true;
803 } 778 }
804 779
805 class LoggingSpdyDeframerDelegate : public SpdyDeframerVisitorInterface { 780 class LoggingSpdyDeframerDelegate : public SpdyDeframerVisitorInterface {
806 public: 781 public:
807 explicit LoggingSpdyDeframerDelegate( 782 explicit LoggingSpdyDeframerDelegate(
808 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped) 783 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped)
809 : wrapped_(std::move(wrapped)) { 784 : wrapped_(std::move(wrapped)) {
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 // The SpdyFramer will not process any more data at this point. 1024 // The SpdyFramer will not process any more data at this point.
1050 void DeframerCallbackCollector::OnError(SpdyFramer* framer, 1025 void DeframerCallbackCollector::OnError(SpdyFramer* framer,
1051 SpdyTestDeframer* deframer) { 1026 SpdyTestDeframer* deframer) {
1052 CollectedFrame cf; 1027 CollectedFrame cf;
1053 cf.error_reported = true; 1028 cf.error_reported = true;
1054 collected_frames_->push_back(std::move(cf)); 1029 collected_frames_->push_back(std::move(cf));
1055 } 1030 }
1056 1031
1057 } // namespace test 1032 } // namespace test
1058 } // namespace net 1033 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698