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