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

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

Issue 2789093003: Mark QUIC broken when the network blackholes after the handshake (Closed)
Patch Set: jana's comments Created 3 years, 8 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 QuicHttpStream::QuicHttpStream( 47 QuicHttpStream::QuicHttpStream(
48 const base::WeakPtr<QuicChromiumClientSession>& session, 48 const base::WeakPtr<QuicChromiumClientSession>& session,
49 HttpServerProperties* http_server_properties) 49 HttpServerProperties* http_server_properties)
50 : MultiplexedHttpStream(MultiplexedSessionHandle(session)), 50 : MultiplexedHttpStream(MultiplexedSessionHandle(session)),
51 next_state_(STATE_NONE), 51 next_state_(STATE_NONE),
52 session_(session), 52 session_(session),
53 server_id_(session->server_id()),
53 http_server_properties_(http_server_properties), 54 http_server_properties_(http_server_properties),
54 quic_version_(session->GetQuicVersion()), 55 quic_version_(session->GetQuicVersion()),
55 session_error_(ERR_UNEXPECTED), 56 session_error_(ERR_UNEXPECTED),
56 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()), 57 was_handshake_confirmed_(session->IsCryptoHandshakeConfirmed()),
57 stream_(nullptr), 58 stream_(nullptr),
58 request_info_(nullptr), 59 request_info_(nullptr),
59 request_body_stream_(nullptr), 60 request_body_stream_(nullptr),
60 priority_(MINIMUM_PRIORITY), 61 priority_(MINIMUM_PRIORITY),
61 response_info_(nullptr), 62 response_info_(nullptr),
62 has_response_status_(false), 63 has_response_status_(false),
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 316
316 return rv > 0 ? OK : rv; 317 return rv > 0 ? OK : rv;
317 } 318 }
318 319
319 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) { 320 int QuicHttpStream::ReadResponseHeaders(const CompletionCallback& callback) {
320 CHECK(callback_.is_null()); 321 CHECK(callback_.is_null());
321 CHECK(!callback.is_null()); 322 CHECK(!callback.is_null());
322 323
323 if (stream_ == nullptr) 324 if (stream_ == nullptr)
324 return GetResponseStatus(); 325 return GetResponseStatus();
325
326 // Check if we already have the response headers. If so, return synchronously. 326 // Check if we already have the response headers. If so, return synchronously.
327 if (response_headers_received_) 327 if (response_headers_received_)
328 return OK; 328 return OK;
329 329
330 // Still waiting for the response, return IO_PENDING. 330 // Still waiting for the response, return IO_PENDING.
331 CHECK(callback_.is_null()); 331 CHECK(callback_.is_null());
332 callback_ = callback; 332 callback_ = callback;
333 return ERR_IO_PENDING; 333 return ERR_IO_PENDING;
334 } 334 }
335 335
(...skipping 21 matching lines...) Expand all
357 if (rv != ERR_IO_PENDING) 357 if (rv != ERR_IO_PENDING)
358 return rv; 358 return rv;
359 359
360 callback_ = callback; 360 callback_ = callback;
361 user_buffer_ = buf; 361 user_buffer_ = buf;
362 user_buffer_len_ = buf_len; 362 user_buffer_len_ = buf_len;
363 return ERR_IO_PENDING; 363 return ERR_IO_PENDING;
364 } 364 }
365 365
366 void QuicHttpStream::Close(bool /*not_reusable*/) { 366 void QuicHttpStream::Close(bool /*not_reusable*/) {
367 session_error_ = ERR_ABORTED;
367 SaveResponseStatus(); 368 SaveResponseStatus();
368 // Note: the not_reusable flag has no meaning for QUIC streams. 369 // Note: the not_reusable flag has no meaning for QUIC streams.
369 if (stream_) { 370 if (stream_) {
370 stream_->SetDelegate(nullptr); 371 stream_->SetDelegate(nullptr);
371 stream_->Reset(QUIC_STREAM_CANCELLED); 372 stream_->Reset(QUIC_STREAM_CANCELLED);
372 } 373 }
373 ResetStream(); 374 ResetStream();
374 } 375 }
375 376
376 bool QuicHttpStream::IsResponseBodyComplete() const { 377 bool QuicHttpStream::IsResponseBodyComplete() const {
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 } 853 }
853 854
854 void QuicHttpStream::SetResponseStatus(int response_status) { 855 void QuicHttpStream::SetResponseStatus(int response_status) {
855 has_response_status_ = true; 856 has_response_status_ = true;
856 response_status_ = response_status; 857 response_status_ = response_status;
857 } 858 }
858 859
859 int QuicHttpStream::ComputeResponseStatus() const { 860 int QuicHttpStream::ComputeResponseStatus() const {
860 DCHECK(!has_response_status_); 861 DCHECK(!has_response_status_);
861 862
862 // If the handshake has failed this will be handled by the 863 // If the handshake has failed this will be handled by the QuicStreamFactory
863 // QuicStreamFactory and HttpStreamFactory to mark QUIC as broken. 864 // and HttpStreamFactory to mark QUIC as broken if TCP is actually working.
864 if (!was_handshake_confirmed_) 865 if (!was_handshake_confirmed_)
865 return ERR_QUIC_HANDSHAKE_FAILED; 866 return ERR_QUIC_HANDSHAKE_FAILED;
866 867
867 // If the session was aborted by a higher layer, simply use that error code. 868 // If the session was aborted by a higher layer, simply use that error code.
868 if (session_error_ != ERR_UNEXPECTED) 869 if (session_error_ != ERR_UNEXPECTED)
869 return session_error_; 870 return session_error_;
870 871
871 // If |response_info_| is null then the request has not been sent, so 872 // If |response_info_| is null then the request has not been sent, so
872 // return ERR_CONNECTION_CLOSED to permit HttpNetworkTransaction to 873 // return ERR_CONNECTION_CLOSED to permit HttpNetworkTransaction to
873 // retry the request. 874 // retry the request.
874 if (!response_info_) 875 if (!response_info_)
875 return ERR_CONNECTION_CLOSED; 876 return ERR_CONNECTION_CLOSED;
876 877
878 // Explicit stream error are always fatal.
879 if (quic_stream_error_ != QUIC_STREAM_NO_ERROR &&
880 quic_stream_error_ != QUIC_STREAM_CONNECTION_ERROR) {
881 return ERR_QUIC_PROTOCOL_ERROR;
882 }
883
884 DCHECK_NE(QUIC_HANDSHAKE_TIMEOUT, quic_connection_error_);
885
886 // If the headers have not been received and QUIC is now broken, return
887 // ERR_QUIC_BROKEN_ERROR to permit HttpNetworkTransaction to retry the request
888 // over TCP.
889 if (!response_headers_received_ &&
890 http_server_properties_->IsAlternativeServiceBroken(AlternativeService(
891 kProtoQUIC, server_id_.host(), server_id_.port()))) {
892 return ERR_QUIC_BROKEN_ERROR;
893 }
894
877 return ERR_QUIC_PROTOCOL_ERROR; 895 return ERR_QUIC_PROTOCOL_ERROR;
878 } 896 }
879 897
880 } // namespace net 898 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/quic_http_stream.h ('k') | net/quic/chromium/quic_network_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698