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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/cpu.h" | 9 #include "base/cpu.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); | 937 config.SetInitialSessionFlowControlWindowToSend(kInitialReceiveWindowSize); |
938 if (http_server_properties_) { | 938 if (http_server_properties_) { |
939 const HttpServerProperties::NetworkStats* stats = | 939 const HttpServerProperties::NetworkStats* stats = |
940 http_server_properties_->GetServerNetworkStats( | 940 http_server_properties_->GetServerNetworkStats( |
941 server_id.host_port_pair()); | 941 server_id.host_port_pair()); |
942 if (stats != nullptr) { | 942 if (stats != nullptr) { |
943 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); | 943 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); |
944 } | 944 } |
945 } | 945 } |
946 | 946 |
| 947 if (quic_server_info_factory_ && !server_info) { |
| 948 // Start the disk cache loading so that we can persist the newer QUIC server |
| 949 // information and/or inform the disk cache that we have reused |
| 950 // |server_info|. |
| 951 server_info.reset(quic_server_info_factory_->GetForServer(server_id)); |
| 952 server_info->Start(); |
| 953 } |
| 954 |
947 *session = new QuicClientSession( | 955 *session = new QuicClientSession( |
948 connection, socket.Pass(), this, transport_security_state_, | 956 connection, socket.Pass(), this, transport_security_state_, |
949 server_info.Pass(), config, server_id.is_https(), | 957 server_info.Pass(), config, server_id.is_https(), |
950 base::MessageLoop::current()->message_loop_proxy().get(), | 958 base::MessageLoop::current()->message_loop_proxy().get(), |
951 net_log.net_log()); | 959 net_log.net_log()); |
952 all_sessions_[*session] = server_id; // owning pointer | 960 all_sessions_[*session] = server_id; // owning pointer |
953 (*session)->InitializeSession(server_id, &crypto_config_, | 961 (*session)->InitializeSession(server_id, &crypto_config_, |
954 quic_crypto_client_stream_factory_); | 962 quic_crypto_client_stream_factory_); |
955 bool closed_during_initialize = | 963 bool closed_during_initialize = |
956 !ContainsKey(all_sessions_, *session) || | 964 !ContainsKey(all_sessions_, *session) || |
(...skipping 21 matching lines...) Expand all Loading... |
978 session_aliases_[session].insert(server_id); | 986 session_aliases_[session].insert(server_id); |
979 const IpAliasKey ip_alias_key(session->connection()->peer_address(), | 987 const IpAliasKey ip_alias_key(session->connection()->peer_address(), |
980 server_id.is_https()); | 988 server_id.is_https()); |
981 DCHECK(!ContainsKey(ip_aliases_[ip_alias_key], session)); | 989 DCHECK(!ContainsKey(ip_aliases_[ip_alias_key], session)); |
982 ip_aliases_[ip_alias_key].insert(session); | 990 ip_aliases_[ip_alias_key].insert(session); |
983 } | 991 } |
984 | 992 |
985 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( | 993 void QuicStreamFactory::InitializeCachedStateInCryptoConfig( |
986 const QuicServerId& server_id, | 994 const QuicServerId& server_id, |
987 const scoped_ptr<QuicServerInfo>& server_info) { | 995 const scoped_ptr<QuicServerInfo>& server_info) { |
| 996 // |server_info| will be NULL, if a non-empty server config already exists in |
| 997 // the memory cache. This is a minor optimization to avoid LookupOrCreate. |
988 if (!server_info) | 998 if (!server_info) |
989 return; | 999 return; |
990 | 1000 |
991 QuicCryptoClientConfig::CachedState* cached = | 1001 QuicCryptoClientConfig::CachedState* cached = |
992 crypto_config_.LookupOrCreate(server_id); | 1002 crypto_config_.LookupOrCreate(server_id); |
993 if (!cached->IsEmpty()) | 1003 if (!cached->IsEmpty()) |
994 return; | 1004 return; |
995 | 1005 |
| 1006 if (http_server_properties_) { |
| 1007 if (quic_supported_servers_at_startup_.empty()) { |
| 1008 for (const std::pair<net::HostPortPair, net::AlternateProtocolInfo>& |
| 1009 key_value : http_server_properties_->alternate_protocol_map()) { |
| 1010 if (key_value.second.protocol == QUIC) { |
| 1011 quic_supported_servers_at_startup_.insert(key_value.first); |
| 1012 } |
| 1013 } |
| 1014 } |
| 1015 |
| 1016 // TODO(rtenneti): Delete the following histogram after collecting stats. |
| 1017 // If the AlternateProtocolMap contained an entry for this host, check if |
| 1018 // the disk cache contained an entry for it. |
| 1019 if (ContainsKey(quic_supported_servers_at_startup_, |
| 1020 server_id.host_port_pair())) { |
| 1021 UMA_HISTOGRAM_BOOLEAN( |
| 1022 "Net.QuicServerInfo.ExpectConfigMissingFromDiskCache", |
| 1023 server_info->state().server_config.empty()); |
| 1024 } |
| 1025 } |
| 1026 |
996 if (!cached->Initialize(server_info->state().server_config, | 1027 if (!cached->Initialize(server_info->state().server_config, |
997 server_info->state().source_address_token, | 1028 server_info->state().source_address_token, |
998 server_info->state().certs, | 1029 server_info->state().certs, |
999 server_info->state().server_config_sig, | 1030 server_info->state().server_config_sig, |
1000 clock_->WallNow())) | 1031 clock_->WallNow())) |
1001 return; | 1032 return; |
1002 | 1033 |
1003 if (!server_id.is_https()) { | 1034 if (!server_id.is_https()) { |
1004 // Don't check the certificates for insecure QUIC. | 1035 // Don't check the certificates for insecure QUIC. |
1005 cached->SetProofValid(); | 1036 cached->SetProofValid(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 http_server_properties_->ClearAlternateProtocol(server); | 1086 http_server_properties_->ClearAlternateProtocol(server); |
1056 http_server_properties_->SetAlternateProtocol( | 1087 http_server_properties_->SetAlternateProtocol( |
1057 server, alternate.port, alternate.protocol, 1); | 1088 server, alternate.port, alternate.protocol, 1); |
1058 DCHECK_EQ(QUIC, | 1089 DCHECK_EQ(QUIC, |
1059 http_server_properties_->GetAlternateProtocol(server).protocol); | 1090 http_server_properties_->GetAlternateProtocol(server).protocol); |
1060 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( | 1091 DCHECK(http_server_properties_->WasAlternateProtocolRecentlyBroken( |
1061 server)); | 1092 server)); |
1062 } | 1093 } |
1063 | 1094 |
1064 } // namespace net | 1095 } // namespace net |
OLD | NEW |