Chromium Code Reviews| 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_chromium_client_session.h" | 5 #include "net/quic/quic_chromium_client_session.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 752 } | 752 } |
| 753 } | 753 } |
| 754 | 754 |
| 755 void QuicChromiumClientSession::OnCryptoHandshakeMessageReceived( | 755 void QuicChromiumClientSession::OnCryptoHandshakeMessageReceived( |
| 756 const CryptoHandshakeMessage& message) { | 756 const CryptoHandshakeMessage& message) { |
| 757 logger_->OnCryptoHandshakeMessageReceived(message); | 757 logger_->OnCryptoHandshakeMessageReceived(message); |
| 758 } | 758 } |
| 759 | 759 |
| 760 void QuicChromiumClientSession::OnGoAway(const QuicGoAwayFrame& frame) { | 760 void QuicChromiumClientSession::OnGoAway(const QuicGoAwayFrame& frame) { |
| 761 QuicSession::OnGoAway(frame); | 761 QuicSession::OnGoAway(frame); |
| 762 NotifyFactoryOfSessionGoingAway(); | 762 NotifyFactoryOfSessionGoingAway(frame.reason_phrase == |
| 763 "peer connection migration"); | |
| 763 } | 764 } |
| 764 | 765 |
| 765 void QuicChromiumClientSession::OnRstStream(const QuicRstStreamFrame& frame) { | 766 void QuicChromiumClientSession::OnRstStream(const QuicRstStreamFrame& frame) { |
| 766 QuicSession::OnRstStream(frame); | 767 QuicSession::OnRstStream(frame); |
| 767 OnClosedStream(); | 768 OnClosedStream(); |
| 768 } | 769 } |
| 769 | 770 |
| 770 void QuicChromiumClientSession::OnConnectionClosed( | 771 void QuicChromiumClientSession::OnConnectionClosed( |
| 771 QuicErrorCode error, | 772 QuicErrorCode error, |
| 772 ConnectionCloseSource source) { | 773 ConnectionCloseSource source) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 842 UMA_HISTOGRAM_SPARSE_SLOWLY( | 843 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 843 "Net.QuicSession.ConnectionClose.HandshakeFailureUnknown.QuicError", | 844 "Net.QuicSession.ConnectionClose.HandshakeFailureUnknown.QuicError", |
| 844 error); | 845 error); |
| 845 } | 846 } |
| 846 } else if (error == QUIC_PUBLIC_RESET) { | 847 } else if (error == QUIC_PUBLIC_RESET) { |
| 847 disabled_reason_ = QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE; | 848 disabled_reason_ = QUIC_DISABLED_PUBLIC_RESET_POST_HANDSHAKE; |
| 848 } | 849 } |
| 849 | 850 |
| 850 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.QuicVersion", | 851 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.QuicVersion", |
| 851 connection()->version()); | 852 connection()->version()); |
| 852 NotifyFactoryOfSessionGoingAway(); | 853 NotifyFactoryOfSessionGoingAway(false); |
| 853 QuicSession::OnConnectionClosed(error, source); | 854 QuicSession::OnConnectionClosed(error, source); |
| 854 | 855 |
| 855 if (!callback_.is_null()) { | 856 if (!callback_.is_null()) { |
| 856 base::ResetAndReturn(&callback_).Run(ERR_QUIC_PROTOCOL_ERROR); | 857 base::ResetAndReturn(&callback_).Run(ERR_QUIC_PROTOCOL_ERROR); |
| 857 } | 858 } |
| 858 | 859 |
| 859 for (auto& socket : sockets_) { | 860 for (auto& socket : sockets_) { |
| 860 socket->Close(); | 861 socket->Close(); |
| 861 } | 862 } |
| 862 DCHECK(dynamic_streams().empty()); | 863 DCHECK(dynamic_streams().empty()); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1008 int result, | 1009 int result, |
| 1009 const DatagramClientSocket* socket) { | 1010 const DatagramClientSocket* socket) { |
| 1010 DCHECK(socket != nullptr); | 1011 DCHECK(socket != nullptr); |
| 1011 if (socket != GetDefaultSocket()) { | 1012 if (socket != GetDefaultSocket()) { |
| 1012 // Ignore read errors from old sockets that are no longer active. | 1013 // Ignore read errors from old sockets that are no longer active. |
| 1013 // TODO(jri): Maybe clean up old sockets on error. | 1014 // TODO(jri): Maybe clean up old sockets on error. |
| 1014 return; | 1015 return; |
| 1015 } | 1016 } |
| 1016 DVLOG(1) << "Closing session on read error: " << result; | 1017 DVLOG(1) << "Closing session on read error: " << result; |
| 1017 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.ReadError", -result); | 1018 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.QuicSession.ReadError", -result); |
| 1018 NotifyFactoryOfSessionGoingAway(); | 1019 NotifyFactoryOfSessionGoingAway(false); |
| 1019 CloseSessionOnErrorInner(result, QUIC_PACKET_READ_ERROR); | 1020 CloseSessionOnErrorInner(result, QUIC_PACKET_READ_ERROR); |
| 1020 NotifyFactoryOfSessionClosedLater(); | 1021 NotifyFactoryOfSessionClosedLater(); |
| 1021 } | 1022 } |
| 1022 | 1023 |
| 1023 bool QuicChromiumClientSession::OnPacket(const QuicEncryptedPacket& packet, | 1024 bool QuicChromiumClientSession::OnPacket(const QuicEncryptedPacket& packet, |
| 1024 IPEndPoint local_address, | 1025 IPEndPoint local_address, |
| 1025 IPEndPoint peer_address) { | 1026 IPEndPoint peer_address) { |
| 1026 ProcessUdpPacket(local_address, peer_address, packet); | 1027 ProcessUdpPacket(local_address, peer_address, packet); |
| 1027 if (!connection()->connected()) { | 1028 if (!connection()->connected()) { |
| 1028 NotifyFactoryOfSessionClosedLater(); | 1029 NotifyFactoryOfSessionClosedLater(); |
| 1029 return false; | 1030 return false; |
| 1030 } | 1031 } |
| 1031 return true; | 1032 return true; |
| 1032 } | 1033 } |
| 1033 | 1034 |
| 1034 void QuicChromiumClientSession::NotifyFactoryOfSessionGoingAway() { | 1035 void QuicChromiumClientSession::NotifyFactoryOfSessionGoingAway( |
| 1036 bool is_connection_migrated) { | |
| 1035 going_away_ = true; | 1037 going_away_ = true; |
| 1036 if (stream_factory_) | 1038 if (stream_factory_) { |
| 1037 stream_factory_->OnSessionGoingAway(this); | 1039 stream_factory_->OnSessionGoingAway(this); |
| 1040 if (is_connection_migrated) | |
| 1041 stream_factory_->OnSessionGoingAwayForConnectionMigration(); | |
|
Ryan Hamilton
2016/03/09 19:53:03
Instead of doing this, can we have the session sto
| |
| 1042 } | |
| 1038 } | 1043 } |
| 1039 | 1044 |
| 1040 void QuicChromiumClientSession::NotifyFactoryOfSessionClosedLater() { | 1045 void QuicChromiumClientSession::NotifyFactoryOfSessionClosedLater() { |
| 1041 if (!dynamic_streams().empty()) | 1046 if (!dynamic_streams().empty()) |
| 1042 RecordUnexpectedOpenStreams(NOTIFY_FACTORY_OF_SESSION_CLOSED_LATER); | 1047 RecordUnexpectedOpenStreams(NOTIFY_FACTORY_OF_SESSION_CLOSED_LATER); |
| 1043 | 1048 |
| 1044 if (!going_away_) | 1049 if (!going_away_) |
| 1045 RecordUnexpectedNotGoingAway(NOTIFY_FACTORY_OF_SESSION_CLOSED_LATER); | 1050 RecordUnexpectedNotGoingAway(NOTIFY_FACTORY_OF_SESSION_CLOSED_LATER); |
| 1046 | 1051 |
| 1047 going_away_ = true; | 1052 going_away_ = true; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 | 1116 |
| 1112 bool QuicChromiumClientSession::HasNonMigratableStreams() const { | 1117 bool QuicChromiumClientSession::HasNonMigratableStreams() const { |
| 1113 for (const auto& stream : dynamic_streams()) { | 1118 for (const auto& stream : dynamic_streams()) { |
| 1114 if (!static_cast<QuicChromiumClientStream*>(stream.second)->can_migrate()) | 1119 if (!static_cast<QuicChromiumClientStream*>(stream.second)->can_migrate()) |
| 1115 return true; | 1120 return true; |
| 1116 } | 1121 } |
| 1117 return false; | 1122 return false; |
| 1118 } | 1123 } |
| 1119 | 1124 |
| 1120 } // namespace net | 1125 } // namespace net |
| OLD | NEW |