summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_factory.cc
blob: fe2ce1044c7d76e1abccc91abbbe79536e7b8899 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/socket/client_socket_factory.h"

#include "base/singleton.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include "net/socket/ssl_client_socket_win.h"
#elif defined(OS_LINUX)
#include "net/socket/ssl_client_socket_nss.h"
#elif defined(OS_MACOSX)
#include "net/socket/ssl_client_socket_mac.h"
#endif
#include "net/socket/tcp_client_socket.h"

namespace net {

class DefaultClientSocketFactory : public ClientSocketFactory {
 public:
  virtual ClientSocket* CreateTCPClientSocket(
      const AddressList& addresses) {
    return new TCPClientSocket(addresses);
  }

  virtual SSLClientSocket* CreateSSLClientSocket(
      ClientSocket* transport_socket,
      const std::string& hostname,
      const SSLConfig& ssl_config) {
#if defined(OS_WIN)
    return new SSLClientSocketWin(transport_socket, hostname, ssl_config);
#elif defined(OS_LINUX)
    return new SSLClientSocketNSS(transport_socket, hostname, ssl_config);
#elif defined(OS_MACOSX)
    return new SSLClientSocketMac(transport_socket, hostname, ssl_config);
#else
    NOTIMPLEMENTED();
    return NULL;
#endif
  }
};

// static
ClientSocketFactory* ClientSocketFactory::GetDefaultFactory() {
  return Singleton<DefaultClientSocketFactory>::get();
}

}  // namespace net