client_socket_pool_manager_impl.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. #ifndef NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_
  5. #define NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_
  6. #include <map>
  7. #include <memory>
  8. #include <string>
  9. #include <type_traits>
  10. #include "base/compiler_specific.h"
  11. #include "base/memory/ref_counted.h"
  12. #include "base/threading/thread_checker.h"
  13. #include "base/values.h"
  14. #include "net/base/net_export.h"
  15. #include "net/http/http_network_session.h"
  16. #include "net/socket/client_socket_pool_manager.h"
  17. #include "net/socket/connect_job.h"
  18. namespace net {
  19. class ProxyServer;
  20. class ClientSocketPool;
  21. class NET_EXPORT_PRIVATE ClientSocketPoolManagerImpl
  22. : public ClientSocketPoolManager {
  23. public:
  24. // |websocket_common_connect_job_params| is only used for direct WebSocket
  25. // connections (No proxy in use). It's never used if |pool_type| is not
  26. // HttpNetworkSession::SocketPoolType::WEBSOCKET_SOCKET_POOL.
  27. ClientSocketPoolManagerImpl(
  28. const CommonConnectJobParams& common_connect_job_params,
  29. const CommonConnectJobParams& websocket_common_connect_job_params,
  30. HttpNetworkSession::SocketPoolType pool_type,
  31. bool cleanup_on_ip_address_change = true);
  32. ClientSocketPoolManagerImpl(const ClientSocketPoolManagerImpl&) = delete;
  33. ClientSocketPoolManagerImpl& operator=(const ClientSocketPoolManagerImpl&) =
  34. delete;
  35. ~ClientSocketPoolManagerImpl() override;
  36. void FlushSocketPoolsWithError(int net_error,
  37. const char* net_log_reason_utf8) override;
  38. void CloseIdleSockets(const char* net_log_reason_utf8) override;
  39. ClientSocketPool* GetSocketPool(const ProxyServer& proxy_server) override;
  40. // Creates a Value summary of the state of the socket pools.
  41. base::Value SocketPoolInfoToValue() const override;
  42. private:
  43. using SocketPoolMap =
  44. std::map<ProxyServer, std::unique_ptr<ClientSocketPool>>;
  45. const CommonConnectJobParams common_connect_job_params_;
  46. // Used only for direct WebSocket connections (i.e., no proxy in use).
  47. const CommonConnectJobParams websocket_common_connect_job_params_;
  48. const HttpNetworkSession::SocketPoolType pool_type_;
  49. const bool cleanup_on_ip_address_change_;
  50. SocketPoolMap socket_pools_;
  51. THREAD_CHECKER(thread_checker_);
  52. };
  53. } // namespace net
  54. #endif // NET_SOCKET_CLIENT_SOCKET_POOL_MANAGER_IMPL_H_