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

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

Issue 2840563003: Implement SpdyMakeUnique and SpdyWrapUnique. (Closed)
Patch Set: Created 3 years, 7 months 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
« no previous file with comments | « net/spdy/core/spdy_deframer_visitor.h ('k') | net/spdy/core/spdy_deframer_visitor_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/core/spdy_deframer_visitor.h" 5 #include "net/spdy/core/spdy_deframer_visitor.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cstdint> 10 #include <cstdint>
11 #include <limits> 11 #include <limits>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "net/spdy/core/hpack/hpack_constants.h" 15 #include "net/spdy/core/hpack/hpack_constants.h"
16 #include "net/spdy/core/mock_spdy_framer_visitor.h" 16 #include "net/spdy/core/mock_spdy_framer_visitor.h"
17 #include "net/spdy/core/spdy_frame_builder.h" 17 #include "net/spdy/core/spdy_frame_builder.h"
18 #include "net/spdy/core/spdy_frame_reader.h" 18 #include "net/spdy/core/spdy_frame_reader.h"
19 #include "net/spdy/core/spdy_protocol.h" 19 #include "net/spdy/core/spdy_protocol.h"
20 #include "net/spdy/core/spdy_test_utils.h" 20 #include "net/spdy/core/spdy_test_utils.h"
21 #include "net/spdy/platform/api/spdy_ptr_util.h"
22 #include "net/spdy/platform/api/spdy_string_piece.h"
21 23
22 using ::base::MakeUnique;
23 using ::testing::AssertionFailure; 24 using ::testing::AssertionFailure;
24 using ::testing::AssertionResult; 25 using ::testing::AssertionResult;
25 using ::testing::AssertionSuccess; 26 using ::testing::AssertionSuccess;
26 27
27 namespace net { 28 namespace net {
28 namespace test { 29 namespace test {
29 30
30 // Specify whether to process headers as request or response in visitor-related 31 // Specify whether to process headers as request or response in visitor-related
31 // params. 32 // params.
32 enum class HeaderDirection { REQUEST, RESPONSE }; 33 enum class HeaderDirection { REQUEST, RESPONSE };
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 232
232 private: 233 private:
233 std::unique_ptr<SpdyDeframerVisitorInterface> listener_; 234 std::unique_ptr<SpdyDeframerVisitorInterface> listener_;
234 235
235 DISALLOW_COPY_AND_ASSIGN(SpdyTestDeframerImpl); 236 DISALLOW_COPY_AND_ASSIGN(SpdyTestDeframerImpl);
236 }; 237 };
237 238
238 // static 239 // static
239 std::unique_ptr<SpdyTestDeframer> SpdyTestDeframer::CreateConverter( 240 std::unique_ptr<SpdyTestDeframer> SpdyTestDeframer::CreateConverter(
240 std::unique_ptr<SpdyDeframerVisitorInterface> listener) { 241 std::unique_ptr<SpdyDeframerVisitorInterface> listener) {
241 return MakeUnique<SpdyTestDeframerImpl>(std::move(listener)); 242 return SpdyMakeUnique<SpdyTestDeframerImpl>(std::move(listener));
242 } 243 }
243 244
244 void SpdyTestDeframerImpl::AtDataEnd() { 245 void SpdyTestDeframerImpl::AtDataEnd() {
245 DVLOG(1) << "AtDataEnd"; 246 DVLOG(1) << "AtDataEnd";
246 CHECK_EQ(data_len_, padding_len_ + data_->size()); 247 CHECK_EQ(data_len_, padding_len_ + data_->size());
247 auto ptr = MakeUnique<SpdyDataIR>(stream_id_, std::move(*data_)); 248 auto ptr = SpdyMakeUnique<SpdyDataIR>(stream_id_, std::move(*data_));
248 CHECK_EQ(0u, data_->size()); 249 CHECK_EQ(0u, data_->size());
249 data_.reset(); 250 data_.reset();
250 251
251 CHECK_LE(0u, padding_len_); 252 CHECK_LE(0u, padding_len_);
252 CHECK_LE(padding_len_, 256u); 253 CHECK_LE(padding_len_, 256u);
253 if (padding_len_ > 0) { 254 if (padding_len_ > 0) {
254 ptr->set_padding_len(padding_len_); 255 ptr->set_padding_len(padding_len_);
255 } 256 }
256 padding_len_ = 0; 257 padding_len_ = 0;
257 258
258 ptr->set_fin(fin_); 259 ptr->set_fin(fin_);
259 listener_->OnData(std::move(ptr)); 260 listener_->OnData(std::move(ptr));
260 frame_type_ = UNSET; 261 frame_type_ = UNSET;
261 fin_ = false; 262 fin_ = false;
262 data_len_ = 0; 263 data_len_ = 0;
263 } 264 }
264 265
265 void SpdyTestDeframerImpl::AtGoAwayEnd() { 266 void SpdyTestDeframerImpl::AtGoAwayEnd() {
266 DVLOG(1) << "AtDataEnd"; 267 DVLOG(1) << "AtDataEnd";
267 CHECK_EQ(frame_type_, GOAWAY); 268 CHECK_EQ(frame_type_, GOAWAY);
268 CHECK(goaway_description_); 269 CHECK(goaway_description_);
269 if (goaway_description_->empty()) { 270 if (goaway_description_->empty()) {
270 listener_->OnGoAway(std::move(goaway_ir_)); 271 listener_->OnGoAway(std::move(goaway_ir_));
271 } else { 272 } else {
272 listener_->OnGoAway(MakeUnique<SpdyGoAwayIR>( 273 listener_->OnGoAway(SpdyMakeUnique<SpdyGoAwayIR>(
273 goaway_ir_->last_good_stream_id(), goaway_ir_->error_code(), 274 goaway_ir_->last_good_stream_id(), goaway_ir_->error_code(),
274 std::move(*goaway_description_))); 275 std::move(*goaway_description_)));
275 CHECK_EQ(0u, goaway_description_->size()); 276 CHECK_EQ(0u, goaway_description_->size());
276 } 277 }
277 goaway_description_.reset(); 278 goaway_description_.reset();
278 goaway_ir_.reset(); 279 goaway_ir_.reset();
279 frame_type_ = UNSET; 280 frame_type_ = UNSET;
280 } 281 }
281 282
282 void SpdyTestDeframerImpl::AtHeadersEnd() { 283 void SpdyTestDeframerImpl::AtHeadersEnd() {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 // Overridden methods from SpdyFramerVisitorInterface in alpha order... 409 // Overridden methods from SpdyFramerVisitorInterface in alpha order...
409 410
410 void SpdyTestDeframerImpl::OnAltSvc( 411 void SpdyTestDeframerImpl::OnAltSvc(
411 SpdyStreamId stream_id, 412 SpdyStreamId stream_id,
412 SpdyStringPiece origin, 413 SpdyStringPiece origin,
413 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) { 414 const SpdyAltSvcWireFormat::AlternativeServiceVector& altsvc_vector) {
414 DVLOG(1) << "OnAltSvc stream_id: " << stream_id; 415 DVLOG(1) << "OnAltSvc stream_id: " << stream_id;
415 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 416 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
416 << Http2FrameTypeToString(frame_type_); 417 << Http2FrameTypeToString(frame_type_);
417 CHECK_GT(stream_id, 0u); 418 CHECK_GT(stream_id, 0u);
418 auto ptr = MakeUnique<SpdyAltSvcIR>(stream_id); 419 auto ptr = SpdyMakeUnique<SpdyAltSvcIR>(stream_id);
419 ptr->set_origin(SpdyString(origin)); 420 ptr->set_origin(SpdyString(origin));
420 for (auto& altsvc : altsvc_vector) { 421 for (auto& altsvc : altsvc_vector) {
421 ptr->add_altsvc(altsvc); 422 ptr->add_altsvc(altsvc);
422 } 423 }
423 listener_->OnAltSvc(std::move(ptr)); 424 listener_->OnAltSvc(std::move(ptr));
424 } 425 }
425 426
426 // A CONTINUATION frame contains a Header Block Fragment, and immediately 427 // A CONTINUATION frame contains a Header Block Fragment, and immediately
427 // follows another frame that contains a Header Block Fragment (HEADERS, 428 // follows another frame that contains a Header Block Fragment (HEADERS,
428 // PUSH_PROMISE or CONTINUATION). The last such frame has the END flag set. 429 // PUSH_PROMISE or CONTINUATION). The last such frame has the END flag set.
(...skipping 19 matching lines...) Expand all
448 DVLOG(1) << "OnDataFrameHeader stream_id: " << stream_id; 449 DVLOG(1) << "OnDataFrameHeader stream_id: " << stream_id;
449 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 450 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
450 << Http2FrameTypeToString(frame_type_); 451 << Http2FrameTypeToString(frame_type_);
451 CHECK_GT(stream_id, 0u); 452 CHECK_GT(stream_id, 0u);
452 CHECK_EQ(data_.get(), nullptr); 453 CHECK_EQ(data_.get(), nullptr);
453 frame_type_ = DATA; 454 frame_type_ = DATA;
454 455
455 stream_id_ = stream_id; 456 stream_id_ = stream_id;
456 fin_ = fin; 457 fin_ = fin;
457 data_len_ = length; 458 data_len_ = length;
458 data_.reset(new SpdyString()); 459 data_ = SpdyMakeUnique<SpdyString>();
459 } 460 }
460 461
461 // The SpdyFramer will not process any more data at this point. 462 // The SpdyFramer will not process any more data at this point.
462 void SpdyTestDeframerImpl::OnError(SpdyFramer* framer) { 463 void SpdyTestDeframerImpl::OnError(SpdyFramer* framer) {
463 DVLOG(1) << "SpdyFramer detected an error in the stream: " 464 DVLOG(1) << "SpdyFramer detected an error in the stream: "
464 << SpdyFramer::SpdyFramerErrorToString(framer->spdy_framer_error()) 465 << SpdyFramer::SpdyFramerErrorToString(framer->spdy_framer_error())
465 << " frame_type_: " << Http2FrameTypeToString(frame_type_); 466 << " frame_type_: " << Http2FrameTypeToString(frame_type_);
466 listener_->OnError(framer, this); 467 listener_->OnError(framer, this);
467 } 468 }
468 469
469 // Received a GOAWAY frame from the peer. The last stream id it accepted from us 470 // Received a GOAWAY frame from the peer. The last stream id it accepted from us
470 // is |last_accepted_stream_id|. |status| is a protocol defined error code. 471 // is |last_accepted_stream_id|. |status| is a protocol defined error code.
471 // The frame may also contain data. After this OnGoAwayFrameData will be called 472 // The frame may also contain data. After this OnGoAwayFrameData will be called
472 // for any non-zero amount of data, and after that it will be called with len==0 473 // for any non-zero amount of data, and after that it will be called with len==0
473 // to indicate the end of the GOAWAY frame. 474 // to indicate the end of the GOAWAY frame.
474 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id, 475 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id,
475 SpdyErrorCode error_code) { 476 SpdyErrorCode error_code) {
476 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id 477 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id
477 << " error code: " << error_code; 478 << " error code: " << error_code;
478 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 479 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
479 << Http2FrameTypeToString(frame_type_); 480 << Http2FrameTypeToString(frame_type_);
480 frame_type_ = GOAWAY; 481 frame_type_ = GOAWAY;
481 goaway_ir_ = MakeUnique<SpdyGoAwayIR>(last_good_stream_id, error_code, ""); 482 goaway_ir_ =
482 goaway_description_.reset(new SpdyString()); 483 SpdyMakeUnique<SpdyGoAwayIR>(last_good_stream_id, error_code, "");
484 goaway_description_ = SpdyMakeUnique<SpdyString>();
483 } 485 }
484 486
485 // If len==0 then we've reached the end of the GOAWAY frame. 487 // If len==0 then we've reached the end of the GOAWAY frame.
486 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data, 488 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data,
487 size_t len) { 489 size_t len) {
488 DVLOG(1) << "OnGoAwayFrameData"; 490 DVLOG(1) << "OnGoAwayFrameData";
489 CHECK_EQ(frame_type_, GOAWAY) << " frame_type_=" 491 CHECK_EQ(frame_type_, GOAWAY) << " frame_type_="
490 << Http2FrameTypeToString(frame_type_); 492 << Http2FrameTypeToString(frame_type_);
491 CHECK(goaway_description_); 493 CHECK(goaway_description_);
492 goaway_description_->append(goaway_data, len); 494 goaway_description_->append(goaway_data, len);
(...skipping 28 matching lines...) Expand all
521 DVLOG(1) << "OnHeaders stream_id: " << stream_id; 523 DVLOG(1) << "OnHeaders stream_id: " << stream_id;
522 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 524 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
523 << Http2FrameTypeToString(frame_type_); 525 << Http2FrameTypeToString(frame_type_);
524 CHECK_GT(stream_id, 0u); 526 CHECK_GT(stream_id, 0u);
525 frame_type_ = HEADERS; 527 frame_type_ = HEADERS;
526 528
527 stream_id_ = stream_id; 529 stream_id_ = stream_id;
528 fin_ = fin; 530 fin_ = fin;
529 end_ = end; 531 end_ = end;
530 532
531 headers_.reset(new StringPairVector()); 533 headers_ = SpdyMakeUnique<StringPairVector>();
532 headers_handler_.reset(new TestHeadersHandler()); 534 headers_handler_ = SpdyMakeUnique<TestHeadersHandler>();
533 headers_ir_ = MakeUnique<SpdyHeadersIR>(stream_id); 535 headers_ir_ = SpdyMakeUnique<SpdyHeadersIR>(stream_id);
534 headers_ir_->set_fin(fin); 536 headers_ir_->set_fin(fin);
535 if (has_priority) { 537 if (has_priority) {
536 headers_ir_->set_has_priority(true); 538 headers_ir_->set_has_priority(true);
537 headers_ir_->set_weight(weight); 539 headers_ir_->set_weight(weight);
538 headers_ir_->set_parent_stream_id(parent_stream_id); 540 headers_ir_->set_parent_stream_id(parent_stream_id);
539 headers_ir_->set_exclusive(exclusive); 541 headers_ir_->set_exclusive(exclusive);
540 } 542 }
541 } 543 }
542 544
543 // The HTTP/2 protocol refers to the payload, |unique_id| here, as 8 octets of 545 // The HTTP/2 protocol refers to the payload, |unique_id| here, as 8 octets of
544 // opaque data that is to be echoed back to the sender, with the ACK bit added. 546 // opaque data that is to be echoed back to the sender, with the ACK bit added.
545 // It isn't defined as a counter, 547 // It isn't defined as a counter,
546 // or frame id, as the SpdyPingId naming might imply. 548 // or frame id, as the SpdyPingId naming might imply.
547 // Responding to a PING is supposed to be at the highest priority. 549 // Responding to a PING is supposed to be at the highest priority.
548 void SpdyTestDeframerImpl::OnPing(uint64_t unique_id, bool is_ack) { 550 void SpdyTestDeframerImpl::OnPing(uint64_t unique_id, bool is_ack) {
549 DVLOG(1) << "OnPing unique_id: " << unique_id 551 DVLOG(1) << "OnPing unique_id: " << unique_id
550 << " is_ack: " << (is_ack ? "true" : "false"); 552 << " is_ack: " << (is_ack ? "true" : "false");
551 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 553 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
552 << Http2FrameTypeToString(frame_type_); 554 << Http2FrameTypeToString(frame_type_);
553 auto ptr = MakeUnique<SpdyPingIR>(unique_id); 555 auto ptr = SpdyMakeUnique<SpdyPingIR>(unique_id);
554 if (is_ack) { 556 if (is_ack) {
555 ptr->set_is_ack(is_ack); 557 ptr->set_is_ack(is_ack);
556 listener_->OnPingAck(std::move(ptr)); 558 listener_->OnPingAck(std::move(ptr));
557 } else { 559 } else {
558 listener_->OnPing(std::move(ptr)); 560 listener_->OnPing(std::move(ptr));
559 } 561 }
560 } 562 }
561 563
562 void SpdyTestDeframerImpl::OnPriority(SpdyStreamId stream_id, 564 void SpdyTestDeframerImpl::OnPriority(SpdyStreamId stream_id,
563 SpdyStreamId parent_stream_id, 565 SpdyStreamId parent_stream_id,
564 int weight, 566 int weight,
565 bool exclusive) { 567 bool exclusive) {
566 DVLOG(1) << "OnPriority stream_id: " << stream_id; 568 DVLOG(1) << "OnPriority stream_id: " << stream_id;
567 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 569 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
568 << Http2FrameTypeToString(frame_type_); 570 << Http2FrameTypeToString(frame_type_);
569 CHECK_GT(stream_id, 0u); 571 CHECK_GT(stream_id, 0u);
570 572
571 listener_->OnPriority(MakeUnique<SpdyPriorityIR>(stream_id, parent_stream_id, 573 listener_->OnPriority(SpdyMakeUnique<SpdyPriorityIR>(
572 weight, exclusive)); 574 stream_id, parent_stream_id, weight, exclusive));
573 } 575 }
574 576
575 void SpdyTestDeframerImpl::OnPushPromise(SpdyStreamId stream_id, 577 void SpdyTestDeframerImpl::OnPushPromise(SpdyStreamId stream_id,
576 SpdyStreamId promised_stream_id, 578 SpdyStreamId promised_stream_id,
577 bool end) { 579 bool end) {
578 DVLOG(1) << "OnPushPromise stream_id: " << stream_id; 580 DVLOG(1) << "OnPushPromise stream_id: " << stream_id;
579 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 581 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
580 << Http2FrameTypeToString(frame_type_); 582 << Http2FrameTypeToString(frame_type_);
581 CHECK_GT(stream_id, 0u); 583 CHECK_GT(stream_id, 0u);
582 584
583 frame_type_ = PUSH_PROMISE; 585 frame_type_ = PUSH_PROMISE;
584 stream_id_ = stream_id; 586 stream_id_ = stream_id;
585 end_ = end; 587 end_ = end;
586 588
587 headers_.reset(new StringPairVector()); 589 headers_ = SpdyMakeUnique<StringPairVector>();
588 headers_handler_.reset(new TestHeadersHandler()); 590 headers_handler_ = SpdyMakeUnique<TestHeadersHandler>();
589 push_promise_ir_ = 591 push_promise_ir_ =
590 MakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id); 592 SpdyMakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id);
591 } 593 }
592 594
593 // Closes the specified stream. After this the sender may still send PRIORITY 595 // Closes the specified stream. After this the sender may still send PRIORITY
594 // frames for this stream, which we can ignore. 596 // frames for this stream, which we can ignore.
595 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id, 597 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id,
596 SpdyErrorCode error_code) { 598 SpdyErrorCode error_code) {
597 DVLOG(1) << "OnRstStream stream_id: " << stream_id 599 DVLOG(1) << "OnRstStream stream_id: " << stream_id
598 << " error code: " << error_code; 600 << " error code: " << error_code;
599 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 601 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
600 << Http2FrameTypeToString(frame_type_); 602 << Http2FrameTypeToString(frame_type_);
601 CHECK_GT(stream_id, 0u); 603 CHECK_GT(stream_id, 0u);
602 604
603 listener_->OnRstStream(MakeUnique<SpdyRstStreamIR>(stream_id, error_code)); 605 listener_->OnRstStream(
606 SpdyMakeUnique<SpdyRstStreamIR>(stream_id, error_code));
604 } 607 }
605 608
606 // Called for an individual setting. There is no negotiation, the sender is 609 // Called for an individual setting. There is no negotiation, the sender is
607 // stating the value that the sender is using. 610 // stating the value that the sender is using.
608 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id, uint32_t value) { 611 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id, uint32_t value) {
609 DVLOG(1) << "OnSetting id: " << id << std::hex << " value: " << value; 612 DVLOG(1) << "OnSetting id: " << id << std::hex << " value: " << value;
610 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_=" 613 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_="
611 << Http2FrameTypeToString(frame_type_); 614 << Http2FrameTypeToString(frame_type_);
612 CHECK(settings_); 615 CHECK(settings_);
613 settings_->push_back(std::make_pair(id, value)); 616 settings_->push_back(std::make_pair(id, value));
614 settings_ir_->AddSetting(id, value); 617 settings_ir_->AddSetting(id, value);
615 } 618 }
616 619
617 // Called at the start of a SETTINGS frame with setting entries, but not the 620 // Called at the start of a SETTINGS frame with setting entries, but not the
618 // (required) ACK of a SETTINGS frame. There is no stream_id because 621 // (required) ACK of a SETTINGS frame. There is no stream_id because
619 // the settings apply to the entire connection, not to an individual stream. 622 // the settings apply to the entire connection, not to an individual stream.
620 // The |clear_persisted| flag is a pre-HTTP/2 remnant. 623 // The |clear_persisted| flag is a pre-HTTP/2 remnant.
621 void SpdyTestDeframerImpl::OnSettings(bool /*clear_persisted*/) { 624 void SpdyTestDeframerImpl::OnSettings(bool /*clear_persisted*/) {
622 DVLOG(1) << "OnSettings"; 625 DVLOG(1) << "OnSettings";
623 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 626 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
624 << Http2FrameTypeToString(frame_type_); 627 << Http2FrameTypeToString(frame_type_);
625 CHECK_EQ(nullptr, settings_ir_.get()); 628 CHECK_EQ(nullptr, settings_ir_.get());
626 CHECK_EQ(nullptr, settings_.get()); 629 CHECK_EQ(nullptr, settings_.get());
627 frame_type_ = SETTINGS; 630 frame_type_ = SETTINGS;
628 ack_ = false; 631 ack_ = false;
629 632
630 settings_.reset(new SettingVector()); 633 settings_ = SpdyMakeUnique<SettingVector>();
631 settings_ir_.reset(new SpdySettingsIR()); 634 settings_ir_ = SpdyMakeUnique<SpdySettingsIR>();
632 } 635 }
633 636
634 void SpdyTestDeframerImpl::OnSettingsAck() { 637 void SpdyTestDeframerImpl::OnSettingsAck() {
635 DVLOG(1) << "OnSettingsAck"; 638 DVLOG(1) << "OnSettingsAck";
636 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 639 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
637 << Http2FrameTypeToString(frame_type_); 640 << Http2FrameTypeToString(frame_type_);
638 auto ptr = MakeUnique<SpdySettingsIR>(); 641 auto ptr = SpdyMakeUnique<SpdySettingsIR>();
639 ptr->set_is_ack(true); 642 ptr->set_is_ack(true);
640 listener_->OnSettingsAck(std::move(ptr)); 643 listener_->OnSettingsAck(std::move(ptr));
641 } 644 }
642 645
643 void SpdyTestDeframerImpl::OnSettingsEnd() { 646 void SpdyTestDeframerImpl::OnSettingsEnd() {
644 DVLOG(1) << "OnSettingsEnd"; 647 DVLOG(1) << "OnSettingsEnd";
645 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_=" 648 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_="
646 << Http2FrameTypeToString(frame_type_); 649 << Http2FrameTypeToString(frame_type_);
647 CHECK(!ack_); 650 CHECK(!ack_);
648 CHECK_NE(nullptr, settings_ir_.get()); 651 CHECK_NE(nullptr, settings_ir_.get());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 // closed. 703 // closed.
701 void SpdyTestDeframerImpl::OnWindowUpdate(SpdyStreamId stream_id, 704 void SpdyTestDeframerImpl::OnWindowUpdate(SpdyStreamId stream_id,
702 int delta_window_size) { 705 int delta_window_size) {
703 DVLOG(1) << "OnWindowUpdate stream_id: " << stream_id 706 DVLOG(1) << "OnWindowUpdate stream_id: " << stream_id
704 << " delta_window_size: " << delta_window_size; 707 << " delta_window_size: " << delta_window_size;
705 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 708 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
706 << Http2FrameTypeToString(frame_type_); 709 << Http2FrameTypeToString(frame_type_);
707 CHECK_NE(0, delta_window_size); 710 CHECK_NE(0, delta_window_size);
708 711
709 listener_->OnWindowUpdate( 712 listener_->OnWindowUpdate(
710 MakeUnique<SpdyWindowUpdateIR>(stream_id, delta_window_size)); 713 SpdyMakeUnique<SpdyWindowUpdateIR>(stream_id, delta_window_size));
711 } 714 }
712 715
713 // Return true to indicate that the stream_id is valid; if not valid then 716 // Return true to indicate that the stream_id is valid; if not valid then
714 // SpdyFramer considers the connection corrupted. Requires keeping track 717 // SpdyFramer considers the connection corrupted. Requires keeping track
715 // of the set of currently open streams. For now we'll assume that unknown 718 // of the set of currently open streams. For now we'll assume that unknown
716 // frame types are unsupported. 719 // frame types are unsupported.
717 bool SpdyTestDeframerImpl::OnUnknownFrame(SpdyStreamId stream_id, 720 bool SpdyTestDeframerImpl::OnUnknownFrame(SpdyStreamId stream_id,
718 uint8_t frame_type) { 721 uint8_t frame_type) {
719 DVLOG(1) << "OnAltSvc stream_id: " << stream_id; 722 DVLOG(1) << "OnAltSvc stream_id: " << stream_id;
720 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 723 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 CHECK(!got_hpack_end_); 771 CHECK(!got_hpack_end_);
769 got_hpack_end_ = true; 772 got_hpack_end_ = true;
770 } 773 }
771 774
772 class LoggingSpdyDeframerDelegate : public SpdyDeframerVisitorInterface { 775 class LoggingSpdyDeframerDelegate : public SpdyDeframerVisitorInterface {
773 public: 776 public:
774 explicit LoggingSpdyDeframerDelegate( 777 explicit LoggingSpdyDeframerDelegate(
775 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped) 778 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped)
776 : wrapped_(std::move(wrapped)) { 779 : wrapped_(std::move(wrapped)) {
777 if (!wrapped_) { 780 if (!wrapped_) {
778 wrapped_ = MakeUnique<SpdyDeframerVisitorInterface>(); 781 wrapped_ = SpdyMakeUnique<SpdyDeframerVisitorInterface>();
779 } 782 }
780 } 783 }
781 ~LoggingSpdyDeframerDelegate() override {} 784 ~LoggingSpdyDeframerDelegate() override {}
782 785
783 void OnAltSvc(std::unique_ptr<SpdyAltSvcIR> frame) override { 786 void OnAltSvc(std::unique_ptr<SpdyAltSvcIR> frame) override {
784 DVLOG(1) << "LoggingSpdyDeframerDelegate::OnAltSvc"; 787 DVLOG(1) << "LoggingSpdyDeframerDelegate::OnAltSvc";
785 wrapped_->OnAltSvc(std::move(frame)); 788 wrapped_->OnAltSvc(std::move(frame));
786 } 789 }
787 void OnData(std::unique_ptr<SpdyDataIR> frame) override { 790 void OnData(std::unique_ptr<SpdyDataIR> frame) override {
788 DVLOG(1) << "LoggingSpdyDeframerDelegate::OnData"; 791 DVLOG(1) << "LoggingSpdyDeframerDelegate::OnData";
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 } 861 }
859 862
860 private: 863 private:
861 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped_; 864 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped_;
862 }; 865 };
863 866
864 // static 867 // static
865 std::unique_ptr<SpdyDeframerVisitorInterface> 868 std::unique_ptr<SpdyDeframerVisitorInterface>
866 SpdyDeframerVisitorInterface::LogBeforeVisiting( 869 SpdyDeframerVisitorInterface::LogBeforeVisiting(
867 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped_listener) { 870 std::unique_ptr<SpdyDeframerVisitorInterface> wrapped_listener) {
868 return MakeUnique<LoggingSpdyDeframerDelegate>(std::move(wrapped_listener)); 871 return SpdyMakeUnique<LoggingSpdyDeframerDelegate>(
872 std::move(wrapped_listener));
869 } 873 }
870 874
871 CollectedFrame::CollectedFrame() {} 875 CollectedFrame::CollectedFrame() {}
872 876
873 CollectedFrame::CollectedFrame(CollectedFrame&& other) 877 CollectedFrame::CollectedFrame(CollectedFrame&& other)
874 : frame_ir(std::move(other.frame_ir)), 878 : frame_ir(std::move(other.frame_ir)),
875 headers(std::move(other.headers)), 879 headers(std::move(other.headers)),
876 settings(std::move(other.settings)), 880 settings(std::move(other.settings)),
877 error_reported(other.error_reported) {} 881 error_reported(other.error_reported) {}
878 882
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 // The SpdyFramer will not process any more data at this point. 1020 // The SpdyFramer will not process any more data at this point.
1017 void DeframerCallbackCollector::OnError(SpdyFramer* framer, 1021 void DeframerCallbackCollector::OnError(SpdyFramer* framer,
1018 SpdyTestDeframer* deframer) { 1022 SpdyTestDeframer* deframer) {
1019 CollectedFrame cf; 1023 CollectedFrame cf;
1020 cf.error_reported = true; 1024 cf.error_reported = true;
1021 collected_frames_->push_back(std::move(cf)); 1025 collected_frames_->push_back(std::move(cf));
1022 } 1026 }
1023 1027
1024 } // namespace test 1028 } // namespace test
1025 } // namespace net 1029 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/core/spdy_deframer_visitor.h ('k') | net/spdy/core/spdy_deframer_visitor_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698