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

Unified Diff: net/socket/client_socket_pool_base.cc

Issue 169643006: Use sockets with unread data if they've never been used before. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mmenke comments Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/client_socket_pool_base.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/client_socket_pool_base.cc
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index e20b355dafe3297d2e8601a7fa3485d7164bf582..9e1abf482a5b6180abfa57031fe2cf80c5376a3c 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -448,7 +448,7 @@ bool ClientSocketPoolBaseHelper::AssignIdleSocketToRequest(
// the |idle_socket_it| will be set to the newest used idle socket.
for (std::list<IdleSocket>::iterator it = idle_sockets->begin();
it != idle_sockets->end();) {
- if (!it->socket->IsConnectedAndIdle()) {
+ if (!it->IsUsable()) {
DecrementIdleCount();
delete it->socket;
it = idle_sockets->erase(it);
@@ -648,15 +648,19 @@ base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue(
return dict;
}
+bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const {
+ if (socket->WasEverUsed())
+ return socket->IsConnectedAndIdle();
+ return socket->IsConnected();
+}
+
bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup(
base::TimeTicks now,
base::TimeDelta timeout) const {
bool timed_out = (now - start_time) >= timeout;
if (timed_out)
return true;
- if (socket->WasEverUsed())
- return !socket->IsConnectedAndIdle();
- return !socket->IsConnected();
+ return !IsUsable();
}
void ClientSocketPoolBaseHelper::CleanupIdleSockets(bool force) {
« no previous file with comments | « net/socket/client_socket_pool_base.h ('k') | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698