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

Side by Side Diff: extensions/browser/api/socket/tls_socket.cc

Issue 1549643002: Switch to standard integer types in extensions/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean
Patch Set: Created 4 years, 12 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 | « extensions/browser/api/socket/tls_socket.h ('k') | extensions/browser/api/socket/udp_socket.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/api/socket/tls_socket.h" 5 #include "extensions/browser/api/socket/tls_socket.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "extensions/browser/api/api_resource.h" 11 #include "extensions/browser/api/api_resource.h"
12 #include "net/base/address_list.h" 12 #include "net/base/address_list.h"
13 #include "net/base/ip_endpoint.h" 13 #include "net/base/ip_endpoint.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/base/net_util.h" 15 #include "net/base/net_util.h"
16 #include "net/base/rand_callback.h" 16 #include "net/base/rand_callback.h"
17 #include "net/socket/client_socket_factory.h" 17 #include "net/socket/client_socket_factory.h"
18 #include "net/socket/client_socket_handle.h" 18 #include "net/socket/client_socket_handle.h"
19 #include "net/socket/ssl_client_socket.h" 19 #include "net/socket/ssl_client_socket.h"
20 #include "net/socket/tcp_client_socket.h" 20 #include "net/socket/tcp_client_socket.h"
21 #include "url/url_canon.h" 21 #include "url/url_canon.h"
22 22
23 namespace { 23 namespace {
24 24
25 // Returns the SSL protocol version (as a uint16) represented by a string. 25 // Returns the SSL protocol version (as a uint16_t) represented by a string.
26 // Returns 0 if the string is invalid. 26 // Returns 0 if the string is invalid.
27 uint16 SSLProtocolVersionFromString(const std::string& version_str) { 27 uint16_t SSLProtocolVersionFromString(const std::string& version_str) {
28 uint16 version = 0; // Invalid. 28 uint16_t version = 0; // Invalid.
29 if (version_str == "tls1") { 29 if (version_str == "tls1") {
30 version = net::SSL_PROTOCOL_VERSION_TLS1; 30 version = net::SSL_PROTOCOL_VERSION_TLS1;
31 } else if (version_str == "tls1.1") { 31 } else if (version_str == "tls1.1") {
32 version = net::SSL_PROTOCOL_VERSION_TLS1_1; 32 version = net::SSL_PROTOCOL_VERSION_TLS1_1;
33 } else if (version_str == "tls1.2") { 33 } else if (version_str == "tls1.2") {
34 version = net::SSL_PROTOCOL_VERSION_TLS1_2; 34 version = net::SSL_PROTOCOL_VERSION_TLS1_2;
35 } 35 }
36 return version; 36 return version;
37 } 37 }
38 38
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 141
142 bool TLSSocket::SetKeepAlive(bool enable, int delay) { 142 bool TLSSocket::SetKeepAlive(bool enable, int delay) {
143 return false; 143 return false;
144 } 144 }
145 145
146 bool TLSSocket::SetNoDelay(bool no_delay) { 146 bool TLSSocket::SetNoDelay(bool no_delay) {
147 return false; 147 return false;
148 } 148 }
149 149
150 int TLSSocket::Listen(const std::string& address, 150 int TLSSocket::Listen(const std::string& address,
151 uint16 port, 151 uint16_t port,
152 int backlog, 152 int backlog,
153 std::string* error_msg) { 153 std::string* error_msg) {
154 *error_msg = kTLSSocketTypeInvalidError; 154 *error_msg = kTLSSocketTypeInvalidError;
155 return net::ERR_NOT_IMPLEMENTED; 155 return net::ERR_NOT_IMPLEMENTED;
156 } 156 }
157 157
158 void TLSSocket::Accept(const AcceptCompletionCallback& callback) { 158 void TLSSocket::Accept(const AcceptCompletionCallback& callback) {
159 callback.Run(net::ERR_FAILED, NULL); 159 callback.Run(net::ERR_FAILED, NULL);
160 } 160 }
161 161
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 239
240 DCHECK(transport_security_state); 240 DCHECK(transport_security_state);
241 net::SSLClientSocketContext context; 241 net::SSLClientSocketContext context;
242 context.cert_verifier = cert_verifier; 242 context.cert_verifier = cert_verifier;
243 context.transport_security_state = transport_security_state; 243 context.transport_security_state = transport_security_state;
244 244
245 // Fill in the SSL socket params. 245 // Fill in the SSL socket params.
246 net::SSLConfig ssl_config; 246 net::SSLConfig ssl_config;
247 ssl_config_service->GetSSLConfig(&ssl_config); 247 ssl_config_service->GetSSLConfig(&ssl_config);
248 if (options && options->tls_version.get()) { 248 if (options && options->tls_version.get()) {
249 uint16 version_min = 0, version_max = 0; 249 uint16_t version_min = 0, version_max = 0;
250 api::socket::TLSVersionConstraints* versions = options->tls_version.get(); 250 api::socket::TLSVersionConstraints* versions = options->tls_version.get();
251 if (versions->min.get()) { 251 if (versions->min.get()) {
252 version_min = SSLProtocolVersionFromString(*versions->min.get()); 252 version_min = SSLProtocolVersionFromString(*versions->min.get());
253 } 253 }
254 if (versions->max.get()) { 254 if (versions->max.get()) {
255 version_max = SSLProtocolVersionFromString(*versions->max.get()); 255 version_max = SSLProtocolVersionFromString(*versions->max.get());
256 } 256 }
257 if (version_min) { 257 if (version_min) {
258 ssl_config.version_min = version_min; 258 ssl_config.version_min = version_min;
259 } 259 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 if (status != net::OK) { 299 if (status != net::OK) {
300 DVLOG(1) << "Status is not OK or IO-pending: " 300 DVLOG(1) << "Status is not OK or IO-pending: "
301 << net::ErrorToString(status); 301 << net::ErrorToString(status);
302 } 302 }
303 connect_cb.Run(status); 303 connect_cb.Run(status);
304 } 304 }
305 } 305 }
306 306
307 } // namespace extensions 307 } // namespace extensions
308 308
OLDNEW
« no previous file with comments | « extensions/browser/api/socket/tls_socket.h ('k') | extensions/browser/api/socket/udp_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698