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

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

Issue 2675593002: Spdy{RstStream,GoAway}Status -> SpdyErrorCode. (Closed)
Patch Set: Merged master, which includes 145087791. Created 3 years, 10 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/mock_spdy_framer_visitor.h ('k') | net/spdy/spdy_framer.h » ('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/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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 void OnBlocked(SpdyStreamId stream_id) override; 144 void OnBlocked(SpdyStreamId stream_id) override;
145 void OnContinuation(SpdyStreamId stream_id, bool end) override; 145 void OnContinuation(SpdyStreamId stream_id, bool end) override;
146 SpdyHeadersHandlerInterface* OnHeaderFrameStart( 146 SpdyHeadersHandlerInterface* OnHeaderFrameStart(
147 SpdyStreamId stream_id) override; 147 SpdyStreamId stream_id) override;
148 void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override; 148 void OnHeaderFrameEnd(SpdyStreamId stream_id, bool end_headers) override;
149 void OnDataFrameHeader(SpdyStreamId stream_id, 149 void OnDataFrameHeader(SpdyStreamId stream_id,
150 size_t length, 150 size_t length,
151 bool fin) override; 151 bool fin) override;
152 void OnError(SpdyFramer* framer) override; 152 void OnError(SpdyFramer* framer) override;
153 void OnGoAway(SpdyStreamId last_accepted_stream_id, 153 void OnGoAway(SpdyStreamId last_accepted_stream_id,
154 SpdyGoAwayStatus status) override; 154 SpdyErrorCode error_code) override;
155 bool OnGoAwayFrameData(const char* goaway_data, size_t len) override; 155 bool OnGoAwayFrameData(const char* goaway_data, size_t len) override;
156 void OnHeaders(SpdyStreamId stream_id, 156 void OnHeaders(SpdyStreamId stream_id,
157 bool has_priority, 157 bool has_priority,
158 int weight, 158 int weight,
159 SpdyStreamId parent_stream_id, 159 SpdyStreamId parent_stream_id,
160 bool exclusive, 160 bool exclusive,
161 bool fin, 161 bool fin,
162 bool end) override; 162 bool end) override;
163 void OnPing(SpdyPingId unique_id, bool is_ack) override; 163 void OnPing(SpdyPingId unique_id, bool is_ack) override;
164 void OnPriority(SpdyStreamId stream_id, 164 void OnPriority(SpdyStreamId stream_id,
165 SpdyStreamId parent_stream_id, 165 SpdyStreamId parent_stream_id,
166 int weight, 166 int weight,
167 bool exclusive) override; 167 bool exclusive) override;
168 void OnPushPromise(SpdyStreamId stream_id, 168 void OnPushPromise(SpdyStreamId stream_id,
169 SpdyStreamId promised_stream_id, 169 SpdyStreamId promised_stream_id,
170 bool end) override; 170 bool end) override;
171 void OnRstStream(SpdyStreamId stream_id, SpdyRstStreamStatus status) override; 171 void OnRstStream(SpdyStreamId stream_id, SpdyErrorCode error_code) override;
172 void OnSetting(SpdySettingsIds id, uint32_t value) override; 172 void OnSetting(SpdySettingsIds id, uint32_t value) override;
173 void OnSettings(bool clear_persisted) override; 173 void OnSettings(bool clear_persisted) override;
174 void OnSettingsAck() override; 174 void OnSettingsAck() override;
175 void OnSettingsEnd() override; 175 void OnSettingsEnd() override;
176 void OnStreamFrameData(SpdyStreamId stream_id, 176 void OnStreamFrameData(SpdyStreamId stream_id,
177 const char* data, 177 const char* data,
178 size_t len) override; 178 size_t len) override;
179 void OnStreamEnd(SpdyStreamId stream_id) override; 179 void OnStreamEnd(SpdyStreamId stream_id) override;
180 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override; 180 void OnStreamPadding(SpdyStreamId stream_id, size_t len) override;
181 bool OnUnknownFrame(SpdyStreamId stream_id, uint8_t frame_type) override; 181 bool OnUnknownFrame(SpdyStreamId stream_id, uint8_t frame_type) override;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 268
269 void SpdyTestDeframerImpl::AtGoAwayEnd() { 269 void SpdyTestDeframerImpl::AtGoAwayEnd() {
270 DVLOG(1) << "AtDataEnd"; 270 DVLOG(1) << "AtDataEnd";
271 CHECK_EQ(frame_type_, GOAWAY); 271 CHECK_EQ(frame_type_, GOAWAY);
272 CHECK(goaway_description_); 272 CHECK(goaway_description_);
273 if (goaway_description_->empty()) { 273 if (goaway_description_->empty()) {
274 listener_->OnGoAway(std::move(goaway_ir_)); 274 listener_->OnGoAway(std::move(goaway_ir_));
275 } else { 275 } else {
276 listener_->OnGoAway(MakeUnique<SpdyGoAwayIR>( 276 listener_->OnGoAway(MakeUnique<SpdyGoAwayIR>(
277 goaway_ir_->last_good_stream_id(), goaway_ir_->status(), 277 goaway_ir_->last_good_stream_id(), goaway_ir_->error_code(),
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";
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 << " frame_type_: " << Http2FrameTypeToString(frame_type_); 485 << " frame_type_: " << Http2FrameTypeToString(frame_type_);
486 listener_->OnError(framer, this); 486 listener_->OnError(framer, this);
487 } 487 }
488 488
489 // Received a GOAWAY frame from the peer. The last stream id it accepted from us 489 // 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. 490 // 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 491 // 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 492 // 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. 493 // to indicate the end of the GOAWAY frame.
494 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id, 494 void SpdyTestDeframerImpl::OnGoAway(SpdyStreamId last_good_stream_id,
495 SpdyGoAwayStatus status) { 495 SpdyErrorCode error_code) {
496 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id 496 DVLOG(1) << "OnGoAway last_good_stream_id: " << last_good_stream_id
497 << " status: " << status; 497 << " error code: " << error_code;
498 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 498 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
499 << Http2FrameTypeToString(frame_type_); 499 << Http2FrameTypeToString(frame_type_);
500 frame_type_ = GOAWAY; 500 frame_type_ = GOAWAY;
501 goaway_ir_ = MakeUnique<SpdyGoAwayIR>(last_good_stream_id, status, ""); 501 goaway_ir_ = MakeUnique<SpdyGoAwayIR>(last_good_stream_id, error_code, "");
502 goaway_description_.reset(new string()); 502 goaway_description_.reset(new string());
503 } 503 }
504 504
505 // If len==0 then we've reached the end of the GOAWAY frame. 505 // If len==0 then we've reached the end of the GOAWAY frame.
506 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data, 506 bool SpdyTestDeframerImpl::OnGoAwayFrameData(const char* goaway_data,
507 size_t len) { 507 size_t len) {
508 DVLOG(1) << "OnGoAwayFrameData"; 508 DVLOG(1) << "OnGoAwayFrameData";
509 CHECK_EQ(frame_type_, GOAWAY) << " frame_type_=" 509 CHECK_EQ(frame_type_, GOAWAY) << " frame_type_="
510 << Http2FrameTypeToString(frame_type_); 510 << Http2FrameTypeToString(frame_type_);
511 CHECK(goaway_description_); 511 CHECK(goaway_description_);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 606
607 headers_.reset(new StringPairVector()); 607 headers_.reset(new StringPairVector());
608 headers_handler_.reset(new TestHeadersHandler()); 608 headers_handler_.reset(new TestHeadersHandler());
609 push_promise_ir_ = 609 push_promise_ir_ =
610 MakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id); 610 MakeUnique<SpdyPushPromiseIR>(stream_id, promised_stream_id);
611 } 611 }
612 612
613 // Closes the specified stream. After this the sender may still send PRIORITY 613 // Closes the specified stream. After this the sender may still send PRIORITY
614 // frames for this stream, which we can ignore. 614 // frames for this stream, which we can ignore.
615 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id, 615 void SpdyTestDeframerImpl::OnRstStream(SpdyStreamId stream_id,
616 SpdyRstStreamStatus status) { 616 SpdyErrorCode error_code) {
617 DVLOG(1) << "OnRstStream stream_id: " << stream_id 617 DVLOG(1) << "OnRstStream stream_id: " << stream_id
618 << " status: " << status; 618 << " error code: " << error_code;
619 CHECK_EQ(frame_type_, UNSET) << " frame_type_=" 619 CHECK_EQ(frame_type_, UNSET) << " frame_type_="
620 << Http2FrameTypeToString(frame_type_); 620 << Http2FrameTypeToString(frame_type_);
621 CHECK_GT(stream_id, 0u); 621 CHECK_GT(stream_id, 0u);
622 622
623 listener_->OnRstStream(MakeUnique<SpdyRstStreamIR>(stream_id, status)); 623 listener_->OnRstStream(MakeUnique<SpdyRstStreamIR>(stream_id, error_code));
624 } 624 }
625 625
626 // Called for an individual setting. There is no negotiation, the sender is 626 // Called for an individual setting. There is no negotiation, the sender is
627 // stating the value that the sender is using. 627 // stating the value that the sender is using.
628 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id, uint32_t value) { 628 void SpdyTestDeframerImpl::OnSetting(SpdySettingsIds id, uint32_t value) {
629 DVLOG(1) << "OnSetting id: " << id << std::hex << " value: " << value; 629 DVLOG(1) << "OnSetting id: " << id << std::hex << " value: " << value;
630 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_=" 630 CHECK_EQ(frame_type_, SETTINGS) << " frame_type_="
631 << Http2FrameTypeToString(frame_type_); 631 << Http2FrameTypeToString(frame_type_);
632 CHECK(settings_); 632 CHECK(settings_);
633 settings_->push_back(std::make_pair(id, value)); 633 settings_->push_back(std::make_pair(id, value));
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 // The SpdyFramer will not process any more data at this point. 1035 // The SpdyFramer will not process any more data at this point.
1036 void DeframerCallbackCollector::OnError(SpdyFramer* framer, 1036 void DeframerCallbackCollector::OnError(SpdyFramer* framer,
1037 SpdyTestDeframer* deframer) { 1037 SpdyTestDeframer* deframer) {
1038 CollectedFrame cf; 1038 CollectedFrame cf;
1039 cf.error_reported = true; 1039 cf.error_reported = true;
1040 collected_frames_->push_back(std::move(cf)); 1040 collected_frames_->push_back(std::move(cf));
1041 } 1041 }
1042 1042
1043 } // namespace test 1043 } // namespace test
1044 } // namespace net 1044 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/mock_spdy_framer_visitor.h ('k') | net/spdy/spdy_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698