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

Side by Side Diff: net/base/client_socket_pool.cc

Issue 99205: Add a histogram to measure the number of idle sockets when a TCP connection is established. (Closed)
Patch Set: Use a const ref (woops!) instead of copying a string. Add comments. Created 11 years, 7 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/base/client_socket_pool.h ('k') | net/http/http_network_transaction.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/base/client_socket_pool.h" 5 #include "net/base/client_socket_pool.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "net/base/client_socket.h" 8 #include "net/base/client_socket.h"
9 #include "net/base/client_socket_handle.h" 9 #include "net/base/client_socket_handle.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // NOTE: We cannot refer to the handle argument after this method returns. 115 // NOTE: We cannot refer to the handle argument after this method returns.
116 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 116 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
117 this, &ClientSocketPool::DoReleaseSocket, handle->group_name_, 117 this, &ClientSocketPool::DoReleaseSocket, handle->group_name_,
118 handle->socket_)); 118 handle->socket_));
119 } 119 }
120 120
121 void ClientSocketPool::CloseIdleSockets() { 121 void ClientSocketPool::CloseIdleSockets() {
122 CleanupIdleSockets(true); 122 CleanupIdleSockets(true);
123 } 123 }
124 124
125 int ClientSocketPool::IdleSocketCountInGroup(
126 const std::string& group_name) const {
127 GroupMap::const_iterator i = group_map_.find(group_name);
128 DCHECK(i != group_map_.end());
129
130 return i->second.idle_sockets.size();
131 }
132
125 bool ClientSocketPool::IdleSocket::ShouldCleanup(base::TimeTicks now) const { 133 bool ClientSocketPool::IdleSocket::ShouldCleanup(base::TimeTicks now) const {
126 bool timed_out = (now - start_time) >= 134 bool timed_out = (now - start_time) >=
127 base::TimeDelta::FromSeconds(kIdleTimeout); 135 base::TimeDelta::FromSeconds(kIdleTimeout);
128 return timed_out || !(*ptr)->IsConnectedAndIdle(); 136 return timed_out || !(*ptr)->IsConnectedAndIdle();
129 } 137 }
130 138
131 void ClientSocketPool::CleanupIdleSockets(bool force) { 139 void ClientSocketPool::CleanupIdleSockets(bool force) {
132 if (idle_socket_count_ == 0) 140 if (idle_socket_count_ == 0)
133 return; 141 return;
134 142
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 } 213 }
206 214
207 // Delete group if no longer needed. 215 // Delete group if no longer needed.
208 if (group.active_socket_count == 0 && group.idle_sockets.empty()) { 216 if (group.active_socket_count == 0 && group.idle_sockets.empty()) {
209 DCHECK(group.pending_requests.empty()); 217 DCHECK(group.pending_requests.empty());
210 group_map_.erase(i); 218 group_map_.erase(i);
211 } 219 }
212 } 220 }
213 221
214 } // namespace net 222 } // namespace net
OLDNEW
« no previous file with comments | « net/base/client_socket_pool.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698