Home | History | Annotate | Download | only in http
      1 // Copyright (c) 2011 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 #include "net/http/http_network_session_peer.h"
      6 
      7 #include "net/http/http_network_session.h"
      8 #include "net/http/http_proxy_client_socket_pool.h"
      9 #include "net/proxy/proxy_service.h"
     10 #include "net/socket/socks_client_socket_pool.h"
     11 #include "net/socket/ssl_client_socket_pool.h"
     12 #include "net/socket/transport_client_socket_pool.h"
     13 
     14 namespace net {
     15 
     16 HttpNetworkSessionPeer::HttpNetworkSessionPeer(
     17     const scoped_refptr<HttpNetworkSession>& session)
     18     : session_(session) {}
     19 
     20 HttpNetworkSessionPeer::~HttpNetworkSessionPeer() {}
     21 
     22 void HttpNetworkSessionPeer::SetTransportSocketPool(
     23     TransportClientSocketPool* pool) {
     24   session_->socket_pool_manager_.transport_socket_pool_.reset(pool);
     25 }
     26 
     27 void HttpNetworkSessionPeer::SetSocketPoolForSOCKSProxy(
     28     const HostPortPair& socks_proxy,
     29     SOCKSClientSocketPool* pool) {
     30   ClientSocketPoolManager* socket_pool_manager =
     31       &session_->socket_pool_manager_;
     32 
     33   // Call through the public interface to force initialization of the
     34   // wrapped socket pools.
     35   delete socket_pool_manager->GetSocketPoolForSOCKSProxy(socks_proxy);
     36   socket_pool_manager->socks_socket_pools_[socks_proxy] = pool;
     37 }
     38 
     39 void HttpNetworkSessionPeer::SetSocketPoolForHTTPProxy(
     40     const HostPortPair& http_proxy,
     41     HttpProxyClientSocketPool* pool) {
     42   ClientSocketPoolManager* socket_pool_manager =
     43       &session_->socket_pool_manager_;
     44 
     45   // Call through the public interface to force initialization of the
     46   // wrapped socket pools.
     47   delete socket_pool_manager->GetSocketPoolForHTTPProxy(http_proxy);
     48   socket_pool_manager->http_proxy_socket_pools_[http_proxy] = pool;
     49 }
     50 
     51 void HttpNetworkSessionPeer::SetSSLSocketPool(SSLClientSocketPool* pool) {
     52   session_->socket_pool_manager_.ssl_socket_pool_.reset(pool);
     53 }
     54 
     55 void HttpNetworkSessionPeer::SetSocketPoolForSSLWithProxy(
     56     const HostPortPair& proxy_host,
     57     SSLClientSocketPool* pool) {
     58   ClientSocketPoolManager* socket_pool_manager =
     59       &session_->socket_pool_manager_;
     60 
     61   // Call through the public interface to force initialization of the
     62   // wrapped socket pools.
     63   delete socket_pool_manager->GetSocketPoolForSSLWithProxy(proxy_host);
     64   socket_pool_manager->ssl_socket_pools_for_proxies_[proxy_host] = pool;
     65 }
     66 
     67 void HttpNetworkSessionPeer::SetProxyService(ProxyService* proxy_service) {
     68   session_->proxy_service_ = proxy_service;
     69 }
     70 
     71 void HttpNetworkSessionPeer::SetHttpStreamFactory(
     72     HttpStreamFactory* http_stream_factory) {
     73   session_->http_stream_factory_.reset(http_stream_factory);
     74 }
     75 
     76 }  // namespace net
     77