Home | History | Annotate | Download | only in socket
      1 // Copyright (c) 2010 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 #ifndef NET_SOCKET_CLIENT_SOCKET_FACTORY_H_
      6 #define NET_SOCKET_CLIENT_SOCKET_FACTORY_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/basictypes.h"
     12 #include "net/base/net_log.h"
     13 
     14 namespace net {
     15 
     16 class AddressList;
     17 class CertVerifier;
     18 class ClientSocket;
     19 class ClientSocketHandle;
     20 class DnsCertProvenanceChecker;
     21 class HostPortPair;
     22 class SSLClientSocket;
     23 struct SSLConfig;
     24 class SSLHostInfo;
     25 
     26 // An interface used to instantiate ClientSocket objects.  Used to facilitate
     27 // testing code with mock socket implementations.
     28 class ClientSocketFactory {
     29  public:
     30   virtual ~ClientSocketFactory() {}
     31 
     32   // |source| is the NetLog::Source for the entity trying to create the socket,
     33   // if it has one.
     34   virtual ClientSocket* CreateTransportClientSocket(
     35       const AddressList& addresses,
     36       NetLog* net_log,
     37       const NetLog::Source& source) = 0;
     38 
     39   virtual SSLClientSocket* CreateSSLClientSocket(
     40       ClientSocketHandle* transport_socket,
     41       const HostPortPair& host_and_port,
     42       const SSLConfig& ssl_config,
     43       SSLHostInfo* ssl_host_info,
     44       CertVerifier* cert_verifier,
     45       DnsCertProvenanceChecker* dns_cert_checker) = 0;
     46 
     47   // Deprecated function (http://crbug.com/37810) that takes a ClientSocket.
     48   virtual SSLClientSocket* CreateSSLClientSocket(
     49       ClientSocket* transport_socket,
     50       const HostPortPair& host_and_port,
     51       const SSLConfig& ssl_config,
     52       SSLHostInfo* ssl_host_info,
     53       CertVerifier* cert_verifier);
     54 
     55   // Clears cache used for SSL session resumption.
     56   virtual void ClearSSLSessionCache() = 0;
     57 
     58   // Returns the default ClientSocketFactory.
     59   static ClientSocketFactory* GetDefaultFactory();
     60 
     61   // Instructs the default ClientSocketFactory to use the system SSL library.
     62   static void UseSystemSSL();
     63 };
     64 
     65 }  // namespace net
     66 
     67 #endif  // NET_SOCKET_CLIENT_SOCKET_FACTORY_H_
     68