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

Side by Side Diff: net/quic/chromium/quic_http_stream.cc

Issue 2937113002: Fix QuicHttpStream reporting negative sent bytes. (Closed)
Patch Set: Oops Created 3 years, 6 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
OLDNEW
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/quic/chromium/quic_http_stream.h" 5 #include "net/quic/chromium/quic_http_stream.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 601
602 int QuicHttpStream::DoSendHeaders() { 602 int QuicHttpStream::DoSendHeaders() {
603 // Log the actual request with the URL Request's net log. 603 // Log the actual request with the URL Request's net log.
604 stream_net_log_.AddEvent( 604 stream_net_log_.AddEvent(
605 NetLogEventType::HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS, 605 NetLogEventType::HTTP_TRANSACTION_QUIC_SEND_REQUEST_HEADERS,
606 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_, 606 base::Bind(&QuicRequestNetLogCallback, stream_->id(), &request_headers_,
607 priority_)); 607 priority_));
608 bool has_upload_data = request_body_stream_ != nullptr; 608 bool has_upload_data = request_body_stream_ != nullptr;
609 609
610 next_state_ = STATE_SEND_HEADERS_COMPLETE; 610 next_state_ = STATE_SEND_HEADERS_COMPLETE;
611 size_t frame_len = stream_->WriteHeaders(std::move(request_headers_), 611 int rv = stream_->WriteHeaders(std::move(request_headers_), !has_upload_data,
612 !has_upload_data, nullptr); 612 nullptr);
613 headers_bytes_sent_ += frame_len; 613 if (rv > 0)
614 headers_bytes_sent_ += rv;
614 615
615 request_headers_ = SpdyHeaderBlock(); 616 request_headers_ = SpdyHeaderBlock();
616 return static_cast<int>(frame_len); 617 return rv;
617 } 618 }
618 619
619 int QuicHttpStream::DoSendHeadersComplete(int rv) { 620 int QuicHttpStream::DoSendHeadersComplete(int rv) {
620 if (rv < 0) 621 if (rv < 0)
621 return rv; 622 return rv;
622 623
623 next_state_ = request_body_stream_ ? STATE_READ_REQUEST_BODY : STATE_OPEN; 624 next_state_ = request_body_stream_ ? STATE_READ_REQUEST_BODY : STATE_OPEN;
624 625
625 return OK; 626 return OK;
626 } 627 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // Explicit stream error are always fatal. 805 // Explicit stream error are always fatal.
805 if (stream_->stream_error() != QUIC_STREAM_NO_ERROR && 806 if (stream_->stream_error() != QUIC_STREAM_NO_ERROR &&
806 stream_->stream_error() != QUIC_STREAM_CONNECTION_ERROR) { 807 stream_->stream_error() != QUIC_STREAM_CONNECTION_ERROR) {
807 return ERR_QUIC_PROTOCOL_ERROR; 808 return ERR_QUIC_PROTOCOL_ERROR;
808 } 809 }
809 810
810 return ERR_QUIC_PROTOCOL_ERROR; 811 return ERR_QUIC_PROTOCOL_ERROR;
811 } 812 }
812 813
813 } // namespace net 814 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/chromium/quic_http_stream_test.cc » ('j') | net/quic/chromium/quic_http_stream_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698