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 bool match_found = false; |
| 61 for (QuicVersion supported : session.params().quic_supported_versions) { |
| 62 for (uint16 advertised : alternative_service_entry.version) { |
| 63 if (supported == advertised) { |
| 64 match_found = true; |
| 65 break; |
| 66 } |
| 67 } |
| 68 if (match_found) { |
| 69 break; |
| 70 } |
| 71 } |
| 72 if (!match_found) { |
| 73 continue; |
| 74 } |
| 75 } |
57 AlternativeService alternative_service(protocol, | 76 AlternativeService alternative_service(protocol, |
58 alternative_service_entry.host, | 77 alternative_service_entry.host, |
59 alternative_service_entry.port); | 78 alternative_service_entry.port); |
60 base::Time expiration = | 79 base::Time expiration = |
61 base::Time::Now() + | 80 base::Time::Now() + |
62 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); | 81 base::TimeDelta::FromSeconds(alternative_service_entry.max_age); |
63 AlternativeServiceInfo alternative_service_info( | 82 AlternativeServiceInfo alternative_service_info( |
64 alternative_service, alternative_service_entry.probability, expiration); | 83 alternative_service, alternative_service_entry.probability, expiration); |
65 alternative_service_info_vector.push_back(alternative_service_info); | 84 alternative_service_info_vector.push_back(alternative_service_info); |
66 } | 85 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 HttpStreamFactory::HttpStreamFactory() {} | 173 HttpStreamFactory::HttpStreamFactory() {} |
155 | 174 |
156 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { | 175 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { |
157 const HostMappingRules* mapping_rules = GetHostMappingRules(); | 176 const HostMappingRules* mapping_rules = GetHostMappingRules(); |
158 if (mapping_rules) | 177 if (mapping_rules) |
159 mapping_rules->RewriteHost(&host_port_pair); | 178 mapping_rules->RewriteHost(&host_port_pair); |
160 return host_port_pair; | 179 return host_port_pair; |
161 } | 180 } |
162 | 181 |
163 } // namespace net | 182 } // namespace net |
OLD | NEW |