| 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.h" | 10 #include "base/message_loop.h" |
| (...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 553 |
| 554 if (!ContainsKey(group_map_, group_name)) { | 554 if (!ContainsKey(group_map_, group_name)) { |
| 555 NOTREACHED() << "ClientSocketPool does not contain group: " << group_name | 555 NOTREACHED() << "ClientSocketPool does not contain group: " << group_name |
| 556 << " for handle: " << handle; | 556 << " for handle: " << handle; |
| 557 return LOAD_STATE_IDLE; | 557 return LOAD_STATE_IDLE; |
| 558 } | 558 } |
| 559 | 559 |
| 560 // Can't use operator[] since it is non-const. | 560 // Can't use operator[] since it is non-const. |
| 561 const Group& group = *group_map_.find(group_name)->second; | 561 const Group& group = *group_map_.find(group_name)->second; |
| 562 | 562 |
| 563 // Search pending_requests for matching handle. | 563 // Search the first group.jobs().size() |pending_requests| for |handle|. |
| 564 // If it's farther back in the deque than that, it doesn't have a |
| 565 // corresponding ConnectJob. |
| 566 size_t connect_jobs = group.jobs().size(); |
| 564 RequestQueue::const_iterator it = group.pending_requests().begin(); | 567 RequestQueue::const_iterator it = group.pending_requests().begin(); |
| 565 for (size_t i = 0; it != group.pending_requests().end(); ++it, ++i) { | 568 for (size_t i = 0; it != group.pending_requests().end() && i < connect_jobs; |
| 566 if ((*it)->handle() == handle) { | 569 ++it, ++i) { |
| 567 if (i < group.jobs().size()) { | 570 if ((*it)->handle() != handle) |
| 568 LoadState max_state = LOAD_STATE_IDLE; | 571 continue; |
| 569 for (ConnectJobSet::const_iterator job_it = group.jobs().begin(); | 572 |
| 570 job_it != group.jobs().end(); ++job_it) { | 573 // Just return the state of the farthest along ConnectJob for the first |
| 571 max_state = std::max(max_state, (*job_it)->GetLoadState()); | 574 // group.jobs().size() pending requests. |
| 572 } | 575 LoadState max_state = LOAD_STATE_IDLE; |
| 573 return max_state; | 576 for (ConnectJobSet::const_iterator job_it = group.jobs().begin(); |
| 574 } else { | 577 job_it != group.jobs().end(); ++job_it) { |
| 575 // TODO(wtc): Add a state for being on the wait list. | 578 max_state = std::max(max_state, (*job_it)->GetLoadState()); |
| 576 // See http://crbug.com/5077. | |
| 577 return LOAD_STATE_IDLE; | |
| 578 } | |
| 579 } | 579 } |
| 580 return max_state; |
| 580 } | 581 } |
| 581 | 582 |
| 582 NOTREACHED(); | 583 if (group.IsStalledOnPoolMaxSockets(max_sockets_per_group_)) |
| 583 return LOAD_STATE_IDLE; | 584 return LOAD_STATE_WAITING_FOR_STALLED_SOCKET_POOL; |
| 585 return LOAD_STATE_WAITING_FOR_AVAILABLE_SOCKET; |
| 584 } | 586 } |
| 585 | 587 |
| 586 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( | 588 base::DictionaryValue* ClientSocketPoolBaseHelper::GetInfoAsValue( |
| 587 const std::string& name, const std::string& type) const { | 589 const std::string& name, const std::string& type) const { |
| 588 base::DictionaryValue* dict = new base::DictionaryValue(); | 590 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 589 dict->SetString("name", name); | 591 dict->SetString("name", name); |
| 590 dict->SetString("type", type); | 592 dict->SetString("type", type); |
| 591 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); | 593 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); |
| 592 dict->SetInteger("connecting_socket_count", connecting_socket_count_); | 594 dict->SetInteger("connecting_socket_count", connecting_socket_count_); |
| 593 dict->SetInteger("idle_socket_count", idle_socket_count_); | 595 dict->SetInteger("idle_socket_count", idle_socket_count_); |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 STLDeleteElements(&jobs_); | 1244 STLDeleteElements(&jobs_); |
| 1243 unassigned_job_count_ = 0; | 1245 unassigned_job_count_ = 0; |
| 1244 | 1246 |
| 1245 // Cancel pending backup job. | 1247 // Cancel pending backup job. |
| 1246 weak_factory_.InvalidateWeakPtrs(); | 1248 weak_factory_.InvalidateWeakPtrs(); |
| 1247 } | 1249 } |
| 1248 | 1250 |
| 1249 } // namespace internal | 1251 } // namespace internal |
| 1250 | 1252 |
| 1251 } // namespace net | 1253 } // namespace net |
| OLD | NEW |