| OLD | NEW |
| 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/quic_http_stream.h" | 5 #include "net/quic/quic_http_stream.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #ifdef TEMP_INSTRUMENTATION_468529 | 8 #ifdef TEMP_INSTRUMENTATION_468529 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #endif | 10 #endif |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 session_error_(OK), | 34 session_error_(OK), |
| 35 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), | 35 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), |
| 36 stream_(nullptr), | 36 stream_(nullptr), |
| 37 request_info_(nullptr), | 37 request_info_(nullptr), |
| 38 request_body_stream_(nullptr), | 38 request_body_stream_(nullptr), |
| 39 priority_(MINIMUM_PRIORITY), | 39 priority_(MINIMUM_PRIORITY), |
| 40 response_info_(nullptr), | 40 response_info_(nullptr), |
| 41 response_status_(OK), | 41 response_status_(OK), |
| 42 response_headers_received_(false), | 42 response_headers_received_(false), |
| 43 closed_stream_received_bytes_(0), | 43 closed_stream_received_bytes_(0), |
| 44 closed_stream_sent_bytes_(0), |
| 44 user_buffer_len_(0), | 45 user_buffer_len_(0), |
| 45 weak_factory_(this) { | 46 weak_factory_(this) { |
| 46 DCHECK(session_); | 47 DCHECK(session_); |
| 47 session_->AddObserver(this); | 48 session_->AddObserver(this); |
| 48 } | 49 } |
| 49 | 50 |
| 50 QuicHttpStream::~QuicHttpStream() { | 51 QuicHttpStream::~QuicHttpStream() { |
| 51 #ifdef TEMP_INSTRUMENTATION_468529 | 52 #ifdef TEMP_INSTRUMENTATION_468529 |
| 52 liveness_ = DEAD; | 53 liveness_ = DEAD; |
| 53 stack_trace_ = base::debug::StackTrace(); | 54 stack_trace_ = base::debug::StackTrace(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 void QuicHttpStream::SetConnectionReused() { | 247 void QuicHttpStream::SetConnectionReused() { |
| 247 // QUIC doesn't need an indicator here. | 248 // QUIC doesn't need an indicator here. |
| 248 } | 249 } |
| 249 | 250 |
| 250 bool QuicHttpStream::CanReuseConnection() const { | 251 bool QuicHttpStream::CanReuseConnection() const { |
| 251 // QUIC streams aren't considered reusable. | 252 // QUIC streams aren't considered reusable. |
| 252 return false; | 253 return false; |
| 253 } | 254 } |
| 254 | 255 |
| 255 int64 QuicHttpStream::GetTotalReceivedBytes() const { | 256 int64 QuicHttpStream::GetTotalReceivedBytes() const { |
| 257 // TODO(sclittle): Currently, this only includes response body bytes. Change |
| 258 // this to include headers and QUIC overhead as well. |
| 256 if (stream_) { | 259 if (stream_) { |
| 257 return stream_->stream_bytes_read(); | 260 return stream_->stream_bytes_read(); |
| 258 } | 261 } |
| 259 | 262 |
| 260 return closed_stream_received_bytes_; | 263 return closed_stream_received_bytes_; |
| 261 } | 264 } |
| 262 | 265 |
| 263 int64_t QuicHttpStream::GetTotalSentBytes() const { | 266 int64_t QuicHttpStream::GetTotalSentBytes() const { |
| 264 // TODO(sclittle): Implement this for real. http://crbug.com/518897. | 267 // TODO(sclittle): Currently, this only includes request body bytes. Change |
| 265 return 0; | 268 // this to include headers and QUIC overhead as well. |
| 269 if (stream_) { |
| 270 return stream_->stream_bytes_written(); |
| 271 } |
| 272 |
| 273 return closed_stream_sent_bytes_; |
| 266 } | 274 } |
| 267 | 275 |
| 268 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { | 276 bool QuicHttpStream::GetLoadTimingInfo(LoadTimingInfo* load_timing_info) const { |
| 269 // TODO(mmenke): Figure out what to do here. | 277 // TODO(mmenke): Figure out what to do here. |
| 270 return true; | 278 return true; |
| 271 } | 279 } |
| 272 | 280 |
| 273 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { | 281 void QuicHttpStream::GetSSLInfo(SSLInfo* ssl_info) { |
| 274 DCHECK(stream_); | 282 DCHECK(stream_); |
| 275 session_->GetSSLInfo(ssl_info); | 283 session_->GetSSLInfo(ssl_info); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 548 } |
| 541 | 549 |
| 542 SpdyMajorVersion QuicHttpStream::GetSpdyVersion() { | 550 SpdyMajorVersion QuicHttpStream::GetSpdyVersion() { |
| 543 return SpdyUtils::GetSpdyVersionForQuicVersion(stream_->version()); | 551 return SpdyUtils::GetSpdyVersionForQuicVersion(stream_->version()); |
| 544 } | 552 } |
| 545 | 553 |
| 546 void QuicHttpStream::ResetStream() { | 554 void QuicHttpStream::ResetStream() { |
| 547 if (!stream_) | 555 if (!stream_) |
| 548 return; | 556 return; |
| 549 closed_stream_received_bytes_ = stream_->stream_bytes_read(); | 557 closed_stream_received_bytes_ = stream_->stream_bytes_read(); |
| 558 closed_stream_sent_bytes_ = stream_->stream_bytes_written(); |
| 550 stream_ = nullptr; | 559 stream_ = nullptr; |
| 551 | 560 |
| 552 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress | 561 // If |request_body_stream_| is non-NULL, Reset it, to abort any in progress |
| 553 // read. | 562 // read. |
| 554 if (request_body_stream_) | 563 if (request_body_stream_) |
| 555 request_body_stream_->Reset(); | 564 request_body_stream_->Reset(); |
| 556 } | 565 } |
| 557 | 566 |
| 558 void QuicHttpStream::CrashIfInvalid() const { | 567 void QuicHttpStream::CrashIfInvalid() const { |
| 559 #ifdef TEMP_INSTRUMENTATION_468529 | 568 #ifdef TEMP_INSTRUMENTATION_468529 |
| 560 Liveness liveness = liveness_; | 569 Liveness liveness = liveness_; |
| 561 | 570 |
| 562 if (liveness == ALIVE) | 571 if (liveness == ALIVE) |
| 563 return; | 572 return; |
| 564 | 573 |
| 565 // Copy relevant variables onto the stack to guarantee they will be available | 574 // Copy relevant variables onto the stack to guarantee they will be available |
| 566 // in minidumps, and then crash. | 575 // in minidumps, and then crash. |
| 567 base::debug::StackTrace stack_trace = stack_trace_; | 576 base::debug::StackTrace stack_trace = stack_trace_; |
| 568 | 577 |
| 569 base::debug::Alias(&liveness); | 578 base::debug::Alias(&liveness); |
| 570 base::debug::Alias(&stack_trace); | 579 base::debug::Alias(&stack_trace); |
| 571 | 580 |
| 572 CHECK_EQ(ALIVE, liveness); | 581 CHECK_EQ(ALIVE, liveness); |
| 573 #endif | 582 #endif |
| 574 } | 583 } |
| 575 | 584 |
| 576 } // namespace net | 585 } // namespace net |
| OLD | NEW |