diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 21:30:38 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 21:30:38 +0000 |
commit | 66761b95332549f825999e482c17c94675275f49 (patch) | |
tree | fc5307808a2c62f1eff2a9f37db3aff11c5455d9 /net/socket/client_socket_pool_base.cc | |
parent | e313f3b11360902a3da9b3b1cc0df2a4792d0867 (diff) | |
download | chromium_src-66761b95332549f825999e482c17c94675275f49.zip chromium_src-66761b95332549f825999e482c17c94675275f49.tar.gz chromium_src-66761b95332549f825999e482c17c94675275f49.tar.bz2 |
Massively simplify the NetworkChangeNotifier infrastructure:
* Use a process-wide object (singleton pattern)
* Create/destroy this object on the main thread, make it outlive all consumers
* Make observer-related functions threadsafe
As a result, the notifier can now be used by any thread (eliminating things like NetworkChangeObserverProxy and NetworkChangeNotifierProxy, and expanding its usefulness); its creation and inner workings are much simplified (eliminating implementation-specific classes); and it is simpler to access (eliminating things like NetworkChangeNotifierThread and a LOT of passing pointers around).
BUG=none
TEST=Unittests; network changes still trigger notifications
Review URL: http://codereview.chromium.org/2802015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50895 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base.cc')
-rw-r--r-- | net/socket/client_socket_pool_base.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc index 1ff2789..40daa35 100644 --- a/net/socket/client_socket_pool_base.cc +++ b/net/socket/client_socket_pool_base.cc @@ -128,8 +128,7 @@ ClientSocketPoolBaseHelper::ClientSocketPoolBaseHelper( int max_sockets_per_group, base::TimeDelta unused_idle_socket_timeout, base::TimeDelta used_idle_socket_timeout, - ConnectJobFactory* connect_job_factory, - NetworkChangeNotifier* network_change_notifier) + ConnectJobFactory* connect_job_factory) : idle_socket_count_(0), connecting_socket_count_(0), handed_out_socket_count_(0), @@ -140,15 +139,13 @@ ClientSocketPoolBaseHelper::ClientSocketPoolBaseHelper( used_idle_socket_timeout_(used_idle_socket_timeout), may_have_stalled_group_(false), connect_job_factory_(connect_job_factory), - network_change_notifier_(network_change_notifier), backup_jobs_enabled_(false), ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), pool_generation_number_(0) { DCHECK_LE(0, max_sockets_per_group); DCHECK_LE(max_sockets_per_group, max_sockets); - if (network_change_notifier_) - network_change_notifier_->AddObserver(this); + NetworkChangeNotifier::AddObserver(this); } ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() { @@ -161,8 +158,7 @@ ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() { CHECK(group_map_.empty()); DCHECK_EQ(0, connecting_socket_count_); - if (network_change_notifier_) - network_change_notifier_->RemoveObserver(this); + NetworkChangeNotifier::RemoveObserver(this); } // InsertRequestIntoQueue inserts the request into the queue based on @@ -383,8 +379,8 @@ void ClientSocketPoolBaseHelper::ReleaseSocket(const std::string& group_name, // Run this asynchronously to allow the caller to finish before we let // another to begin doing work. This also avoids nasty recursion issues. // NOTE: We cannot refer to the handle argument after this method returns. - MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( - this, &ClientSocketPoolBaseHelper::DoReleaseSocket, group_name, socket, id)); + MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(this, + &ClientSocketPoolBaseHelper::DoReleaseSocket, group_name, socket, id)); } void ClientSocketPoolBaseHelper::CloseIdleSockets() { @@ -640,6 +636,10 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete( } } +void ClientSocketPoolBaseHelper::OnIPAddressChanged() { + Flush(); +} + void ClientSocketPoolBaseHelper::Flush() { pool_generation_number_++; CancelAllConnectJobs(); |