summaryrefslogtreecommitdiffstats
path: root/net/socket
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 22:40:42 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-14 22:40:42 +0000
commit7af985a498165e9ba74d7e428be4ffe9a054f053 (patch)
tree88a20282a57a9b0bffc1d99f34e0ba7ae65f4063 /net/socket
parentab108f2658ea9da9572085ea8bd501505f3f38c5 (diff)
downloadchromium_src-7af985a498165e9ba74d7e428be4ffe9a054f053.zip
chromium_src-7af985a498165e9ba74d7e428be4ffe9a054f053.tar.gz
chromium_src-7af985a498165e9ba74d7e428be4ffe9a054f053.tar.bz2
Introduce ERR_NETWORK_CHANGED and allow URLFetcher to automatically retry on that error.
BUG=164363 Review URL: https://codereview.chromium.org/11464028 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173227 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket')
-rw-r--r--net/socket/client_socket_pool.h9
-rw-r--r--net/socket/client_socket_pool_base.cc12
-rw-r--r--net/socket/client_socket_pool_base.h16
-rw-r--r--net/socket/client_socket_pool_base_unittest.cc12
-rw-r--r--net/socket/client_socket_pool_manager.h2
-rw-r--r--net/socket/client_socket_pool_manager_impl.cc24
-rw-r--r--net/socket/client_socket_pool_manager_impl.h2
-rw-r--r--net/socket/mock_client_socket_pool_manager.cc2
-rw-r--r--net/socket/mock_client_socket_pool_manager.h2
-rw-r--r--net/socket/socks_client_socket_pool.cc4
-rw-r--r--net/socket/socks_client_socket_pool.h2
-rw-r--r--net/socket/ssl_client_socket_pool.cc6
-rw-r--r--net/socket/ssl_client_socket_pool.h2
-rw-r--r--net/socket/transport_client_socket_pool.cc4
-rw-r--r--net/socket/transport_client_socket_pool.h2
-rw-r--r--net/socket/transport_client_socket_pool_unittest.cc2
16 files changed, 52 insertions, 51 deletions
diff --git a/net/socket/client_socket_pool.h b/net/socket/client_socket_pool.h
index 1d2246c..7a274b7 100644
--- a/net/socket/client_socket_pool.h
+++ b/net/socket/client_socket_pool.h
@@ -115,10 +115,11 @@ class NET_EXPORT ClientSocketPool {
int id) = 0;
// This flushes all state from the ClientSocketPool. This means that all
- // idle and connecting sockets are discarded. Active sockets being
- // held by ClientSocketPool clients will be discarded when released back to
- // the pool. Does not flush any pools wrapped by |this|.
- virtual void Flush() = 0;
+ // idle and connecting sockets are discarded with the given |error|.
+ // Active sockets being held by ClientSocketPool clients will be discarded
+ // when released back to the pool.
+ // Does not flush any pools wrapped by |this|.
+ virtual void FlushWithError(int error) = 0;
// Returns true if a there is currently a request blocked on the
// per-pool (not per-host) max socket limit.
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index 0880724..3e9cd82 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -189,7 +189,7 @@ ClientSocketPoolBaseHelper::~ClientSocketPoolBaseHelper() {
// Clean up any idle sockets and pending connect jobs. Assert that we have no
// remaining active sockets or pending requests. They should have all been
// cleaned up prior to |this| being destroyed.
- Flush();
+ FlushWithError(ERR_ABORTED);
DCHECK(group_map_.empty());
DCHECK(pending_callback_map_.empty());
DCHECK_EQ(0, connecting_socket_count_);
@@ -903,14 +903,14 @@ void ClientSocketPoolBaseHelper::OnConnectJobComplete(
}
void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
- Flush();
+ FlushWithError(ERR_NETWORK_CHANGED);
}
-void ClientSocketPoolBaseHelper::Flush() {
+void ClientSocketPoolBaseHelper::FlushWithError(int error) {
pool_generation_number_++;
CancelAllConnectJobs();
CloseIdleSockets();
- AbortAllRequests();
+ CancelAllRequestsWithError(error);
}
bool ClientSocketPoolBaseHelper::IsStalled() const {
@@ -1031,7 +1031,7 @@ void ClientSocketPoolBaseHelper::CancelAllConnectJobs() {
DCHECK_EQ(0, connecting_socket_count_);
}
-void ClientSocketPoolBaseHelper::AbortAllRequests() {
+void ClientSocketPoolBaseHelper::CancelAllRequestsWithError(int error) {
for (GroupMap::iterator i = group_map_.begin(); i != group_map_.end();) {
Group* group = i->second;
@@ -1041,7 +1041,7 @@ void ClientSocketPoolBaseHelper::AbortAllRequests() {
it2 != pending_requests.end(); ++it2) {
scoped_ptr<const Request> request(*it2);
InvokeUserCallbackLater(
- request->handle(), request->callback(), ERR_ABORTED);
+ request->handle(), request->callback(), error);
}
// Delete group if no longer needed.
diff --git a/net/socket/client_socket_pool_base.h b/net/socket/client_socket_pool_base.h
index e35ab29..39dbeb0 100644
--- a/net/socket/client_socket_pool_base.h
+++ b/net/socket/client_socket_pool_base.h
@@ -242,8 +242,8 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
StreamSocket* socket,
int id);
- // See ClientSocketPool::Flush for documentation on this function.
- void Flush();
+ // See ClientSocketPool::FlushWithError for documentation on this function.
+ void FlushWithError(int error);
// See ClientSocketPool::IsStalled for documentation on this function.
bool IsStalled() const;
@@ -505,9 +505,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
// groups if they are no longer needed.
void CancelAllConnectJobs();
- // Iterates through |group_map_|, posting ERR_ABORTED callbacks for all
+ // Iterates through |group_map_|, posting |error| callbacks for all
// requests, and then deleting groups if they are no longer needed.
- void AbortAllRequests();
+ void CancelAllRequestsWithError(int error);
// Returns true if we can't create any more sockets due to the total limit.
bool ReachedMaxSocketsLimit() const;
@@ -584,9 +584,9 @@ class NET_EXPORT_PRIVATE ClientSocketPoolBaseHelper
// TODO(vandebo) Remove when backup jobs move to TransportClientSocketPool
bool connect_backup_jobs_enabled_;
- // A unique id for the pool. It gets incremented every time we Flush() the
- // pool. This is so that when sockets get released back to the pool, we can
- // make sure that they are discarded rather than reused.
+ // A unique id for the pool. It gets incremented every time we
+ // FlushWithError() the pool. This is so that when sockets get released back
+ // to the pool, we can make sure that they are discarded rather than reused.
int pool_generation_number_;
std::set<LayeredPool*> higher_layer_pools_;
@@ -708,7 +708,7 @@ class ClientSocketPoolBase {
return helper_.ReleaseSocket(group_name, socket, id);
}
- void Flush() { helper_.Flush(); }
+ void FlushWithError(int error) { helper_.FlushWithError(error); }
bool IsStalled() const { return helper_.IsStalled(); }
diff --git a/net/socket/client_socket_pool_base_unittest.cc b/net/socket/client_socket_pool_base_unittest.cc
index dbbeb5d..f55dadb 100644
--- a/net/socket/client_socket_pool_base_unittest.cc
+++ b/net/socket/client_socket_pool_base_unittest.cc
@@ -476,8 +476,8 @@ class TestClientSocketPool : public ClientSocketPool {
base_.ReleaseSocket(group_name, socket, id);
}
- virtual void Flush() OVERRIDE {
- base_.Flush();
+ virtual void FlushWithError(int error) OVERRIDE {
+ base_.FlushWithError(error);
}
virtual bool IsStalled() const OVERRIDE {
@@ -2486,7 +2486,7 @@ TEST_F(ClientSocketPoolBaseTest, CallbackThatReleasesPool) {
pool_.get(),
BoundNetLog()));
- pool_->Flush();
+ pool_->FlushWithError(ERR_NETWORK_CHANGED);
// We'll call back into this now.
callback.WaitForResult();
@@ -2507,7 +2507,7 @@ TEST_F(ClientSocketPoolBaseTest, DoNotReuseSocketAfterFlush) {
EXPECT_EQ(OK, callback.WaitForResult());
EXPECT_EQ(ClientSocketHandle::UNUSED, handle.reuse_type());
- pool_->Flush();
+ pool_->FlushWithError(ERR_NETWORK_CHANGED);
handle.Reset();
MessageLoop::current()->RunUntilIdle();
@@ -2584,8 +2584,8 @@ TEST_F(ClientSocketPoolBaseTest, AbortAllRequestsOnFlush) {
// Second job will be started during the first callback, and will
// asynchronously complete with OK.
connect_job_factory_->set_job_type(TestConnectJob::kMockPendingJob);
- pool_->Flush();
- EXPECT_EQ(ERR_ABORTED, callback.WaitForResult());
+ pool_->FlushWithError(ERR_NETWORK_CHANGED);
+ EXPECT_EQ(ERR_NETWORK_CHANGED, callback.WaitForResult());
EXPECT_EQ(OK, callback.WaitForNestedResult());
}
diff --git a/net/socket/client_socket_pool_manager.h b/net/socket/client_socket_pool_manager.h
index 69d77e4..a92d218 100644
--- a/net/socket/client_socket_pool_manager.h
+++ b/net/socket/client_socket_pool_manager.h
@@ -67,7 +67,7 @@ class NET_EXPORT_PRIVATE ClientSocketPoolManager {
HttpNetworkSession::SocketPoolType pool_type,
int socket_count);
- virtual void FlushSocketPools() = 0;
+ virtual void FlushSocketPoolsWithError(int error) = 0;
virtual void CloseIdleSockets() = 0;
virtual TransportClientSocketPool* GetTransportSocketPool() = 0;
virtual SSLClientSocketPool* GetSSLSocketPool() = 0;
diff --git a/net/socket/client_socket_pool_manager_impl.cc b/net/socket/client_socket_pool_manager_impl.cc
index a91bca9..bd46652 100644
--- a/net/socket/client_socket_pool_manager_impl.cc
+++ b/net/socket/client_socket_pool_manager_impl.cc
@@ -90,7 +90,7 @@ ClientSocketPoolManagerImpl::~ClientSocketPoolManagerImpl() {
CertDatabase::GetInstance()->RemoveObserver(this);
}
-void ClientSocketPoolManagerImpl::FlushSocketPools() {
+void ClientSocketPoolManagerImpl::FlushSocketPoolsWithError(int error) {
// Flush the highest level pools first, since higher level pools may release
// stuff to the lower level pools.
@@ -98,46 +98,46 @@ void ClientSocketPoolManagerImpl::FlushSocketPools() {
ssl_socket_pools_for_proxies_.begin();
it != ssl_socket_pools_for_proxies_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (HTTPProxySocketPoolMap::const_iterator it =
http_proxy_socket_pools_.begin();
it != http_proxy_socket_pools_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (SSLSocketPoolMap::const_iterator it =
ssl_socket_pools_for_https_proxies_.begin();
it != ssl_socket_pools_for_https_proxies_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (TransportSocketPoolMap::const_iterator it =
transport_socket_pools_for_https_proxies_.begin();
it != transport_socket_pools_for_https_proxies_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (TransportSocketPoolMap::const_iterator it =
transport_socket_pools_for_http_proxies_.begin();
it != transport_socket_pools_for_http_proxies_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (SOCKSSocketPoolMap::const_iterator it =
socks_socket_pools_.begin();
it != socks_socket_pools_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
for (TransportSocketPoolMap::const_iterator it =
transport_socket_pools_for_socks_proxies_.begin();
it != transport_socket_pools_for_socks_proxies_.end();
++it)
- it->second->Flush();
+ it->second->FlushWithError(error);
- ssl_socket_pool_->Flush();
- transport_socket_pool_->Flush();
+ ssl_socket_pool_->FlushWithError(error);
+ transport_socket_pool_->FlushWithError(error);
}
void ClientSocketPoolManagerImpl::CloseIdleSockets() {
@@ -372,7 +372,7 @@ Value* ClientSocketPoolManagerImpl::SocketPoolInfoToValue() const {
}
void ClientSocketPoolManagerImpl::OnCertAdded(const X509Certificate* cert) {
- FlushSocketPools();
+ FlushSocketPoolsWithError(ERR_NETWORK_CHANGED);
}
void ClientSocketPoolManagerImpl::OnCertTrustChanged(
@@ -387,7 +387,7 @@ void ClientSocketPoolManagerImpl::OnCertTrustChanged(
// Since the OnCertTrustChanged method doesn't tell us what
// kind of trust change it is, we have to flush the socket
// pools to be safe.
- FlushSocketPools();
+ FlushSocketPoolsWithError(ERR_NETWORK_CHANGED);
}
} // namespace net
diff --git a/net/socket/client_socket_pool_manager_impl.h b/net/socket/client_socket_pool_manager_impl.h
index 1b0de1d..ff5e5a2 100644
--- a/net/socket/client_socket_pool_manager_impl.h
+++ b/net/socket/client_socket_pool_manager_impl.h
@@ -68,7 +68,7 @@ class ClientSocketPoolManagerImpl : public base::NonThreadSafe,
HttpNetworkSession::SocketPoolType pool_type);
virtual ~ClientSocketPoolManagerImpl();
- virtual void FlushSocketPools() OVERRIDE;
+ virtual void FlushSocketPoolsWithError(int error) OVERRIDE;
virtual void CloseIdleSockets() OVERRIDE;
virtual TransportClientSocketPool* GetTransportSocketPool() OVERRIDE;
diff --git a/net/socket/mock_client_socket_pool_manager.cc b/net/socket/mock_client_socket_pool_manager.cc
index 7cb9b5b..0496adb 100644
--- a/net/socket/mock_client_socket_pool_manager.cc
+++ b/net/socket/mock_client_socket_pool_manager.cc
@@ -42,7 +42,7 @@ void MockClientSocketPoolManager::SetSocketPoolForSSLWithProxy(
ssl_socket_pools_for_proxies_[proxy_server] = pool;
}
-void MockClientSocketPoolManager::FlushSocketPools() {
+void MockClientSocketPoolManager::FlushSocketPoolsWithError(int error) {
NOTIMPLEMENTED();
}
diff --git a/net/socket/mock_client_socket_pool_manager.h b/net/socket/mock_client_socket_pool_manager.h
index 5db6506..c2c3792 100644
--- a/net/socket/mock_client_socket_pool_manager.h
+++ b/net/socket/mock_client_socket_pool_manager.h
@@ -27,7 +27,7 @@ class MockClientSocketPoolManager : public ClientSocketPoolManager {
SSLClientSocketPool* pool);
// ClientSocketPoolManager methods:
- virtual void FlushSocketPools() OVERRIDE;
+ virtual void FlushSocketPoolsWithError(int error) OVERRIDE;
virtual void CloseIdleSockets() OVERRIDE;
virtual TransportClientSocketPool* GetTransportSocketPool() OVERRIDE;
virtual SSLClientSocketPool* GetSSLSocketPool() OVERRIDE;
diff --git a/net/socket/socks_client_socket_pool.cc b/net/socket/socks_client_socket_pool.cc
index a7c7ecb..dc181e4 100644
--- a/net/socket/socks_client_socket_pool.cc
+++ b/net/socket/socks_client_socket_pool.cc
@@ -242,8 +242,8 @@ void SOCKSClientSocketPool::ReleaseSocket(const std::string& group_name,
base_.ReleaseSocket(group_name, socket, id);
}
-void SOCKSClientSocketPool::Flush() {
- base_.Flush();
+void SOCKSClientSocketPool::FlushWithError(int error) {
+ base_.FlushWithError(error);
}
bool SOCKSClientSocketPool::IsStalled() const {
diff --git a/net/socket/socks_client_socket_pool.h b/net/socket/socks_client_socket_pool.h
index 090c29f..96c48426 100644
--- a/net/socket/socks_client_socket_pool.h
+++ b/net/socket/socks_client_socket_pool.h
@@ -137,7 +137,7 @@ class NET_EXPORT_PRIVATE SOCKSClientSocketPool
StreamSocket* socket,
int id) OVERRIDE;
- virtual void Flush() OVERRIDE;
+ virtual void FlushWithError(int error) OVERRIDE;
virtual bool IsStalled() const OVERRIDE;
diff --git a/net/socket/ssl_client_socket_pool.cc b/net/socket/ssl_client_socket_pool.cc
index 21ebf97..30ad46e 100644
--- a/net/socket/ssl_client_socket_pool.cc
+++ b/net/socket/ssl_client_socket_pool.cc
@@ -530,8 +530,8 @@ void SSLClientSocketPool::ReleaseSocket(const std::string& group_name,
base_.ReleaseSocket(group_name, socket, id);
}
-void SSLClientSocketPool::Flush() {
- base_.Flush();
+void SSLClientSocketPool::FlushWithError(int error) {
+ base_.FlushWithError(error);
}
bool SSLClientSocketPool::IsStalled() const {
@@ -603,7 +603,7 @@ ClientSocketPoolHistograms* SSLClientSocketPool::histograms() const {
}
void SSLClientSocketPool::OnSSLConfigChanged() {
- Flush();
+ FlushWithError(ERR_NETWORK_CHANGED);
}
bool SSLClientSocketPool::CloseOneIdleConnection() {
diff --git a/net/socket/ssl_client_socket_pool.h b/net/socket/ssl_client_socket_pool.h
index 8802afc..6ee0155 100644
--- a/net/socket/ssl_client_socket_pool.h
+++ b/net/socket/ssl_client_socket_pool.h
@@ -206,7 +206,7 @@ class NET_EXPORT_PRIVATE SSLClientSocketPool
StreamSocket* socket,
int id) OVERRIDE;
- virtual void Flush() OVERRIDE;
+ virtual void FlushWithError(int error) OVERRIDE;
virtual bool IsStalled() const OVERRIDE;
diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc
index bc49d98..84e89c8 100644
--- a/net/socket/transport_client_socket_pool.cc
+++ b/net/socket/transport_client_socket_pool.cc
@@ -419,8 +419,8 @@ void TransportClientSocketPool::ReleaseSocket(
base_.ReleaseSocket(group_name, socket, id);
}
-void TransportClientSocketPool::Flush() {
- base_.Flush();
+void TransportClientSocketPool::FlushWithError(int error) {
+ base_.FlushWithError(error);
}
bool TransportClientSocketPool::IsStalled() const {
diff --git a/net/socket/transport_client_socket_pool.h b/net/socket/transport_client_socket_pool.h
index 7764b88..af14152 100644
--- a/net/socket/transport_client_socket_pool.h
+++ b/net/socket/transport_client_socket_pool.h
@@ -164,7 +164,7 @@ class NET_EXPORT_PRIVATE TransportClientSocketPool : public ClientSocketPool {
virtual void ReleaseSocket(const std::string& group_name,
StreamSocket* socket,
int id) OVERRIDE;
- virtual void Flush() OVERRIDE;
+ virtual void FlushWithError(int error) OVERRIDE;
virtual bool IsStalled() const OVERRIDE;
virtual void CloseIdleSockets() OVERRIDE;
virtual int IdleSocketCount() const OVERRIDE;
diff --git a/net/socket/transport_client_socket_pool_unittest.cc b/net/socket/transport_client_socket_pool_unittest.cc
index efeaa6e..aefe79c 100644
--- a/net/socket/transport_client_socket_pool_unittest.cc
+++ b/net/socket/transport_client_socket_pool_unittest.cc
@@ -983,7 +983,7 @@ TEST_F(TransportClientSocketPoolTest, BackupSocketConnect) {
handle.Reset();
// Close all pending connect jobs and existing sockets.
- pool_.Flush();
+ pool_.FlushWithError(ERR_NETWORK_CHANGED);
}
}