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

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

Issue 2677883002: QUIC: Do not count the duplicate received bytes in GetTotalReceivedBytes (Closed)
Patch Set: use sequencer 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/quic/chromium/quic_chromium_client_stream.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/metrics/histogram_macros.h" 11 #include "base/metrics/histogram_macros.h"
12 #include "base/strings/string_split.h" 12 #include "base/strings/string_split.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "net/base/load_flags.h" 14 #include "net/base/load_flags.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "net/http/http_response_headers.h" 16 #include "net/http/http_response_headers.h"
17 #include "net/http/http_util.h" 17 #include "net/http/http_util.h"
18 #include "net/log/net_log_event_type.h" 18 #include "net/log/net_log_event_type.h"
19 #include "net/log/net_log_source.h" 19 #include "net/log/net_log_source.h"
20 #include "net/quic/chromium/quic_http_utils.h" 20 #include "net/quic/chromium/quic_http_utils.h"
21 #include "net/quic/core/quic_client_promised_info.h" 21 #include "net/quic/core/quic_client_promised_info.h"
22 #include "net/quic/core/quic_stream_sequencer.h"
22 #include "net/quic/core/quic_utils.h" 23 #include "net/quic/core/quic_utils.h"
23 #include "net/quic/core/spdy_utils.h" 24 #include "net/quic/core/spdy_utils.h"
24 #include "net/spdy/spdy_frame_builder.h" 25 #include "net/spdy/spdy_frame_builder.h"
25 #include "net/spdy/spdy_framer.h" 26 #include "net/spdy/spdy_framer.h"
26 #include "net/spdy/spdy_http_utils.h" 27 #include "net/spdy/spdy_http_utils.h"
27 #include "net/ssl/ssl_info.h" 28 #include "net/ssl/ssl_info.h"
28 29
29 namespace net { 30 namespace net {
30 31
31 namespace { 32 namespace {
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 bool QuicHttpStream::IsConnectionReused() const { 370 bool QuicHttpStream::IsConnectionReused() const {
370 // TODO(rch): do something smarter here. 371 // TODO(rch): do something smarter here.
371 return stream_ && stream_->id() > 1; 372 return stream_ && stream_->id() > 1;
372 } 373 }
373 374
374 int64_t QuicHttpStream::GetTotalReceivedBytes() const { 375 int64_t QuicHttpStream::GetTotalReceivedBytes() const {
375 // TODO(sclittle): Currently, this only includes headers and response body 376 // TODO(sclittle): Currently, this only includes headers and response body
376 // bytes. Change this to include QUIC overhead as well. 377 // bytes. Change this to include QUIC overhead as well.
377 int64_t total_received_bytes = headers_bytes_received_; 378 int64_t total_received_bytes = headers_bytes_received_;
378 if (stream_) { 379 if (stream_) {
379 total_received_bytes += stream_->stream_bytes_read(); 380 DCHECK_LE(stream_->sequencer()->NumBytesConsumed(),
381 stream_->stream_bytes_read());
382 // Only count the uniquely received bytes.
383 total_received_bytes += stream_->sequencer()->NumBytesConsumed();
380 } else { 384 } else {
381 total_received_bytes += closed_stream_received_bytes_; 385 total_received_bytes += closed_stream_received_bytes_;
382 } 386 }
383 return total_received_bytes; 387 return total_received_bytes;
384 } 388 }
385 389
386 int64_t QuicHttpStream::GetTotalSentBytes() const { 390 int64_t QuicHttpStream::GetTotalSentBytes() const {
387 // TODO(sclittle): Currently, this only includes request headers and body 391 // TODO(sclittle): Currently, this only includes request headers and body
388 // bytes. Change this to include QUIC overhead as well. 392 // bytes. Change this to include QUIC overhead as well.
389 int64_t total_sent_bytes = headers_bytes_sent_; 393 int64_t total_sent_bytes = headers_bytes_sent_;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 return rv; 809 return rv;
806 } 810 }
807 811
808 void QuicHttpStream::ResetStream() { 812 void QuicHttpStream::ResetStream() {
809 if (push_handle_) { 813 if (push_handle_) {
810 push_handle_->Cancel(); 814 push_handle_->Cancel();
811 push_handle_ = nullptr; 815 push_handle_ = nullptr;
812 } 816 }
813 if (!stream_) 817 if (!stream_)
814 return; 818 return;
815 closed_stream_received_bytes_ = stream_->stream_bytes_read(); 819 DCHECK_LE(stream_->sequencer()->NumBytesConsumed(),
820 stream_->stream_bytes_read());
821 // Only count the uniquely received bytes.
822 closed_stream_received_bytes_ = stream_->sequencer()->NumBytesConsumed();
816 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); 823 closed_stream_sent_bytes_ = stream_->stream_bytes_written();
817 closed_is_first_stream_ = stream_->IsFirstStream(); 824 closed_is_first_stream_ = stream_->IsFirstStream();
818 stream_ = nullptr; 825 stream_ = nullptr;
819 826
820 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress 827 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress
821 // read. 828 // read.
822 if (request_body_stream_) 829 if (request_body_stream_)
823 request_body_stream_->Reset(); 830 request_body_stream_->Reset();
824 } 831 }
825 832
826 } // namespace net 833 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_chromium_client_stream.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698