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/http/http_stream_factory.h" | 5 #include "net/http/http_stream_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "net/base/host_mapping_rules.h" | 12 #include "net/base/host_mapping_rules.h" |
| 13 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
| 14 #include "net/base/port_util.h" | 14 #include "net/base/port_util.h" |
| 15 #include "net/http/http_network_session.h" | 15 #include "net/http/http_network_session.h" |
| 16 #include "net/quic/quic_protocol.h" | |
| 16 #include "net/spdy/spdy_alt_svc_wire_format.h" | 17 #include "net/spdy/spdy_alt_svc_wire_format.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 | 21 |
| 21 // WARNING: If you modify or add any static flags, you must keep them in sync | 22 // WARNING: If you modify or add any static flags, you must keep them in sync |
| 22 // with |ResetStaticSettingsToInit|. This is critical for unit test isolation. | 23 // with |ResetStaticSettingsToInit|. This is critical for unit test isolation. |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 bool HttpStreamFactory::spdy_enabled_ = true; | 26 bool HttpStreamFactory::spdy_enabled_ = true; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 47 AlternativeServiceInfoVector alternative_service_info_vector; | 48 AlternativeServiceInfoVector alternative_service_info_vector; |
| 48 for (const SpdyAltSvcWireFormat::AlternativeService& | 49 for (const SpdyAltSvcWireFormat::AlternativeService& |
| 49 alternative_service_entry : alternative_service_vector) { | 50 alternative_service_entry : alternative_service_vector) { |
| 50 AlternateProtocol protocol = | 51 AlternateProtocol protocol = |
| 51 AlternateProtocolFromString(alternative_service_entry.protocol_id); | 52 AlternateProtocolFromString(alternative_service_entry.protocol_id); |
| 52 if (!IsAlternateProtocolValid(protocol) || | 53 if (!IsAlternateProtocolValid(protocol) || |
| 53 !session.IsProtocolEnabled(protocol) || | 54 !session.IsProtocolEnabled(protocol) || |
| 54 !IsPortValid(alternative_service_entry.port)) { | 55 !IsPortValid(alternative_service_entry.port)) { |
| 55 continue; | 56 continue; |
| 56 } | 57 } |
| 58 // Check if QUIC version is supported. | |
| 59 if (protocol == QUIC && !alternative_service_entry.version.empty()) { | |
| 60 SpdyAltSvcWireFormat::VersionVector::const_iterator begin = | |
| 61 alternative_service_entry.version.begin(); | |
| 62 SpdyAltSvcWireFormat::VersionVector::const_iterator end = | |
| 63 alternative_service_entry.version.end(); | |
| 64 bool match_found = false; | |
| 65 for (QuicVersion supported : session.params().quic_supported_versions) { | |
| 66 if (std::find(begin, end, static_cast<uint16>(supported)) != end) { | |
| 67 match_found = true; | |
|
Ryan Hamilton
2015/10/29 20:07:23
Up to you, but instead of using std::find, I wonde
| |
| 68 break; | |
| 69 } | |
| 70 } | |
| 71 if (!match_found) { | |
| 72 continue; | |
| 73 } | |
| 74 } | |
| 57 AlternativeService alternative_service(protocol, | 75 AlternativeService alternative_service(protocol, |
| 58 alternative_service_entry.host, | 76 alternative_service_entry.host, |
| 59 alternative_service_entry.port); | 77 alternative_service_entry.port); |
| 60 base::Time expiration = | 78 base::Time expiration = |
| 61 base::Time::Now() + | 79 base::Time::Now() + |
| 62 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); | 80 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); |
| 63 AlternativeServiceInfo alternative_service_info( | 81 AlternativeServiceInfo alternative_service_info( |
| 64 alternative_service, alternative_service_entry.probability, expiration); | 82 alternative_service, alternative_service_entry.probability, expiration); |
| 65 alternative_service_info_vector.push_back(alternative_service_info); | 83 alternative_service_info_vector.push_back(alternative_service_info); |
| 66 } | 84 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 HttpStreamFactory::HttpStreamFactory() {} | 172 HttpStreamFactory::HttpStreamFactory() {} |
| 155 | 173 |
| 156 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { | 174 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { |
| 157 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 175 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
| 158 if (mapping_rules) | 176 if (mapping_rules) |
| 159 mapping_rules->RewriteHost(&host_port_pair); | 177 mapping_rules->RewriteHost(&host_port_pair); |
| 160 return host_port_pair; | 178 return host_port_pair; |
| 161 } | 179 } |
| 162 | 180 |
| 163 } // namespace net | 181 } // namespace net |
| OLD | NEW |