| OLD | NEW |
| 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/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/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 ConnectJob::ConnectJob(const std::string& group_name, | 34 ConnectJob::ConnectJob(const std::string& group_name, |
| 35 const ClientSocketHandle* key_handle, | 35 const ClientSocketHandle* key_handle, |
| 36 base::TimeDelta timeout_duration, | 36 base::TimeDelta timeout_duration, |
| 37 Delegate* delegate, | 37 Delegate* delegate, |
| 38 LoadLog* load_log) | 38 LoadLog* load_log) |
| 39 : group_name_(group_name), | 39 : group_name_(group_name), |
| 40 key_handle_(key_handle), | 40 key_handle_(key_handle), |
| 41 timeout_duration_(timeout_duration), | 41 timeout_duration_(timeout_duration), |
| 42 delegate_(delegate), | 42 delegate_(delegate), |
| 43 load_state_(LOAD_STATE_IDLE), | |
| 44 load_log_(load_log) { | 43 load_log_(load_log) { |
| 45 DCHECK(!group_name.empty()); | 44 DCHECK(!group_name.empty()); |
| 46 DCHECK(key_handle); | 45 DCHECK(key_handle); |
| 47 DCHECK(delegate); | 46 DCHECK(delegate); |
| 48 } | 47 } |
| 49 | 48 |
| 50 ConnectJob::~ConnectJob() { | 49 ConnectJob::~ConnectJob() { |
| 51 if (delegate_) { | 50 if (delegate_) { |
| 52 // If the delegate was not NULLed, then NotifyDelegateOfCompletion has | 51 // If the delegate was not NULLed, then NotifyDelegateOfCompletion has |
| 53 // not been called yet (hence we are cancelling). | 52 // not been called yet (hence we are cancelling). |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const Group& group = group_map_.find(group_name)->second; | 305 const Group& group = group_map_.find(group_name)->second; |
| 307 | 306 |
| 308 // Search connecting_requests for matching handle. | 307 // Search connecting_requests for matching handle. |
| 309 RequestMap::const_iterator map_it = group.connecting_requests.find(handle); | 308 RequestMap::const_iterator map_it = group.connecting_requests.find(handle); |
| 310 if (map_it != group.connecting_requests.end()) { | 309 if (map_it != group.connecting_requests.end()) { |
| 311 ConnectJobMap::const_iterator job_it = connect_job_map_.find(handle); | 310 ConnectJobMap::const_iterator job_it = connect_job_map_.find(handle); |
| 312 if (job_it == connect_job_map_.end()) { | 311 if (job_it == connect_job_map_.end()) { |
| 313 NOTREACHED(); | 312 NOTREACHED(); |
| 314 return LOAD_STATE_IDLE; | 313 return LOAD_STATE_IDLE; |
| 315 } | 314 } |
| 316 return job_it->second->load_state(); | 315 return job_it->second->GetLoadState(); |
| 317 } | 316 } |
| 318 | 317 |
| 319 // Search pending_requests for matching handle. | 318 // Search pending_requests for matching handle. |
| 320 RequestQueue::const_iterator it = group.pending_requests.begin(); | 319 RequestQueue::const_iterator it = group.pending_requests.begin(); |
| 321 for (size_t i = 0; it != group.pending_requests.end(); ++it, ++i) { | 320 for (size_t i = 0; it != group.pending_requests.end(); ++it, ++i) { |
| 322 if ((*it)->handle() == handle) { | 321 if ((*it)->handle() == handle) { |
| 323 if (g_late_binding && i < group.jobs.size()) { | 322 if (g_late_binding && i < group.jobs.size()) { |
| 324 LoadState max_state = LOAD_STATE_IDLE; | 323 LoadState max_state = LOAD_STATE_IDLE; |
| 325 for (ConnectJobSet::const_iterator job_it = group.jobs.begin(); | 324 for (ConnectJobSet::const_iterator job_it = group.jobs.begin(); |
| 326 job_it != group.jobs.end(); ++job_it) { | 325 job_it != group.jobs.end(); ++job_it) { |
| 327 max_state = std::max(max_state, (*job_it)->load_state()); | 326 max_state = std::max(max_state, (*job_it)->GetLoadState()); |
| 328 } | 327 } |
| 329 return max_state; | 328 return max_state; |
| 330 } else { | 329 } else { |
| 331 // TODO(wtc): Add a state for being on the wait list. | 330 // TODO(wtc): Add a state for being on the wait list. |
| 332 // See http://www.crbug.com/5077. | 331 // See http://www.crbug.com/5077. |
| 333 return LOAD_STATE_IDLE; | 332 return LOAD_STATE_IDLE; |
| 334 } | 333 } |
| 335 } | 334 } |
| 336 } | 335 } |
| 337 | 336 |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return total == max_sockets_; | 645 return total == max_sockets_; |
| 647 } | 646 } |
| 648 | 647 |
| 649 } // namespace internal | 648 } // namespace internal |
| 650 | 649 |
| 651 void EnableLateBindingOfSockets(bool enabled) { | 650 void EnableLateBindingOfSockets(bool enabled) { |
| 652 internal::ClientSocketPoolBaseHelper::EnableLateBindingOfSockets(enabled); | 651 internal::ClientSocketPoolBaseHelper::EnableLateBindingOfSockets(enabled); |
| 653 } | 652 } |
| 654 | 653 |
| 655 } // namespace net | 654 } // namespace net |
| OLD | NEW |