| 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_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1611 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); | 1611 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); |
| 1612 active_sessions_[server_id] = session; | 1612 active_sessions_[server_id] = session; |
| 1613 session_aliases_[session].insert(server_id); | 1613 session_aliases_[session].insert(server_id); |
| 1614 const IPEndPoint peer_address = session->connection()->peer_address(); | 1614 const IPEndPoint peer_address = session->connection()->peer_address(); |
| 1615 DCHECK(!ContainsKey(ip_aliases_[peer_address], session)); | 1615 DCHECK(!ContainsKey(ip_aliases_[peer_address], session)); |
| 1616 ip_aliases_[peer_address].insert(session); | 1616 ip_aliases_[peer_address].insert(session); |
| 1617 } | 1617 } |
| 1618 | 1618 |
| 1619 int64_t QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( | 1619 int64_t QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( |
| 1620 const QuicServerId& server_id) const { | 1620 const QuicServerId& server_id) const { |
| 1621 HostPortPair host_port_pair = server_id.host_port_pair(); |
| 1622 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), |
| 1623 host_port_pair.port()); |
| 1621 const ServerNetworkStats* stats = | 1624 const ServerNetworkStats* stats = |
| 1622 http_server_properties_->GetServerNetworkStats( | 1625 http_server_properties_->GetServerNetworkStats(scheme_host_port); |
| 1623 server_id.host_port_pair()); | |
| 1624 if (stats == nullptr) | 1626 if (stats == nullptr) |
| 1625 return 0; | 1627 return 0; |
| 1626 return stats->srtt.InMicroseconds(); | 1628 return stats->srtt.InMicroseconds(); |
| 1627 } | 1629 } |
| 1628 | 1630 |
| 1629 bool QuicStreamFactory::WasQuicRecentlyBroken( | 1631 bool QuicStreamFactory::WasQuicRecentlyBroken( |
| 1630 const QuicServerId& server_id) const { | 1632 const QuicServerId& server_id) const { |
| 1631 const AlternativeService alternative_service(QUIC, | 1633 const AlternativeService alternative_service(QUIC, |
| 1632 server_id.host_port_pair()); | 1634 server_id.host_port_pair()); |
| 1633 return http_server_properties_->WasAlternativeServiceRecentlyBroken( | 1635 return http_server_properties_->WasAlternativeServiceRecentlyBroken( |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1720 return; | 1722 return; |
| 1721 | 1723 |
| 1722 const QuicConnectionStats& stats = session->connection()->GetStats(); | 1724 const QuicConnectionStats& stats = session->connection()->GetStats(); |
| 1723 const AlternativeService alternative_service(QUIC, | 1725 const AlternativeService alternative_service(QUIC, |
| 1724 server_id.host_port_pair()); | 1726 server_id.host_port_pair()); |
| 1725 if (session->IsCryptoHandshakeConfirmed()) { | 1727 if (session->IsCryptoHandshakeConfirmed()) { |
| 1726 http_server_properties_->ConfirmAlternativeService(alternative_service); | 1728 http_server_properties_->ConfirmAlternativeService(alternative_service); |
| 1727 ServerNetworkStats network_stats; | 1729 ServerNetworkStats network_stats; |
| 1728 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); | 1730 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); |
| 1729 network_stats.bandwidth_estimate = stats.estimated_bandwidth; | 1731 network_stats.bandwidth_estimate = stats.estimated_bandwidth; |
| 1730 http_server_properties_->SetServerNetworkStats(server_id.host_port_pair(), | 1732 HostPortPair host_port_pair = server_id.host_port_pair(); |
| 1733 url::SchemeHostPort scheme_host_port("https", host_port_pair.host(), |
| 1734 host_port_pair.port()); |
| 1735 |
| 1736 http_server_properties_->SetServerNetworkStats(scheme_host_port, |
| 1731 network_stats); | 1737 network_stats); |
| 1732 return; | 1738 return; |
| 1733 } | 1739 } |
| 1734 | 1740 |
| 1735 UMA_HISTOGRAM_COUNTS("Net.QuicHandshakeNotConfirmedNumPacketsReceived", | 1741 UMA_HISTOGRAM_COUNTS("Net.QuicHandshakeNotConfirmedNumPacketsReceived", |
| 1736 stats.packets_received); | 1742 stats.packets_received); |
| 1737 | 1743 |
| 1738 if (!session_was_active) | 1744 if (!session_was_active) |
| 1739 return; | 1745 return; |
| 1740 | 1746 |
| 1741 // TODO(rch): In the special case where the session has received no | 1747 // TODO(rch): In the special case where the session has received no |
| 1742 // packets from the peer, we should consider blacklisting this | 1748 // packets from the peer, we should consider blacklisting this |
| 1743 // differently so that we still race TCP but we don't consider the | 1749 // differently so that we still race TCP but we don't consider the |
| 1744 // session connected until the handshake has been confirmed. | 1750 // session connected until the handshake has been confirmed. |
| 1745 HistogramBrokenAlternateProtocolLocation( | 1751 HistogramBrokenAlternateProtocolLocation( |
| 1746 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); | 1752 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); |
| 1747 | 1753 |
| 1748 // Since the session was active, there's no longer an | 1754 // Since the session was active, there's no longer an |
| 1749 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1755 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1750 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1756 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1751 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1757 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1752 // still race. | 1758 // still race. |
| 1753 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1759 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1754 alternative_service); | 1760 alternative_service); |
| 1755 } | 1761 } |
| 1756 | 1762 |
| 1757 } // namespace net | 1763 } // namespace net |
| OLD | NEW |