| 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" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 555 |
| 556 return i->second->idle_sockets().size(); | 556 return i->second->idle_sockets().size(); |
| 557 } | 557 } |
| 558 | 558 |
| 559 LoadState ClientSocketPoolBaseHelper::GetLoadState( | 559 LoadState ClientSocketPoolBaseHelper::GetLoadState( |
| 560 const std::string& group_name, | 560 const std::string& group_name, |
| 561 const ClientSocketHandle* handle) const { | 561 const ClientSocketHandle* handle) const { |
| 562 if (ContainsKey(pending_callback_map_, handle)) | 562 if (ContainsKey(pending_callback_map_, handle)) |
| 563 return LOAD_STATE_CONNECTING; | 563 return LOAD_STATE_CONNECTING; |
| 564 | 564 |
| 565 if (!ContainsKey(group_map_, group_name)) { | 565 GroupMap::const_iterator group_it = group_map_.find(group_name); |
| 566 NOTREACHED() << "ClientSocketPool does not contain group: " << group_name | 566 // TODO(mmenke): Switch to DCHECK once sure this doesn't break anything. |
| 567 << " for handle: " << handle; | 567 // Added in M43. |
| 568 return LOAD_STATE_IDLE; | 568 CHECK(group_it != group_map_.end()); |
| 569 } | 569 const Group& group = *group_it->second; |
| 570 | |
| 571 // Can't use operator[] since it is non-const. | |
| 572 const Group& group = *group_map_.find(group_name)->second; | |
| 573 | 570 |
| 574 if (group.HasConnectJobForHandle(handle)) { | 571 if (group.HasConnectJobForHandle(handle)) { |
| 575 // Just return the state of the farthest along ConnectJob for the first | 572 // Just return the state of the farthest along ConnectJob for the first |
| 576 // group.jobs().size() pending requests. | 573 // group.jobs().size() pending requests. |
| 577 LoadState max_state = LOAD_STATE_IDLE; | 574 LoadState max_state = LOAD_STATE_IDLE; |
| 578 for (ConnectJobSet::const_iterator job_it = group.jobs().begin(); | 575 for (const auto& job : group.jobs()) { |
| 579 job_it != group.jobs().end(); ++job_it) { | 576 max_state = std::max(max_state, job->GetLoadState()); |
| 580 max_state = std::max(max_state, (*job_it)->GetLoadState()); | |
| 581 } | 577 } |
| 582 return max_state; | 578 return max_state; |
| 583 } | 579 } |
| 584 | 580 |
| 585 if (group.IsStalledOnPoolMaxSockets(max_sockets_per_group_)) | 581 if (group.IsStalledOnPoolMaxSockets(max_sockets_per_group_)) |
| 586 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; | 582 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; |
| 587 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; | 583 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; |
| 588 } | 584 } |
| 589 | 585 |
| 590 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( | 586 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 pending_requests_.Erase(pointer); | 1322 pending_requests_.Erase(pointer); |
| 1327 // If there are no more requests, kill the backup timer. | 1323 // If there are no more requests, kill the backup timer. |
| 1328 if (pending_requests_.empty()) | 1324 if (pending_requests_.empty()) |
| 1329 backup_job_timer_.Stop(); | 1325 backup_job_timer_.Stop(); |
| 1330 return request.Pass(); | 1326 return request.Pass(); |
| 1331 } | 1327 } |
| 1332 | 1328 |
| 1333 } // namespace internal | 1329 } // namespace internal |
| 1334 | 1330 |
| 1335 } // namespace net | 1331 } // namespace net |
| OLD | NEW |