1 // Copyright 2011 The Chromium Authors 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_MOCK_CLIENT_SOCKET_POOL_MANAGER_H_ 6 #define NET_SOCKET_MOCK_CLIENT_SOCKET_POOL_MANAGER_H_ 7 8 #include <map> 9 #include <memory> 10 #include <string> 11 12 #include "net/base/proxy_chain.h" 13 #include "net/socket/client_socket_pool_manager.h" 14 #include "net/socket/client_socket_pool_manager_impl.h" 15 16 namespace net { 17 18 class ClientSocketPool; 19 20 class MockClientSocketPoolManager : public ClientSocketPoolManager { 21 public: 22 MockClientSocketPoolManager(); 23 24 MockClientSocketPoolManager(const MockClientSocketPoolManager&) = delete; 25 MockClientSocketPoolManager& operator=(const MockClientSocketPoolManager&) = 26 delete; 27 28 ~MockClientSocketPoolManager() override; 29 30 // Sets socket pool that gets used for the specified ProxyChain. 31 void SetSocketPool(const ProxyChain& proxy_chain, 32 std::unique_ptr<ClientSocketPool> pool); 33 34 // ClientSocketPoolManager methods: 35 void FlushSocketPoolsWithError(int error, 36 const char* net_log_reason_utf8) override; 37 void CloseIdleSockets(const char* net_log_reason_utf8) override; 38 ClientSocketPool* GetSocketPool(const ProxyChain& proxy_chain) override; 39 base::Value SocketPoolInfoToValue() const override; 40 41 private: 42 using ClientSocketPoolMap = 43 std::map<ProxyChain, std::unique_ptr<ClientSocketPool>>; 44 45 ClientSocketPoolMap socket_pools_; 46 }; 47 48 } // namespace net 49 50 #endif // NET_SOCKET_MOCK_CLIENT_SOCKET_POOL_MANAGER_H_ 51