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

Side by Side Diff: net/socket/ssl_client_socket.cc

Issue 1371263002: Refactor SSLClientSocket::SerializeNextProtos(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move DisableHTTP2 to next_protos. Created 5 years, 2 months 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/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('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/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/metrics/sparse_histogram.h" 8 #include "base/metrics/sparse_histogram.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "crypto/ec_private_key.h" 10 #include "crypto/ec_private_key.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 } 182 }
183 183
184 // static 184 // static
185 bool SSLClientSocket::IsTLSVersionAdequateForHTTP2( 185 bool SSLClientSocket::IsTLSVersionAdequateForHTTP2(
186 const SSLConfig& ssl_config) { 186 const SSLConfig& ssl_config) {
187 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2; 187 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1_2;
188 } 188 }
189 189
190 // static 190 // static
191 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( 191 std::vector<uint8_t> SSLClientSocket::SerializeNextProtos(
192 const NextProtoVector& next_protos, 192 const NextProtoVector& next_protos) {
193 bool can_advertise_http2) {
194 std::vector<uint8_t> wire_protos; 193 std::vector<uint8_t> wire_protos;
195 for (const NextProto next_proto : next_protos) { 194 for (const NextProto next_proto : next_protos) {
196 if (!can_advertise_http2 && next_proto == kProtoHTTP2) {
197 continue;
198 }
199 const std::string proto = NextProtoToString(next_proto); 195 const std::string proto = NextProtoToString(next_proto);
200 if (proto.size() > 255) { 196 if (proto.size() > 255) {
201 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; 197 LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto;
202 continue; 198 continue;
203 } 199 }
204 if (proto.size() == 0) { 200 if (proto.size() == 0) {
205 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; 201 LOG(WARNING) << "Ignoring empty NPN/ALPN protocol";
206 continue; 202 continue;
207 } 203 }
208 wire_protos.push_back(proto.size()); 204 wire_protos.push_back(proto.size());
209 for (const char ch : proto) { 205 for (const char ch : proto) {
210 wire_protos.push_back(static_cast<uint8_t>(ch)); 206 wire_protos.push_back(static_cast<uint8_t>(ch));
211 } 207 }
212 } 208 }
213 209
214 return wire_protos; 210 return wire_protos;
215 } 211 }
216 212
217 } // namespace net 213 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/ssl_client_socket.h ('k') | net/socket/ssl_client_socket_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698