diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-21 21:08:35 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-21 21:08:35 +0000 |
commit | 100d5fb906712b03495b961c35f9c9b21381a74a (patch) | |
tree | 284b84c9e6baba6da57427243a8b7729f67cb132 /net/socket/client_socket_pool_base.h | |
parent | 92683b5a068ab7c7f58251dbee9b047314977bae (diff) | |
download | chromium_src-100d5fb906712b03495b961c35f9c9b21381a74a.zip chromium_src-100d5fb906712b03495b961c35f9c9b21381a74a.tar.gz chromium_src-100d5fb906712b03495b961c35f9c9b21381a74a.tar.bz2 |
Detects network changes. Only for Mac OS X so far. Hooks up TCPClientSocketPool to flush idle sockets on IP address change.
BUG=http://crbug.com/26156
TEST=Run chrome with both network cable and wireless on. Go to www.google.com, twice. Verify second time via chrome://net-internals that the second request did not need a TCP_CONNECT_JOB, since we reused idle sockets. Unplug network cable. This should flush idle sockets. Go back to www.google.com. Check chrome://net-internals. Verify that there is a TCP_CONNECT_JOB for that request, because there was no idle socket to reuse.
Review URL: http://codereview.chromium.org/460149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35107 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base.h')
-rw-r--r-- | net/socket/client_socket_pool_base.h | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h index 897ffec..b21bfb8 100644 --- a/net/socket/client_socket_pool_base.h +++ b/net/socket/client_socket_pool_base.h @@ -28,6 +28,7 @@ #include <string> #include "base/basictypes.h" +#include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/time.h" #include "base/timer.h" @@ -36,6 +37,7 @@ #include "net/base/load_log.h" #include "net/base/load_states.h" #include "net/base/net_errors.h" +#include "net/base/network_change_notifier.h" #include "net/base/request_priority.h" #include "net/socket/client_socket.h" #include "net/socket/client_socket_pool.h" @@ -121,7 +123,8 @@ namespace internal { // ClientSocketPoolBase instead. class ClientSocketPoolBaseHelper : public base::RefCounted<ClientSocketPoolBaseHelper>, - public ConnectJob::Delegate { + public ConnectJob::Delegate, + public NetworkChangeNotifier::Observer { public: class Request { public: @@ -163,11 +166,13 @@ class ClientSocketPoolBaseHelper DISALLOW_COPY_AND_ASSIGN(ConnectJobFactory); }; - ClientSocketPoolBaseHelper(int max_sockets, - int max_sockets_per_group, - base::TimeDelta unused_idle_socket_timeout, - base::TimeDelta used_idle_socket_timeout, - ConnectJobFactory* connect_job_factory); + ClientSocketPoolBaseHelper( + int max_sockets, + int max_sockets_per_group, + base::TimeDelta unused_idle_socket_timeout, + base::TimeDelta used_idle_socket_timeout, + ConnectJobFactory* connect_job_factory, + const scoped_refptr<NetworkChangeNotifier>& network_change_notifier); // See ClientSocketPool::RequestSocket for documentation on this function. // Note that |request| must be heap allocated. If ERR_IO_PENDING is returned, @@ -201,6 +206,9 @@ class ClientSocketPoolBaseHelper // ConnectJob::Delegate methods: virtual void OnConnectJobComplete(int result, ConnectJob* job); + // NetworkChangeNotifier::Observer methods: + virtual void OnIPAddressChanged(); + // Enables late binding of sockets. In this mode, socket requests are // decoupled from socket connection jobs. A socket request may initiate a // socket connection job, but there is no guarantee that that socket @@ -385,9 +393,10 @@ class ClientSocketPoolBaseHelper const scoped_ptr<ConnectJobFactory> connect_job_factory_; + const scoped_refptr<NetworkChangeNotifier> network_change_notifier_; + // Controls whether or not we use late binding of sockets. static bool g_late_binding; - }; } // namespace internal @@ -441,15 +450,18 @@ class ClientSocketPoolBase { // long to leave an unused idle socket open before closing it. // |used_idle_socket_timeout| specifies how long to leave a previously used // idle socket open before closing it. - ClientSocketPoolBase(int max_sockets, - int max_sockets_per_group, - base::TimeDelta unused_idle_socket_timeout, - base::TimeDelta used_idle_socket_timeout, - ConnectJobFactory* connect_job_factory) + ClientSocketPoolBase( + int max_sockets, + int max_sockets_per_group, + base::TimeDelta unused_idle_socket_timeout, + base::TimeDelta used_idle_socket_timeout, + ConnectJobFactory* connect_job_factory, + const scoped_refptr<NetworkChangeNotifier>& network_change_notifier) : helper_(new internal::ClientSocketPoolBaseHelper( max_sockets, max_sockets_per_group, unused_idle_socket_timeout, used_idle_socket_timeout, - new ConnectJobFactoryAdaptor(connect_job_factory))) {} + new ConnectJobFactoryAdaptor(connect_job_factory), + network_change_notifier)) {} virtual ~ClientSocketPoolBase() {} |