Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: net/http/http_stream_factory.cc

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 AlternateProtocolFromString(alternative_service_entry.protocol_id); 52 AlternateProtocolFromString(alternative_service_entry.protocol_id);
53 if (!IsAlternateProtocolValid(protocol) || 53 if (!IsAlternateProtocolValid(protocol) ||
54 !session.IsProtocolEnabled(protocol) || 54 !session.IsProtocolEnabled(protocol) ||
55 !IsPortValid(alternative_service_entry.port)) { 55 !IsPortValid(alternative_service_entry.port)) {
56 continue; 56 continue;
57 } 57 }
58 // Check if QUIC version is supported. 58 // Check if QUIC version is supported.
59 if (protocol == QUIC && !alternative_service_entry.version.empty()) { 59 if (protocol == QUIC && !alternative_service_entry.version.empty()) {
60 bool match_found = false; 60 bool match_found = false;
61 for (QuicVersion supported : session.params().quic_supported_versions) { 61 for (QuicVersion supported : session.params().quic_supported_versions) {
62 for (uint16 advertised : alternative_service_entry.version) { 62 for (uint16_t advertised : alternative_service_entry.version) {
63 if (supported == advertised) { 63 if (supported == advertised) {
64 match_found = true; 64 match_found = true;
65 break; 65 break;
66 } 66 }
67 } 67 }
68 if (match_found) { 68 if (match_found) {
69 break; 69 break;
70 } 70 }
71 } 71 }
72 if (!match_found) { 72 if (!match_found) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 } 146 }
147 147
148 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) { 148 if (!is_valid || protocol == UNINITIALIZED_ALTERNATE_PROTOCOL) {
149 http_server_properties->ClearAlternativeServices(http_host_port_pair); 149 http_server_properties->ClearAlternativeServices(http_host_port_pair);
150 return; 150 return;
151 } 151 }
152 152
153 http_server_properties->SetAlternativeService( 153 http_server_properties->SetAlternativeService(
154 RewriteHost(http_host_port_pair), 154 RewriteHost(http_host_port_pair),
155 AlternativeService(protocol, "", static_cast<uint16>(port)), probability, 155 AlternativeService(protocol, "", static_cast<uint16_t>(port)),
156 base::Time::Now() + base::TimeDelta::FromDays(30)); 156 probability, base::Time::Now() + base::TimeDelta::FromDays(30));
157 } 157 }
158 158
159 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url, 159 GURL HttpStreamFactory::ApplyHostMappingRules(const GURL& url,
160 HostPortPair* endpoint) { 160 HostPortPair* endpoint) {
161 const HostMappingRules* mapping_rules = GetHostMappingRules(); 161 const HostMappingRules* mapping_rules = GetHostMappingRules();
162 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) { 162 if (mapping_rules && mapping_rules->RewriteHost(endpoint)) {
163 url::Replacements<char> replacements; 163 url::Replacements<char> replacements;
164 const std::string port_str = base::UintToString(endpoint->port()); 164 const std::string port_str = base::UintToString(endpoint->port());
165 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size())); 165 replacements.SetPort(port_str.c_str(), url::Component(0, port_str.size()));
166 replacements.SetHost(endpoint->host().c_str(), 166 replacements.SetHost(endpoint->host().c_str(),
167 url::Component(0, endpoint->host().size())); 167 url::Component(0, endpoint->host().size()));
168 return url.ReplaceComponents(replacements); 168 return url.ReplaceComponents(replacements);
169 } 169 }
170 return url; 170 return url;
171 } 171 }
172 172
173 HttpStreamFactory::HttpStreamFactory() {} 173 HttpStreamFactory::HttpStreamFactory() {}
174 174
175 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) { 175 HostPortPair HttpStreamFactory::RewriteHost(HostPortPair host_port_pair) {
176 const HostMappingRules* mapping_rules = GetHostMappingRules(); 176 const HostMappingRules* mapping_rules = GetHostMappingRules();
177 if (mapping_rules) 177 if (mapping_rules)
178 mapping_rules->RewriteHost(&host_port_pair); 178 mapping_rules->RewriteHost(&host_port_pair);
179 return host_port_pair; 179 return host_port_pair;
180 } 180 }
181 181
182 } // namespace net 182 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory.h ('k') | net/http/http_stream_factory_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698