OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | |
8 | |
7 namespace net { | 9 namespace net { |
8 | 10 |
9 SSLClientSocket::SSLClientSocket() | 11 SSLClientSocket::SSLClientSocket() |
10 : was_npn_negotiated_(false), | 12 : was_npn_negotiated_(false), |
11 was_spdy_negotiated_(false) { | 13 was_spdy_negotiated_(false) { |
12 } | 14 } |
13 | 15 |
14 SSLClientSocket::NextProto SSLClientSocket::NextProtoFromString( | 16 SSLClientSocket::NextProto SSLClientSocket::NextProtoFromString( |
15 const std::string& proto_string) { | 17 const std::string& proto_string) { |
16 if (proto_string == "http1.1" || proto_string == "http/1.1") { | 18 if (proto_string == "http1.1" || proto_string == "http/1.1") { |
17 return kProtoHTTP11; | 19 return kProtoHTTP11; |
18 } else if (proto_string == "spdy/1") { | 20 } else if (proto_string == "spdy/1") { |
19 return kProtoSPDY1; | 21 return kProtoSPDY1; |
20 } else if (proto_string == "spdy/2") { | 22 } else if (proto_string == "spdy/2") { |
21 return kProtoSPDY2; | 23 return kProtoSPDY2; |
22 } else { | 24 } else { |
23 return kProtoUnknown; | 25 return kProtoUnknown; |
24 } | 26 } |
25 } | 27 } |
26 | 28 |
29 // static | |
30 const char* SSLClientSocket::NextProtoStatusToString( | |
31 const SSLClientSocket::NextProtoStatus status) { | |
32 switch (status) { | |
33 case kNextProtoUnsupported: | |
34 return "Unsupported"; | |
agl
2011/12/05 16:38:10
"unsupported"
ramant (doing other things)
2011/12/05 19:03:28
Done.
| |
35 case kNextProtoNegotiated: | |
36 return "Negotiated"; | |
agl
2011/12/05 16:38:10
"negotiated"
ramant (doing other things)
2011/12/05 19:03:28
Done.
| |
37 case kNextProtoNoOverlap: | |
38 return "No overlap"; | |
agl
2011/12/05 16:38:10
"no-overlap"
ramant (doing other things)
2011/12/05 19:03:28
Done.
| |
39 } | |
40 return NULL; | |
41 } | |
42 | |
43 // static | |
44 std::string SSLClientSocket::ServerProtoToString( | |
45 const std::string& server_proto) { | |
agl
2011/12/05 16:38:10
s
ramant (doing other things)
2011/12/05 19:03:28
Done.
| |
46 const char* protos = server_proto.c_str(); | |
47 size_t protos_len = server_proto.length(); | |
48 std::vector<std::string> server_protos; | |
49 for (size_t i = 0; i < protos_len; ) { | |
50 const size_t len = protos[i]; | |
51 std::string proto_str(&protos[i + 1], len); | |
52 server_protos.push_back(proto_str); | |
53 i += len + 1; | |
54 } | |
55 return JoinString(server_protos, ','); | |
56 } | |
57 | |
27 bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { | 58 bool SSLClientSocket::IgnoreCertError(int error, int load_flags) { |
28 if (error == OK || load_flags & LOAD_IGNORE_ALL_CERT_ERRORS) | 59 if (error == OK || load_flags & LOAD_IGNORE_ALL_CERT_ERRORS) |
29 return true; | 60 return true; |
30 | 61 |
31 if (error == ERR_CERT_COMMON_NAME_INVALID && | 62 if (error == ERR_CERT_COMMON_NAME_INVALID && |
32 (load_flags & LOAD_IGNORE_CERT_COMMON_NAME_INVALID)) | 63 (load_flags & LOAD_IGNORE_CERT_COMMON_NAME_INVALID)) |
33 return true; | 64 return true; |
34 | 65 |
35 if (error == ERR_CERT_DATE_INVALID && | 66 if (error == ERR_CERT_DATE_INVALID && |
36 (load_flags & LOAD_IGNORE_CERT_DATE_INVALID)) | 67 (load_flags & LOAD_IGNORE_CERT_DATE_INVALID)) |
(...skipping 16 matching lines...) Expand all Loading... | |
53 | 84 |
54 bool SSLClientSocket::was_spdy_negotiated() const { | 85 bool SSLClientSocket::was_spdy_negotiated() const { |
55 return was_spdy_negotiated_; | 86 return was_spdy_negotiated_; |
56 } | 87 } |
57 | 88 |
58 bool SSLClientSocket::set_was_spdy_negotiated(bool negotiated) { | 89 bool SSLClientSocket::set_was_spdy_negotiated(bool negotiated) { |
59 return was_spdy_negotiated_ = negotiated; | 90 return was_spdy_negotiated_ = negotiated; |
60 } | 91 } |
61 | 92 |
62 } // namespace net | 93 } // namespace net |
OLD | NEW |