| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 if (group_it == group_map_.end()) { | 565 if (group_it == group_map_.end()) { |
| 566 // TODO(mmenke): This is actually reached in the wild, for unknown reasons. | 566 // TODO(mmenke): This is actually reached in the wild, for unknown reasons. |
| 567 // Would be great to understand why, and if it's a bug, fix it. If not, | 567 // Would be great to understand why, and if it's a bug, fix it. If not, |
| 568 // should have a test for that case. | 568 // should have a test for that case. |
| 569 NOTREACHED(); | 569 NOTREACHED(); |
| 570 return LOAD_STATE_IDLE; | 570 return LOAD_STATE_IDLE; |
| 571 } | 571 } |
| 572 | 572 |
| 573 const Group& group = *group_it->second; | 573 const Group& group = *group_it->second; |
| 574 if (group.HasConnectJobForHandle(handle)) { | 574 if (group.HasConnectJobForHandle(handle)) { |
| 575 // Just return the state of the farthest along ConnectJob for the first | 575 // Instead of going through all the states in the underlying protocol |
| 576 // group.jobs().size() pending requests. | 576 // levels, just return the state of the oldest connect job, which is the |
| 577 LoadState max_state = LOAD_STATE_IDLE; | 577 // first in the set since the connect jobs are sorted in ascending order |
| 578 for (const auto& job : group.jobs()) { | 578 // by time. |
| 579 max_state = std::max(max_state, job->GetLoadState()); | 579 return (*group.jobs().begin())->GetLoadState(); |
| 580 } | |
| 581 return max_state; | |
| 582 } | 580 } |
| 583 | 581 |
| 584 if (group.CanUseAdditionalSocketSlot(max_sockets_per_group_)) | 582 if (group.CanUseAdditionalSocketSlot(max_sockets_per_group_)) |
| 585 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; | 583 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; |
| 586 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; | 584 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; |
| 587 } | 585 } |
| 588 | 586 |
| 589 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( | 587 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( |
| 590 const std::string& name, const std::string& type) const { | 588 const std::string& name, const std::string& type) const { |
| 591 base::DictionaryValue* dict = new base::DictionaryValue(); | 589 base::DictionaryValue* dict = new base::DictionaryValue(); |
| (...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 pending_requests_.Erase(pointer); | 1326 pending_requests_.Erase(pointer); |
| 1329 // If there are no more requests, kill the backup timer. | 1327 // If there are no more requests, kill the backup timer. |
| 1330 if (pending_requests_.empty()) | 1328 if (pending_requests_.empty()) |
| 1331 backup_job_timer_.Stop(); | 1329 backup_job_timer_.Stop(); |
| 1332 return request.Pass(); | 1330 return request.Pass(); |
| 1333 } | 1331 } |
| 1334 | 1332 |
| 1335 } // namespace internal | 1333 } // namespace internal |
| 1336 | 1334 |
| 1337 } // namespace net | 1335 } // namespace net |
| OLD | NEW |