OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "jingle/notifier/base/xmpp_client_socket_factory.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "jingle/notifier/base/fake_ssl_client_socket.h" | |
9 #include "jingle/notifier/base/proxy_resolving_client_socket.h" | |
10 #include "net/socket/client_socket_factory.h" | |
11 #include "net/socket/ssl_client_socket.h" | |
12 #include "net/url_request/url_request_context.h" | |
13 #include "net/url_request/url_request_context_getter.h" | |
14 | |
15 namespace notifier { | |
16 | |
17 XmppClientSocketFactory::XmppClientSocketFactory( | |
18 net::ClientSocketFactory* client_socket_factory, | |
19 const net::SSLConfig& ssl_config, | |
20 const scoped_refptr<net::URLRequestContextGetter>& request_context_getter, | |
21 bool use_fake_ssl_client_socket) | |
22 : client_socket_factory_(client_socket_factory), | |
23 request_context_getter_(request_context_getter), | |
24 ssl_config_(ssl_config), | |
25 use_fake_ssl_client_socket_(use_fake_ssl_client_socket) { | |
26 CHECK(client_socket_factory_); | |
27 } | |
28 | |
29 XmppClientSocketFactory::~XmppClientSocketFactory() {} | |
30 | |
31 net::StreamSocket* XmppClientSocketFactory::CreateTransportClientSocket( | |
32 const net::HostPortPair& host_and_port) { | |
33 // TODO(akalin): Use socket pools. | |
34 net::StreamSocket* transport_socket = new ProxyResolvingClientSocket( | |
35 NULL, | |
36 request_context_getter_, | |
37 ssl_config_, | |
38 host_and_port); | |
39 return (use_fake_ssl_client_socket_ ? | |
40 new FakeSSLClientSocket(transport_socket) : transport_socket); | |
41 } | |
42 | |
43 net::SSLClientSocket* XmppClientSocketFactory::CreateSSLClientSocket( | |
44 net::ClientSocketHandle* transport_socket, | |
45 const net::HostPortPair& host_and_port) { | |
46 net::SSLClientSocketContext context; | |
47 context.cert_verifier = | |
48 request_context_getter_->GetURLRequestContext()->cert_verifier(); | |
49 // TODO(rkn): context.server_bound_cert_service is NULL because the | |
50 // ServerBoundCertService class is not thread safe. | |
51 return client_socket_factory_->CreateSSLClientSocket( | |
52 transport_socket, host_and_port, ssl_config_, context); | |
53 } | |
54 | |
55 | |
56 } // namespace | |
OLD | NEW |