Index: net/socket/ssl_client_socket.cc |
diff --git a/net/socket/ssl_client_socket.cc b/net/socket/ssl_client_socket.cc |
index a52e6a3c052c70eba239aa57594c8a390816fc56..f1b65cc17fc755626aaf7a15bdc44ab1a005d21d 100644 |
--- a/net/socket/ssl_client_socket.cc |
+++ b/net/socket/ssl_client_socket.cc |
@@ -235,34 +235,32 @@ bool SSLClientSocket::IsChannelIDEnabled( |
// static |
std::vector<uint8_t> SSLClientSocket::SerializeNextProtos( |
- const std::vector<std::string>& next_protos) { |
+ const NextProtoVector& next_protos) { |
// Do a first pass to determine the total length. |
size_t wire_length = 0; |
- for (std::vector<std::string>::const_iterator i = next_protos.begin(); |
- i != next_protos.end(); ++i) { |
- if (i->size() > 255) { |
- LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << *i; |
+ std::vector<std::string> next_proto_strings; |
+ for (const auto& it : next_protos) { |
Ryan Hamilton
2014/12/10 20:09:00
Prefer using the actual type to auto if the type i
Bence
2014/12/10 22:01:23
Done.
|
+ const std::string proto = NextProtoToString(it); |
+ if (proto.size() > 255) { |
+ LOG(WARNING) << "Ignoring overlong NPN/ALPN protocol: " << proto; |
continue; |
} |
- if (i->size() == 0) { |
+ if (proto.size() == 0) { |
LOG(WARNING) << "Ignoring empty NPN/ALPN protocol"; |
continue; |
} |
- wire_length += i->size(); |
+ next_proto_strings.push_back(proto); |
+ wire_length += proto.size(); |
wire_length++; |
} |
// Allocate memory for the result and fill it in. |
std::vector<uint8_t> wire_protos; |
wire_protos.reserve(wire_length); |
- for (std::vector<std::string>::const_iterator i = next_protos.begin(); |
- i != next_protos.end(); i++) { |
- if (i->size() == 0 || i->size() > 255) |
- continue; |
- wire_protos.push_back(i->size()); |
- wire_protos.resize(wire_protos.size() + i->size()); |
- memcpy(&wire_protos[wire_protos.size() - i->size()], |
- i->data(), i->size()); |
+ for (const auto& it : next_proto_strings) { |
Ryan Hamilton
2014/12/10 20:09:00
ditto.
Bence
2014/12/10 22:01:23
Done.
|
+ wire_protos.push_back(it.size()); |
+ wire_protos.resize(wire_protos.size() + it.size()); |
+ memcpy(&wire_protos[wire_protos.size() - it.size()], it.data(), it.size()); |
Ryan Hamilton
2014/12/10 20:09:00
This code (which you did not write) looks complete
Bence
2014/12/10 22:01:23
Done.
|
} |
DCHECK_EQ(wire_protos.size(), wire_length); |