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

Side by Side Diff: blimp/net/ssl_client_transport.cc

Issue 2632803002: Remove all blimp network code. (Closed)
Patch Set: merge from origin/master for good measure Created 3 years, 11 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 | « blimp/net/ssl_client_transport.h ('k') | blimp/net/ssl_client_transport_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/net/ssl_client_transport.h"
6
7 #include <utility>
8
9 #include "base/callback.h"
10 #include "base/callback_helpers.h"
11 #include "blimp/net/exact_match_cert_verifier.h"
12 #include "net/base/host_port_pair.h"
13 #include "net/cert/x509_certificate.h"
14 #include "net/socket/client_socket_factory.h"
15 #include "net/socket/client_socket_handle.h"
16 #include "net/socket/ssl_client_socket.h"
17 #include "net/socket/stream_socket.h"
18 #include "net/socket/tcp_client_socket.h"
19 #include "net/ssl/ssl_config.h"
20
21 namespace blimp {
22
23 SSLClientTransport::SSLClientTransport(const net::IPEndPoint& ip_endpoint,
24 scoped_refptr<net::X509Certificate> cert,
25 net::NetLog* net_log)
26 : TCPClientTransport(ip_endpoint, net_log), ip_endpoint_(ip_endpoint) {
27 // Test code may pass in a null value for |cert|. Only spin up a CertVerifier
28 // if there is a cert present.
29 if (cert) {
30 cert_verifier_.reset(new ExactMatchCertVerifier(std::move(cert)));
31 }
32 }
33
34 SSLClientTransport::~SSLClientTransport() {}
35
36 const char* SSLClientTransport::GetName() const {
37 return "SSL";
38 }
39
40 void SSLClientTransport::OnTCPConnectComplete(int result) {
41 DCHECK_NE(net::ERR_IO_PENDING, result);
42
43 std::unique_ptr<net::StreamSocket> tcp_socket =
44 TCPClientTransport::TakeSocket();
45
46 DVLOG(1) << "TCP connection result=" << result;
47 if (result != net::OK) {
48 OnConnectComplete(result);
49 return;
50 }
51
52 // Construct arguments to use for the SSL socket factory.
53 std::unique_ptr<net::ClientSocketHandle> socket_handle(
54 new net::ClientSocketHandle);
55 socket_handle->SetSocket(std::move(tcp_socket));
56
57 net::HostPortPair host_port_pair =
58 net::HostPortPair::FromIPEndPoint(ip_endpoint_);
59
60 net::SSLClientSocketContext create_context;
61 create_context.cert_verifier = cert_verifier_.get();
62 create_context.transport_security_state = &transport_security_state_;
63 create_context.ct_policy_enforcer = &ct_policy_enforcer_;
64 create_context.cert_transparency_verifier = &cert_transparency_verifier_;
65
66 std::unique_ptr<net::StreamSocket> ssl_socket(
67 socket_factory()->CreateSSLClientSocket(std::move(socket_handle),
68 host_port_pair, net::SSLConfig(),
69 create_context));
70
71 if (!ssl_socket) {
72 OnConnectComplete(net::ERR_SSL_PROTOCOL_ERROR);
73 return;
74 }
75
76 result = ssl_socket->Connect(base::Bind(
77 &SSLClientTransport::OnSSLConnectComplete, base::Unretained(this)));
78 SetSocket(std::move(ssl_socket));
79
80 if (result == net::ERR_IO_PENDING) {
81 // SSL connection will complete asynchronously.
82 return;
83 }
84
85 OnSSLConnectComplete(result);
86 }
87
88 void SSLClientTransport::OnSSLConnectComplete(int result) {
89 DCHECK_NE(net::ERR_IO_PENDING, result);
90 DVLOG(1) << "SSL connection result=" << result;
91
92 OnConnectComplete(result);
93 }
94
95 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/net/ssl_client_transport.h ('k') | blimp/net/ssl_client_transport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698