| 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 <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include <openssl/aead.h> | 10 #include <openssl/aead.h> |
| (...skipping 1612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1623 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); | 1623 UMA_HISTOGRAM_COUNTS("Net.QuicActiveSessions", active_sessions_.size()); |
| 1624 active_sessions_[server_id] = session; | 1624 active_sessions_[server_id] = session; |
| 1625 session_aliases_[session].insert(server_id); | 1625 session_aliases_[session].insert(server_id); |
| 1626 const IPEndPoint peer_address = session->connection()->peer_address(); | 1626 const IPEndPoint peer_address = session->connection()->peer_address(); |
| 1627 DCHECK(!ContainsKey(ip_aliases_[peer_address], session)); | 1627 DCHECK(!ContainsKey(ip_aliases_[peer_address], session)); |
| 1628 ip_aliases_[peer_address].insert(session); | 1628 ip_aliases_[peer_address].insert(session); |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 int64_t QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( | 1631 int64_t QuicStreamFactory::GetServerNetworkStatsSmoothedRttInMicroseconds( |
| 1632 const QuicServerId& server_id) const { | 1632 const QuicServerId& server_id) const { |
| 1633 url::SchemeHostPort server("https", server_id.host_port_pair().host(), |
| 1634 server_id.host_port_pair().port()); |
| 1633 const ServerNetworkStats* stats = | 1635 const ServerNetworkStats* stats = |
| 1634 http_server_properties_->GetServerNetworkStats( | 1636 http_server_properties_->GetServerNetworkStats(server); |
| 1635 server_id.host_port_pair()); | |
| 1636 if (stats == nullptr) | 1637 if (stats == nullptr) |
| 1637 return 0; | 1638 return 0; |
| 1638 return stats->srtt.InMicroseconds(); | 1639 return stats->srtt.InMicroseconds(); |
| 1639 } | 1640 } |
| 1640 | 1641 |
| 1641 bool QuicStreamFactory::WasQuicRecentlyBroken( | 1642 bool QuicStreamFactory::WasQuicRecentlyBroken( |
| 1642 const QuicServerId& server_id) const { | 1643 const QuicServerId& server_id) const { |
| 1643 const AlternativeService alternative_service(QUIC, | 1644 const AlternativeService alternative_service(QUIC, |
| 1644 server_id.host_port_pair()); | 1645 server_id.host_port_pair()); |
| 1645 return http_server_properties_->WasAlternativeServiceRecentlyBroken( | 1646 return http_server_properties_->WasAlternativeServiceRecentlyBroken( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1688 | 1689 |
| 1689 void QuicStreamFactory::MaybeInitialize() { | 1690 void QuicStreamFactory::MaybeInitialize() { |
| 1690 // We don't initialize data from HttpServerProperties in the constructor | 1691 // We don't initialize data from HttpServerProperties in the constructor |
| 1691 // because HttpServerProperties has not yet initialized. We're guaranteed | 1692 // because HttpServerProperties has not yet initialized. We're guaranteed |
| 1692 // HttpServerProperties has been initialized by the first time a request is | 1693 // HttpServerProperties has been initialized by the first time a request is |
| 1693 // made. | 1694 // made. |
| 1694 if (has_initialized_data_) | 1695 if (has_initialized_data_) |
| 1695 return; | 1696 return; |
| 1696 | 1697 |
| 1697 has_initialized_data_ = true; | 1698 has_initialized_data_ = true; |
| 1698 for (const std::pair<const HostPortPair, AlternativeServiceInfoVector>& | 1699 for (const std::pair<const url::SchemeHostPort, AlternativeServiceInfoVector>& |
| 1699 key_value : http_server_properties_->alternative_service_map()) { | 1700 key_value : http_server_properties_->alternative_service_map()) { |
| 1701 HostPortPair host_port_pair(key_value.first.host(), key_value.first.port()); |
| 1700 for (const AlternativeServiceInfo& alternative_service_info : | 1702 for (const AlternativeServiceInfo& alternative_service_info : |
| 1701 key_value.second) { | 1703 key_value.second) { |
| 1702 if (alternative_service_info.alternative_service.protocol == QUIC) { | 1704 if (alternative_service_info.alternative_service.protocol == QUIC) { |
| 1703 quic_supported_servers_at_startup_.insert(key_value.first); | 1705 quic_supported_servers_at_startup_.insert(host_port_pair); |
| 1704 break; | 1706 break; |
| 1705 } | 1707 } |
| 1706 } | 1708 } |
| 1707 } | 1709 } |
| 1708 | 1710 |
| 1709 if (http_server_properties_->max_server_configs_stored_in_properties() == 0) | 1711 if (http_server_properties_->max_server_configs_stored_in_properties() == 0) |
| 1710 return; | 1712 return; |
| 1711 // Create a temporary QuicServerInfo object to deserialize and to populate the | 1713 // Create a temporary QuicServerInfo object to deserialize and to populate the |
| 1712 // in-memory crypto server config cache in the MRU order. | 1714 // in-memory crypto server config cache in the MRU order. |
| 1713 std::unique_ptr<QuicServerInfo> server_info; | 1715 std::unique_ptr<QuicServerInfo> server_info; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1737 return; | 1739 return; |
| 1738 | 1740 |
| 1739 const QuicConnectionStats& stats = session->connection()->GetStats(); | 1741 const QuicConnectionStats& stats = session->connection()->GetStats(); |
| 1740 const AlternativeService alternative_service(QUIC, | 1742 const AlternativeService alternative_service(QUIC, |
| 1741 server_id.host_port_pair()); | 1743 server_id.host_port_pair()); |
| 1742 if (session->IsCryptoHandshakeConfirmed()) { | 1744 if (session->IsCryptoHandshakeConfirmed()) { |
| 1743 http_server_properties_->ConfirmAlternativeService(alternative_service); | 1745 http_server_properties_->ConfirmAlternativeService(alternative_service); |
| 1744 ServerNetworkStats network_stats; | 1746 ServerNetworkStats network_stats; |
| 1745 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); | 1747 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); |
| 1746 network_stats.bandwidth_estimate = stats.estimated_bandwidth; | 1748 network_stats.bandwidth_estimate = stats.estimated_bandwidth; |
| 1747 http_server_properties_->SetServerNetworkStats(server_id.host_port_pair(), | 1749 url::SchemeHostPort server("https", server_id.host_port_pair().host(), |
| 1748 network_stats); | 1750 server_id.host_port_pair().port()); |
| 1751 http_server_properties_->SetServerNetworkStats(server, network_stats); |
| 1749 return; | 1752 return; |
| 1750 } | 1753 } |
| 1751 | 1754 |
| 1752 UMA_HISTOGRAM_COUNTS("Net.QuicHandshakeNotConfirmedNumPacketsReceived", | 1755 UMA_HISTOGRAM_COUNTS("Net.QuicHandshakeNotConfirmedNumPacketsReceived", |
| 1753 stats.packets_received); | 1756 stats.packets_received); |
| 1754 | 1757 |
| 1755 if (!session_was_active) | 1758 if (!session_was_active) |
| 1756 return; | 1759 return; |
| 1757 | 1760 |
| 1758 // TODO(rch): In the special case where the session has received no | 1761 // TODO(rch): In the special case where the session has received no |
| 1759 // packets from the peer, we should consider blacklisting this | 1762 // packets from the peer, we should consider blacklisting this |
| 1760 // differently so that we still race TCP but we don't consider the | 1763 // differently so that we still race TCP but we don't consider the |
| 1761 // session connected until the handshake has been confirmed. | 1764 // session connected until the handshake has been confirmed. |
| 1762 HistogramBrokenAlternateProtocolLocation( | 1765 HistogramBrokenAlternateProtocolLocation( |
| 1763 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); | 1766 BROKEN_ALTERNATE_PROTOCOL_LOCATION_QUIC_STREAM_FACTORY); |
| 1764 | 1767 |
| 1765 // Since the session was active, there's no longer an | 1768 // Since the session was active, there's no longer an |
| 1766 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP | 1769 // HttpStreamFactoryImpl::Job running which can mark it broken, unless the TCP |
| 1767 // job also fails. So to avoid not using QUIC when we otherwise could, we mark | 1770 // job also fails. So to avoid not using QUIC when we otherwise could, we mark |
| 1768 // it as recently broken, which means that 0-RTT will be disabled but we'll | 1771 // it as recently broken, which means that 0-RTT will be disabled but we'll |
| 1769 // still race. | 1772 // still race. |
| 1770 http_server_properties_->MarkAlternativeServiceRecentlyBroken( | 1773 http_server_properties_->MarkAlternativeServiceRecentlyBroken( |
| 1771 alternative_service); | 1774 alternative_service); |
| 1772 } | 1775 } |
| 1773 | 1776 |
| 1774 } // namespace net | 1777 } // namespace net |
| OLD | NEW |