OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/client_socket_factory.h" | 5 #include "net/socket/client_socket_factory.h" |
6 | 6 |
7 #include "base/singleton.h" | 7 #include "base/singleton.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "net/socket/ssl_client_socket_win.h" | 10 #include "net/socket/ssl_client_socket_win.h" |
11 #elif defined(OS_LINUX) | 11 #elif defined(USE_NSS) |
12 #include "net/socket/ssl_client_socket_nss.h" | 12 #include "net/socket/ssl_client_socket_nss.h" |
13 #elif defined(OS_MACOSX) | 13 #elif defined(OS_MACOSX) |
14 #include "net/socket/ssl_client_socket_mac.h" | 14 #include "net/socket/ssl_client_socket_mac.h" |
15 #endif | 15 #endif |
16 #include "net/socket/tcp_client_socket.h" | 16 #include "net/socket/tcp_client_socket.h" |
17 | 17 |
18 namespace net { | 18 namespace net { |
19 | 19 |
20 class DefaultClientSocketFactory : public ClientSocketFactory { | 20 class DefaultClientSocketFactory : public ClientSocketFactory { |
21 public: | 21 public: |
22 virtual ClientSocket* CreateTCPClientSocket( | 22 virtual ClientSocket* CreateTCPClientSocket( |
23 const AddressList& addresses) { | 23 const AddressList& addresses) { |
24 return new TCPClientSocket(addresses); | 24 return new TCPClientSocket(addresses); |
25 } | 25 } |
26 | 26 |
27 virtual SSLClientSocket* CreateSSLClientSocket( | 27 virtual SSLClientSocket* CreateSSLClientSocket( |
28 ClientSocket* transport_socket, | 28 ClientSocket* transport_socket, |
29 const std::string& hostname, | 29 const std::string& hostname, |
30 const SSLConfig& ssl_config) { | 30 const SSLConfig& ssl_config) { |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
32 return new SSLClientSocketWin(transport_socket, hostname, ssl_config); | 32 return new SSLClientSocketWin(transport_socket, hostname, ssl_config); |
33 #elif defined(OS_LINUX) | 33 #elif defined(USE_NSS) |
34 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config); | 34 return new SSLClientSocketNSS(transport_socket, hostname, ssl_config); |
35 #elif defined(OS_MACOSX) | 35 #elif defined(OS_MACOSX) |
36 return new SSLClientSocketMac(transport_socket, hostname, ssl_config); | 36 return new SSLClientSocketMac(transport_socket, hostname, ssl_config); |
37 #else | 37 #else |
38 NOTIMPLEMENTED(); | 38 NOTIMPLEMENTED(); |
39 return NULL; | 39 return NULL; |
40 #endif | 40 #endif |
41 } | 41 } |
42 }; | 42 }; |
43 | 43 |
44 // static | 44 // static |
45 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { | 45 ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() { |
46 return Singleton<DefaultClientSocketFactory>::get(); | 46 return Singleton<DefaultClientSocketFactory>::get(); |
47 } | 47 } |
48 | 48 |
49 } // namespace net | 49 } // namespace net |
OLD | NEW |