Home | History | Annotate | Download | only in http
      1 // Copyright (c) 2009 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.h"
      6 
      7 #include "base/logging.h"
      8 #include "net/flip/flip_session_pool.h"
      9 
     10 namespace net {
     11 
     12 // static
     13 int HttpNetworkSession::max_sockets_ = 100;
     14 
     15 // static
     16 int HttpNetworkSession::max_sockets_per_group_ = 6;
     17 
     18 // static
     19 uint16 HttpNetworkSession::g_fixed_http_port = 0;
     20 uint16 HttpNetworkSession::g_fixed_https_port = 0;
     21 
     22 HttpNetworkSession::HttpNetworkSession(
     23     NetworkChangeNotifier* network_change_notifier,
     24     HostResolver* host_resolver,
     25     ProxyService* proxy_service,
     26     ClientSocketFactory* client_socket_factory,
     27     SSLConfigService* ssl_config_service,
     28     FlipSessionPool* flip_session_pool)
     29     : network_change_notifier_(network_change_notifier),
     30       tcp_socket_pool_(new TCPClientSocketPool(
     31           max_sockets_, max_sockets_per_group_,
     32           host_resolver, client_socket_factory, network_change_notifier_)),
     33       socket_factory_(client_socket_factory),
     34       host_resolver_(host_resolver),
     35       proxy_service_(proxy_service),
     36       ssl_config_service_(ssl_config_service),
     37       flip_session_pool_(flip_session_pool) {
     38   DCHECK(proxy_service);
     39   DCHECK(ssl_config_service);
     40 }
     41 
     42 HttpNetworkSession::~HttpNetworkSession() {
     43 }
     44 
     45 // static
     46 void HttpNetworkSession::set_max_sockets_per_group(int socket_count) {
     47   DCHECK(0 < socket_count);
     48   // The following is a sanity check... but we should NEVER be near this value.
     49   DCHECK(100 > socket_count);
     50   max_sockets_per_group_ = socket_count;
     51 }
     52 
     53 void HttpNetworkSession::ReplaceTCPSocketPool() {
     54   tcp_socket_pool_ = new TCPClientSocketPool(max_sockets_,
     55                                              max_sockets_per_group_,
     56                                              host_resolver_,
     57                                              socket_factory_,
     58                                              network_change_notifier_);
     59 }
     60 
     61 } //  namespace net
     62