Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(354)

Side by Side Diff: net/http/http_network_session.cc

Issue 1604045: Fix crash on IP address change. (Closed)
Patch Set: Merge conflict Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_session.h ('k') | net/http/http_network_session_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_network_session.h" 5 #include "net/http/http_network_session.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/http/http_auth_handler_factory.h" 8 #include "net/http/http_auth_handler_factory.h"
9 #include "net/http/url_security_manager.h" 9 #include "net/http/url_security_manager.h"
10 #include "net/spdy/spdy_session_pool.h" 10 #include "net/spdy/spdy_session_pool.h"
(...skipping 11 matching lines...) Expand all
22 uint16 HttpNetworkSession::g_fixed_https_port = 0; 22 uint16 HttpNetworkSession::g_fixed_https_port = 0;
23 23
24 // TODO(vandebo) when we've completely converted to pools, the base TCP 24 // TODO(vandebo) when we've completely converted to pools, the base TCP
25 // pool name should get changed to TCP instead of Transport. 25 // pool name should get changed to TCP instead of Transport.
26 HttpNetworkSession::HttpNetworkSession( 26 HttpNetworkSession::HttpNetworkSession(
27 NetworkChangeNotifier* network_change_notifier, 27 NetworkChangeNotifier* network_change_notifier,
28 HostResolver* host_resolver, 28 HostResolver* host_resolver,
29 ProxyService* proxy_service, 29 ProxyService* proxy_service,
30 ClientSocketFactory* client_socket_factory, 30 ClientSocketFactory* client_socket_factory,
31 SSLConfigService* ssl_config_service, 31 SSLConfigService* ssl_config_service,
32 SpdySessionPool* spdy_session_pool,
32 HttpAuthHandlerFactory* http_auth_handler_factory) 33 HttpAuthHandlerFactory* http_auth_handler_factory)
33 : network_change_notifier_(network_change_notifier), 34 : network_change_notifier_(network_change_notifier),
35 tcp_socket_pool_(new TCPClientSocketPool(
36 max_sockets_, max_sockets_per_group_, "Transport",
37 host_resolver, client_socket_factory, network_change_notifier_)),
38 socks_socket_pool_(new SOCKSClientSocketPool(
39 max_sockets_, max_sockets_per_group_, "SOCKS", host_resolver,
40 new TCPClientSocketPool(max_sockets_, max_sockets_per_group_,
41 "TCPForSOCKS", host_resolver,
42 client_socket_factory,
43 network_change_notifier_),
44 network_change_notifier_)),
34 socket_factory_(client_socket_factory), 45 socket_factory_(client_socket_factory),
35 host_resolver_(host_resolver), 46 host_resolver_(host_resolver),
36 tcp_socket_pool_(CreateNewTCPSocketPool()),
37 socks_socket_pool_(CreateNewSOCKSSocketPool()),
38 proxy_service_(proxy_service), 47 proxy_service_(proxy_service),
39 ssl_config_service_(ssl_config_service), 48 ssl_config_service_(ssl_config_service),
40 spdy_session_pool_(new SpdySessionPool()), 49 spdy_session_pool_(spdy_session_pool),
41 http_auth_handler_factory_(http_auth_handler_factory) { 50 http_auth_handler_factory_(http_auth_handler_factory) {
42 DCHECK(proxy_service); 51 DCHECK(proxy_service);
43 DCHECK(ssl_config_service); 52 DCHECK(ssl_config_service);
44
45 if (network_change_notifier)
46 network_change_notifier_->AddObserver(this);
47 } 53 }
48 54
49 HttpNetworkSession::~HttpNetworkSession() { 55 HttpNetworkSession::~HttpNetworkSession() {
50 if (network_change_notifier_)
51 network_change_notifier_->RemoveObserver(this);
52 } 56 }
53 57
54 // static 58 // static
55 void HttpNetworkSession::set_max_sockets_per_group(int socket_count) { 59 void HttpNetworkSession::set_max_sockets_per_group(int socket_count) {
56 DCHECK_LT(0, socket_count); 60 DCHECK(0 < socket_count);
57 // The following is a sanity check... but we should NEVER be near this value. 61 // The following is a sanity check... but we should NEVER be near this value.
58 DCHECK_GT(100, socket_count); 62 DCHECK(100 > socket_count);
59 max_sockets_per_group_ = socket_count; 63 max_sockets_per_group_ = socket_count;
60 } 64 }
61 65
62 void HttpNetworkSession::Flush() { 66 // TODO(vandebo) when we've completely converted to pools, the base TCP
63 host_resolver()->Flush(); 67 // pool name should get changed to TCP instead of Transport.
64 tcp_socket_pool()->CloseIdleSockets(); 68 void HttpNetworkSession::ReplaceTCPSocketPool() {
65 tcp_socket_pool_ = CreateNewTCPSocketPool(); 69 tcp_socket_pool_ = new TCPClientSocketPool(max_sockets_,
66 socks_socket_pool()->CloseIdleSockets(); 70 max_sockets_per_group_,
67 socks_socket_pool_ = CreateNewSOCKSSocketPool(); 71 "Transport",
68 spdy_session_pool_->CloseAllSessions(); 72 host_resolver_,
69 spdy_session_pool_ = new SpdySessionPool; 73 socket_factory_,
70 } 74 network_change_notifier_);
71
72 void HttpNetworkSession::OnIPAddressChanged() {
73 Flush();
74 }
75
76 scoped_refptr<TCPClientSocketPool>
77 HttpNetworkSession::CreateNewTCPSocketPool() {
78 // TODO(vandebo) when we've completely converted to pools, the base TCP
79 // pool name should get changed to TCP instead of Transport.
80 return new TCPClientSocketPool(max_sockets_,
81 max_sockets_per_group_,
82 "Transport",
83 host_resolver_,
84 socket_factory_);
85 }
86
87 scoped_refptr<SOCKSClientSocketPool>
88 HttpNetworkSession::CreateNewSOCKSSocketPool() {
89 return new SOCKSClientSocketPool(
90 max_sockets_, max_sockets_per_group_, "SOCKS", host_resolver_,
91 new TCPClientSocketPool(max_sockets_, max_sockets_per_group_,
92 "TCPForSOCKS", host_resolver_,
93 socket_factory_));
94 } 75 }
95 76
96 } // namespace net 77 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_session.h ('k') | net/http/http_network_session_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698