Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/socket/client_socket_pool_base.h" | 5 #include "net/socket/client_socket_pool_base.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/metrics/stats_counters.h" | 11 #include "base/metrics/stats_counters.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 17 #include "net/base/net_log.h" | 17 #include "net/base/net_log.h" |
| 18 #include "net/socket/ssl_client_socket_pool.h" | |
| 18 | 19 |
| 19 using base::TimeDelta; | 20 using base::TimeDelta; |
| 20 | 21 |
| 21 namespace net { | 22 namespace net { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 // Indicate whether we should enable idle socket cleanup timer. When timer is | 26 // Indicate whether we should enable idle socket cleanup timer. When timer is |
| 26 // disabled, sockets are closed next time a socket request is made. | 27 // disabled, sockets are closed next time a socket request is made. |
| 27 bool g_cleanup_timer_enabled = true; | 28 bool g_cleanup_timer_enabled = true; |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 536 RemoveConnectJob(*group->jobs().begin(), group); | 537 RemoveConnectJob(*group->jobs().begin(), group); |
| 537 CheckForStalledSocketGroups(); | 538 CheckForStalledSocketGroups(); |
| 538 } | 539 } |
| 539 } | 540 } |
| 540 } | 541 } |
| 541 | 542 |
| 542 bool ClientSocketPoolBaseHelper::HasGroup(const std::string& group_name) const { | 543 bool ClientSocketPoolBaseHelper::HasGroup(const std::string& group_name) const { |
| 543 return ContainsKey(group_map_, group_name); | 544 return ContainsKey(group_map_, group_name); |
| 544 } | 545 } |
| 545 | 546 |
| 547 void ClientSocketPoolBaseHelper::RemoveMessengersFromGroup( | |
| 548 const std::string& group_name, | |
| 549 const std::string& cache_key) const { | |
| 550 GroupMap::const_iterator it = group_map_.find(group_name); | |
| 551 if (it != group_map_.end()) | |
| 552 it->second->RemoveMessengers(cache_key); | |
| 553 } | |
| 554 | |
| 546 void ClientSocketPoolBaseHelper::CloseIdleSockets() { | 555 void ClientSocketPoolBaseHelper::CloseIdleSockets() { |
| 547 CleanupIdleSockets(true); | 556 CleanupIdleSockets(true); |
| 548 DCHECK_EQ(0, idle_socket_count_); | 557 DCHECK_EQ(0, idle_socket_count_); |
| 549 } | 558 } |
| 550 | 559 |
| 551 int ClientSocketPoolBaseHelper::IdleSocketCountInGroup( | 560 int ClientSocketPoolBaseHelper::IdleSocketCountInGroup( |
| 552 const std::string& group_name) const { | 561 const std::string& group_name) const { |
| 553 GroupMap::const_iterator i = group_map_.find(group_name); | 562 GroupMap::const_iterator i = group_map_.find(group_name); |
| 554 CHECK(i != group_map_.end()); | 563 CHECK(i != group_map_.end()); |
| 555 | 564 |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1251 SanityCheck(); | 1260 SanityCheck(); |
| 1252 | 1261 |
| 1253 // Delete active jobs. | 1262 // Delete active jobs. |
| 1254 STLDeleteElements(&jobs_); | 1263 STLDeleteElements(&jobs_); |
| 1255 unassigned_job_count_ = 0; | 1264 unassigned_job_count_ = 0; |
| 1256 | 1265 |
| 1257 // Stop backup job timer. | 1266 // Stop backup job timer. |
| 1258 backup_job_timer_.Stop(); | 1267 backup_job_timer_.Stop(); |
| 1259 } | 1268 } |
| 1260 | 1269 |
| 1270 void ClientSocketPoolBaseHelper::Group::RemoveMessengers( | |
| 1271 const std::string& cache_key) { | |
| 1272 for (std::set<ConnectJob*>::iterator it = jobs_.begin(); it != jobs_.end(); | |
| 1273 ++it) { | |
| 1274 SSLConnectJob* job = static_cast<SSLConnectJob*>(*it); | |
|
Ryan Sleevi
2014/08/12 00:27:42
This is definitely a layering violation
(It's a c
mshelley
2014/08/12 21:47:00
Done.
| |
| 1275 job->RemoveMessenger(cache_key); | |
| 1276 } | |
| 1277 } | |
| 1278 | |
| 1261 const ClientSocketPoolBaseHelper::Request* | 1279 const ClientSocketPoolBaseHelper::Request* |
| 1262 ClientSocketPoolBaseHelper::Group::GetNextPendingRequest() const { | 1280 ClientSocketPoolBaseHelper::Group::GetNextPendingRequest() const { |
| 1263 return | 1281 return |
| 1264 pending_requests_.empty() ? NULL : pending_requests_.FirstMax().value(); | 1282 pending_requests_.empty() ? NULL : pending_requests_.FirstMax().value(); |
| 1265 } | 1283 } |
| 1266 | 1284 |
| 1267 bool ClientSocketPoolBaseHelper::Group::HasConnectJobForHandle( | 1285 bool ClientSocketPoolBaseHelper::Group::HasConnectJobForHandle( |
| 1268 const ClientSocketHandle* handle) const { | 1286 const ClientSocketHandle* handle) const { |
| 1269 // Search the first |jobs_.size()| pending requests for |handle|. | 1287 // Search the first |jobs_.size()| pending requests for |handle|. |
| 1270 // If it's farther back in the deque than that, it doesn't have a | 1288 // If it's farther back in the deque than that, it doesn't have a |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1322 pending_requests_.Erase(pointer); | 1340 pending_requests_.Erase(pointer); |
| 1323 // If there are no more requests, kill the backup timer. | 1341 // If there are no more requests, kill the backup timer. |
| 1324 if (pending_requests_.empty()) | 1342 if (pending_requests_.empty()) |
| 1325 backup_job_timer_.Stop(); | 1343 backup_job_timer_.Stop(); |
| 1326 return request.Pass(); | 1344 return request.Pass(); |
| 1327 } | 1345 } |
| 1328 | 1346 |
| 1329 } // namespace internal | 1347 } // namespace internal |
| 1330 | 1348 |
| 1331 } // namespace net | 1349 } // namespace net |
| OLD | NEW |