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 <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
10 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 DCHECK(delegate); | 65 DCHECK(delegate); |
65 net_log.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, | 66 net_log.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, |
66 NetLog::StringCallback("group_name", &group_name_)); | 67 NetLog::StringCallback("group_name", &group_name_)); |
67 } | 68 } |
68 | 69 |
69 ConnectJob::~ConnectJob() { | 70 ConnectJob::~ConnectJob() { |
70 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); | 71 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); |
71 } | 72 } |
72 | 73 |
73 scoped_ptr<StreamSocket> ConnectJob::PassSocket() { | 74 scoped_ptr<StreamSocket> ConnectJob::PassSocket() { |
74 return socket_.Pass(); | 75 return std::move(socket_); |
75 } | 76 } |
76 | 77 |
77 int ConnectJob::Connect() { | 78 int ConnectJob::Connect() { |
78 if (timeout_duration_ != base::TimeDelta()) | 79 if (timeout_duration_ != base::TimeDelta()) |
79 timer_.Start(FROM_HERE, timeout_duration_, this, &ConnectJob::OnTimeout); | 80 timer_.Start(FROM_HERE, timeout_duration_, this, &ConnectJob::OnTimeout); |
80 | 81 |
81 idle_ = false; | 82 idle_ = false; |
82 | 83 |
83 LogConnectStart(); | 84 LogConnectStart(); |
84 | 85 |
85 int rv = ConnectInternal(); | 86 int rv = ConnectInternal(); |
86 | 87 |
87 if (rv != ERR_IO_PENDING) { | 88 if (rv != ERR_IO_PENDING) { |
88 LogConnectCompletion(rv); | 89 LogConnectCompletion(rv); |
89 delegate_ = NULL; | 90 delegate_ = NULL; |
90 } | 91 } |
91 | 92 |
92 return rv; | 93 return rv; |
93 } | 94 } |
94 | 95 |
95 void ConnectJob::SetSocket(scoped_ptr<StreamSocket> socket) { | 96 void ConnectJob::SetSocket(scoped_ptr<StreamSocket> socket) { |
96 if (socket) { | 97 if (socket) { |
97 net_log().AddEvent(NetLog::TYPE_CONNECT_JOB_SET_SOCKET, | 98 net_log().AddEvent(NetLog::TYPE_CONNECT_JOB_SET_SOCKET, |
98 socket->NetLog().source().ToEventParametersCallback()); | 99 socket->NetLog().source().ToEventParametersCallback()); |
99 } | 100 } |
100 socket_ = socket.Pass(); | 101 socket_ = std::move(socket); |
101 } | 102 } |
102 | 103 |
103 void ConnectJob::NotifyDelegateOfCompletion(int rv) { | 104 void ConnectJob::NotifyDelegateOfCompletion(int rv) { |
104 // The delegate will own |this|. | 105 // The delegate will own |this|. |
105 Delegate* delegate = delegate_; | 106 Delegate* delegate = delegate_; |
106 delegate_ = NULL; | 107 delegate_ = NULL; |
107 | 108 |
108 LogConnectCompletion(rv); | 109 LogConnectCompletion(rv); |
109 delegate->OnConnectJobComplete(rv, this); | 110 delegate->OnConnectJobComplete(rv, this); |
110 } | 111 } |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 282 |
282 request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL); | 283 request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL); |
283 Group* group = GetOrCreateGroup(group_name); | 284 Group* group = GetOrCreateGroup(group_name); |
284 | 285 |
285 int rv = RequestSocketInternal(group_name, *request); | 286 int rv = RequestSocketInternal(group_name, *request); |
286 if (rv != ERR_IO_PENDING) { | 287 if (rv != ERR_IO_PENDING) { |
287 request->net_log().EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, rv); | 288 request->net_log().EndEventWithNetErrorCode(NetLog::TYPE_SOCKET_POOL, rv); |
288 CHECK(!request->handle()->is_initialized()); | 289 CHECK(!request->handle()->is_initialized()); |
289 request.reset(); | 290 request.reset(); |
290 } else { | 291 } else { |
291 group->InsertPendingRequest(request.Pass()); | 292 group->InsertPendingRequest(std::move(request)); |
292 // Have to do this asynchronously, as closing sockets in higher level pools | 293 // Have to do this asynchronously, as closing sockets in higher level pools |
293 // call back in to |this|, which will cause all sorts of fun and exciting | 294 // call back in to |this|, which will cause all sorts of fun and exciting |
294 // re-entrancy issues if the socket pool is doing something else at the | 295 // re-entrancy issues if the socket pool is doing something else at the |
295 // time. | 296 // time. |
296 if (group->CanUseAdditionalSocketSlot(max_sockets_per_group_)) { | 297 if (group->CanUseAdditionalSocketSlot(max_sockets_per_group_)) { |
297 base::ThreadTaskRunnerHandle::Get()->PostTask( | 298 base::ThreadTaskRunnerHandle::Get()->PostTask( |
298 FROM_HERE, | 299 FROM_HERE, |
299 base::Bind( | 300 base::Bind( |
300 &ClientSocketPoolBaseHelper::TryToCloseSocketsInLayeredPools, | 301 &ClientSocketPoolBaseHelper::TryToCloseSocketsInLayeredPools, |
301 weak_factory_.GetWeakPtr())); | 302 weak_factory_.GetWeakPtr())); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 } else if (rv == ERR_IO_PENDING) { | 424 } else if (rv == ERR_IO_PENDING) { |
424 // If we don't have any sockets in this group, set a timer for potentially | 425 // If we don't have any sockets in this group, set a timer for potentially |
425 // creating a new one. If the SYN is lost, this backup socket may complete | 426 // creating a new one. If the SYN is lost, this backup socket may complete |
426 // before the slow socket, improving end user latency. | 427 // before the slow socket, improving end user latency. |
427 if (connect_backup_jobs_enabled_ && group->IsEmpty()) { | 428 if (connect_backup_jobs_enabled_ && group->IsEmpty()) { |
428 group->StartBackupJobTimer(group_name, this); | 429 group->StartBackupJobTimer(group_name, this); |
429 } | 430 } |
430 | 431 |
431 connecting_socket_count_++; | 432 connecting_socket_count_++; |
432 | 433 |
433 group->AddJob(connect_job.Pass(), preconnecting); | 434 group->AddJob(std::move(connect_job), preconnecting); |
434 } else { | 435 } else { |
435 LogBoundConnectJobToRequest(connect_job->net_log().source(), request); | 436 LogBoundConnectJobToRequest(connect_job->net_log().source(), request); |
436 scoped_ptr<StreamSocket> error_socket; | 437 scoped_ptr<StreamSocket> error_socket; |
437 if (!preconnecting) { | 438 if (!preconnecting) { |
438 DCHECK(handle); | 439 DCHECK(handle); |
439 connect_job->GetAdditionalErrorState(handle); | 440 connect_job->GetAdditionalErrorState(handle); |
440 error_socket = connect_job->PassSocket(); | 441 error_socket = connect_job->PassSocket(); |
441 } | 442 } |
442 if (error_socket) { | 443 if (error_socket) { |
443 HandOutSocket(error_socket.Pass(), ClientSocketHandle::UNUSED, | 444 HandOutSocket(std::move(error_socket), ClientSocketHandle::UNUSED, |
444 connect_job->connect_timing(), handle, base::TimeDelta(), | 445 connect_job->connect_timing(), handle, base::TimeDelta(), |
445 group, request.net_log()); | 446 group, request.net_log()); |
446 } else if (group->IsEmpty()) { | 447 } else if (group->IsEmpty()) { |
447 RemoveGroup(group_name); | 448 RemoveGroup(group_name); |
448 } | 449 } |
449 } | 450 } |
450 | 451 |
451 return rv; | 452 return rv; |
452 } | 453 } |
453 | 454 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 void ClientSocketPoolBaseHelper::CancelRequest( | 527 void ClientSocketPoolBaseHelper::CancelRequest( |
527 const std::string& group_name, ClientSocketHandle* handle) { | 528 const std::string& group_name, ClientSocketHandle* handle) { |
528 PendingCallbackMap::iterator callback_it = pending_callback_map_.find(handle); | 529 PendingCallbackMap::iterator callback_it = pending_callback_map_.find(handle); |
529 if (callback_it != pending_callback_map_.end()) { | 530 if (callback_it != pending_callback_map_.end()) { |
530 int result = callback_it->second.result; | 531 int result = callback_it->second.result; |
531 pending_callback_map_.erase(callback_it); | 532 pending_callback_map_.erase(callback_it); |
532 scoped_ptr<StreamSocket> socket = handle->PassSocket(); | 533 scoped_ptr<StreamSocket> socket = handle->PassSocket(); |
533 if (socket) { | 534 if (socket) { |
534 if (result != OK) | 535 if (result != OK) |
535 socket->Disconnect(); | 536 socket->Disconnect(); |
536 ReleaseSocket(handle->group_name(), socket.Pass(), handle->id()); | 537 ReleaseSocket(handle->group_name(), std::move(socket), handle->id()); |
537 } | 538 } |
538 return; | 539 return; |
539 } | 540 } |
540 | 541 |
541 CHECK(ContainsKey(group_map_, group_name)); | 542 CHECK(ContainsKey(group_map_, group_name)); |
542 | 543 |
543 Group* group = GetOrCreateGroup(group_name); | 544 Group* group = GetOrCreateGroup(group_name); |
544 | 545 |
545 // Search pending_requests for matching handle. | 546 // Search pending_requests for matching handle. |
546 scoped_ptr<const Request> request = | 547 scoped_ptr<const Request> request = |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 dict->SetString("name", name); | 609 dict->SetString("name", name); |
609 dict->SetString("type", type); | 610 dict->SetString("type", type); |
610 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); | 611 dict->SetInteger("handed_out_socket_count", handed_out_socket_count_); |
611 dict->SetInteger("connecting_socket_count", connecting_socket_count_); | 612 dict->SetInteger("connecting_socket_count", connecting_socket_count_); |
612 dict->SetInteger("idle_socket_count", idle_socket_count_); | 613 dict->SetInteger("idle_socket_count", idle_socket_count_); |
613 dict->SetInteger("max_socket_count", max_sockets_); | 614 dict->SetInteger("max_socket_count", max_sockets_); |
614 dict->SetInteger("max_sockets_per_group", max_sockets_per_group_); | 615 dict->SetInteger("max_sockets_per_group", max_sockets_per_group_); |
615 dict->SetInteger("pool_generation_number", pool_generation_number_); | 616 dict->SetInteger("pool_generation_number", pool_generation_number_); |
616 | 617 |
617 if (group_map_.empty()) | 618 if (group_map_.empty()) |
618 return dict.Pass(); | 619 return dict; |
619 | 620 |
620 base::DictionaryValue* all_groups_dict = new base::DictionaryValue(); | 621 base::DictionaryValue* all_groups_dict = new base::DictionaryValue(); |
621 for (GroupMap::const_iterator it = group_map_.begin(); | 622 for (GroupMap::const_iterator it = group_map_.begin(); |
622 it != group_map_.end(); it++) { | 623 it != group_map_.end(); it++) { |
623 const Group* group = it->second; | 624 const Group* group = it->second; |
624 base::DictionaryValue* group_dict = new base::DictionaryValue(); | 625 base::DictionaryValue* group_dict = new base::DictionaryValue(); |
625 | 626 |
626 group_dict->SetInteger("pending_request_count", | 627 group_dict->SetInteger("pending_request_count", |
627 group->pending_request_count()); | 628 group->pending_request_count()); |
628 if (group->has_pending_requests()) { | 629 if (group->has_pending_requests()) { |
(...skipping 23 matching lines...) Expand all Loading... |
652 group_dict->Set("connect_jobs", connect_jobs_list); | 653 group_dict->Set("connect_jobs", connect_jobs_list); |
653 | 654 |
654 group_dict->SetBoolean("is_stalled", group->CanUseAdditionalSocketSlot( | 655 group_dict->SetBoolean("is_stalled", group->CanUseAdditionalSocketSlot( |
655 max_sockets_per_group_)); | 656 max_sockets_per_group_)); |
656 group_dict->SetBoolean("backup_job_timer_is_running", | 657 group_dict->SetBoolean("backup_job_timer_is_running", |
657 group->BackupJobTimerIsRunning()); | 658 group->BackupJobTimerIsRunning()); |
658 | 659 |
659 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); | 660 all_groups_dict->SetWithoutPathExpansion(it->first, group_dict); |
660 } | 661 } |
661 dict->Set("groups", all_groups_dict); | 662 dict->Set("groups", all_groups_dict); |
662 return dict.Pass(); | 663 return dict; |
663 } | 664 } |
664 | 665 |
665 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { | 666 bool ClientSocketPoolBaseHelper::IdleSocket::IsUsable() const { |
666 if (socket->WasEverUsed()) | 667 if (socket->WasEverUsed()) |
667 return socket->IsConnectedAndIdle(); | 668 return socket->IsConnectedAndIdle(); |
668 return socket->IsConnected(); | 669 return socket->IsConnected(); |
669 } | 670 } |
670 | 671 |
671 bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup( | 672 bool ClientSocketPoolBaseHelper::IdleSocket::ShouldCleanup( |
672 base::TimeTicks now, | 673 base::TimeTicks now, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 CHECK_GT(handed_out_socket_count_, 0); | 789 CHECK_GT(handed_out_socket_count_, 0); |
789 handed_out_socket_count_--; | 790 handed_out_socket_count_--; |
790 | 791 |
791 CHECK_GT(group->active_socket_count(), 0); | 792 CHECK_GT(group->active_socket_count(), 0); |
792 group->DecrementActiveSocketCount(); | 793 group->DecrementActiveSocketCount(); |
793 | 794 |
794 const bool can_reuse = socket->IsConnectedAndIdle() && | 795 const bool can_reuse = socket->IsConnectedAndIdle() && |
795 id == pool_generation_number_; | 796 id == pool_generation_number_; |
796 if (can_reuse) { | 797 if (can_reuse) { |
797 // Add it to the idle list. | 798 // Add it to the idle list. |
798 AddIdleSocket(socket.Pass(), group); | 799 AddIdleSocket(std::move(socket), group); |
799 OnAvailableSocketSlot(group_name, group); | 800 OnAvailableSocketSlot(group_name, group); |
800 } else { | 801 } else { |
801 socket.reset(); | 802 socket.reset(); |
802 } | 803 } |
803 | 804 |
804 CheckForStalledSocketGroups(); | 805 CheckForStalledSocketGroups(); |
805 } | 806 } |
806 | 807 |
807 void ClientSocketPoolBaseHelper::CheckForStalledSocketGroups() { | 808 void ClientSocketPoolBaseHelper::CheckForStalledSocketGroups() { |
808 // If we have idle sockets, see if we can give one to the top-stalled group. | 809 // If we have idle sockets, see if we can give one to the top-stalled group. |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 | 895 |
895 // RemoveConnectJob(job, _) must be called by all branches below; | 896 // RemoveConnectJob(job, _) must be called by all branches below; |
896 // otherwise, |job| will be leaked. | 897 // otherwise, |job| will be leaked. |
897 | 898 |
898 if (result == OK) { | 899 if (result == OK) { |
899 DCHECK(socket.get()); | 900 DCHECK(socket.get()); |
900 RemoveConnectJob(job, group); | 901 RemoveConnectJob(job, group); |
901 scoped_ptr<const Request> request = group->PopNextPendingRequest(); | 902 scoped_ptr<const Request> request = group->PopNextPendingRequest(); |
902 if (request) { | 903 if (request) { |
903 LogBoundConnectJobToRequest(job_log.source(), *request); | 904 LogBoundConnectJobToRequest(job_log.source(), *request); |
904 HandOutSocket( | 905 HandOutSocket(std::move(socket), ClientSocketHandle::UNUSED, |
905 socket.Pass(), ClientSocketHandle::UNUSED, connect_timing, | 906 connect_timing, request->handle(), base::TimeDelta(), group, |
906 request->handle(), base::TimeDelta(), group, request->net_log()); | 907 request->net_log()); |
907 request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); | 908 request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); |
908 InvokeUserCallbackLater(request->handle(), request->callback(), result); | 909 InvokeUserCallbackLater(request->handle(), request->callback(), result); |
909 } else { | 910 } else { |
910 AddIdleSocket(socket.Pass(), group); | 911 AddIdleSocket(std::move(socket), group); |
911 OnAvailableSocketSlot(group_name, group); | 912 OnAvailableSocketSlot(group_name, group); |
912 CheckForStalledSocketGroups(); | 913 CheckForStalledSocketGroups(); |
913 } | 914 } |
914 } else { | 915 } else { |
915 // If we got a socket, it must contain error information so pass that | 916 // If we got a socket, it must contain error information so pass that |
916 // up so that the caller can retrieve it. | 917 // up so that the caller can retrieve it. |
917 bool handed_out_socket = false; | 918 bool handed_out_socket = false; |
918 scoped_ptr<const Request> request = group->PopNextPendingRequest(); | 919 scoped_ptr<const Request> request = group->PopNextPendingRequest(); |
919 if (request) { | 920 if (request) { |
920 LogBoundConnectJobToRequest(job_log.source(), *request); | 921 LogBoundConnectJobToRequest(job_log.source(), *request); |
921 job->GetAdditionalErrorState(request->handle()); | 922 job->GetAdditionalErrorState(request->handle()); |
922 RemoveConnectJob(job, group); | 923 RemoveConnectJob(job, group); |
923 if (socket.get()) { | 924 if (socket.get()) { |
924 handed_out_socket = true; | 925 handed_out_socket = true; |
925 HandOutSocket(socket.Pass(), ClientSocketHandle::UNUSED, | 926 HandOutSocket(std::move(socket), ClientSocketHandle::UNUSED, |
926 connect_timing, request->handle(), base::TimeDelta(), | 927 connect_timing, request->handle(), base::TimeDelta(), |
927 group, request->net_log()); | 928 group, request->net_log()); |
928 } | 929 } |
929 request->net_log().EndEventWithNetErrorCode( | 930 request->net_log().EndEventWithNetErrorCode( |
930 NetLog::TYPE_SOCKET_POOL, result); | 931 NetLog::TYPE_SOCKET_POOL, result); |
931 InvokeUserCallbackLater(request->handle(), request->callback(), result); | 932 InvokeUserCallbackLater(request->handle(), request->callback(), result); |
932 } else { | 933 } else { |
933 RemoveConnectJob(job, group); | 934 RemoveConnectJob(job, group); |
934 } | 935 } |
935 if (!handed_out_socket) { | 936 if (!handed_out_socket) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 | 997 |
997 void ClientSocketPoolBaseHelper::HandOutSocket( | 998 void ClientSocketPoolBaseHelper::HandOutSocket( |
998 scoped_ptr<StreamSocket> socket, | 999 scoped_ptr<StreamSocket> socket, |
999 ClientSocketHandle::SocketReuseType reuse_type, | 1000 ClientSocketHandle::SocketReuseType reuse_type, |
1000 const LoadTimingInfo::ConnectTiming& connect_timing, | 1001 const LoadTimingInfo::ConnectTiming& connect_timing, |
1001 ClientSocketHandle* handle, | 1002 ClientSocketHandle* handle, |
1002 base::TimeDelta idle_time, | 1003 base::TimeDelta idle_time, |
1003 Group* group, | 1004 Group* group, |
1004 const BoundNetLog& net_log) { | 1005 const BoundNetLog& net_log) { |
1005 DCHECK(socket); | 1006 DCHECK(socket); |
1006 handle->SetSocket(socket.Pass()); | 1007 handle->SetSocket(std::move(socket)); |
1007 handle->set_reuse_type(reuse_type); | 1008 handle->set_reuse_type(reuse_type); |
1008 handle->set_idle_time(idle_time); | 1009 handle->set_idle_time(idle_time); |
1009 handle->set_pool_id(pool_generation_number_); | 1010 handle->set_pool_id(pool_generation_number_); |
1010 handle->set_connect_timing(connect_timing); | 1011 handle->set_connect_timing(connect_timing); |
1011 | 1012 |
1012 if (handle->is_reused()) { | 1013 if (handle->is_reused()) { |
1013 net_log.AddEvent( | 1014 net_log.AddEvent( |
1014 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, | 1015 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, |
1015 NetLog::IntCallback("idle_ms", | 1016 NetLog::IntCallback("idle_ms", |
1016 static_cast<int>(idle_time.InMilliseconds()))); | 1017 static_cast<int>(idle_time.InMilliseconds()))); |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 if (pending_requests_.empty()) | 1250 if (pending_requests_.empty()) |
1250 return; | 1251 return; |
1251 | 1252 |
1252 scoped_ptr<ConnectJob> backup_job = | 1253 scoped_ptr<ConnectJob> backup_job = |
1253 pool->connect_job_factory_->NewConnectJob( | 1254 pool->connect_job_factory_->NewConnectJob( |
1254 group_name, *pending_requests_.FirstMax().value(), pool); | 1255 group_name, *pending_requests_.FirstMax().value(), pool); |
1255 backup_job->net_log().AddEvent(NetLog::TYPE_BACKUP_CONNECT_JOB_CREATED); | 1256 backup_job->net_log().AddEvent(NetLog::TYPE_BACKUP_CONNECT_JOB_CREATED); |
1256 int rv = backup_job->Connect(); | 1257 int rv = backup_job->Connect(); |
1257 pool->connecting_socket_count_++; | 1258 pool->connecting_socket_count_++; |
1258 ConnectJob* raw_backup_job = backup_job.get(); | 1259 ConnectJob* raw_backup_job = backup_job.get(); |
1259 AddJob(backup_job.Pass(), false); | 1260 AddJob(std::move(backup_job), false); |
1260 if (rv != ERR_IO_PENDING) | 1261 if (rv != ERR_IO_PENDING) |
1261 pool->OnConnectJobComplete(rv, raw_backup_job); | 1262 pool->OnConnectJobComplete(rv, raw_backup_job); |
1262 } | 1263 } |
1263 | 1264 |
1264 void ClientSocketPoolBaseHelper::Group::SanityCheck() { | 1265 void ClientSocketPoolBaseHelper::Group::SanityCheck() { |
1265 DCHECK_LE(unassigned_job_count_, jobs_.size()); | 1266 DCHECK_LE(unassigned_job_count_, jobs_.size()); |
1266 } | 1267 } |
1267 | 1268 |
1268 void ClientSocketPoolBaseHelper::Group::RemoveAllJobs() { | 1269 void ClientSocketPoolBaseHelper::Group::RemoveAllJobs() { |
1269 SanityCheck(); | 1270 SanityCheck(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 } | 1321 } |
1321 | 1322 |
1322 scoped_ptr<const ClientSocketPoolBaseHelper::Request> | 1323 scoped_ptr<const ClientSocketPoolBaseHelper::Request> |
1323 ClientSocketPoolBaseHelper::Group::FindAndRemovePendingRequest( | 1324 ClientSocketPoolBaseHelper::Group::FindAndRemovePendingRequest( |
1324 ClientSocketHandle* handle) { | 1325 ClientSocketHandle* handle) { |
1325 for (RequestQueue::Pointer pointer = pending_requests_.FirstMax(); | 1326 for (RequestQueue::Pointer pointer = pending_requests_.FirstMax(); |
1326 !pointer.is_null(); | 1327 !pointer.is_null(); |
1327 pointer = pending_requests_.GetNextTowardsLastMin(pointer)) { | 1328 pointer = pending_requests_.GetNextTowardsLastMin(pointer)) { |
1328 if (pointer.value()->handle() == handle) { | 1329 if (pointer.value()->handle() == handle) { |
1329 scoped_ptr<const Request> request = RemovePendingRequest(pointer); | 1330 scoped_ptr<const Request> request = RemovePendingRequest(pointer); |
1330 return request.Pass(); | 1331 return request; |
1331 } | 1332 } |
1332 } | 1333 } |
1333 return scoped_ptr<const ClientSocketPoolBaseHelper::Request>(); | 1334 return scoped_ptr<const ClientSocketPoolBaseHelper::Request>(); |
1334 } | 1335 } |
1335 | 1336 |
1336 scoped_ptr<const ClientSocketPoolBaseHelper::Request> | 1337 scoped_ptr<const ClientSocketPoolBaseHelper::Request> |
1337 ClientSocketPoolBaseHelper::Group::RemovePendingRequest( | 1338 ClientSocketPoolBaseHelper::Group::RemovePendingRequest( |
1338 const RequestQueue::Pointer& pointer) { | 1339 const RequestQueue::Pointer& pointer) { |
1339 // TODO(eroman): Temporary for debugging http://crbug.com/467797. | 1340 // TODO(eroman): Temporary for debugging http://crbug.com/467797. |
1340 CHECK(!pointer.is_null()); | 1341 CHECK(!pointer.is_null()); |
1341 scoped_ptr<const Request> request(pointer.value()); | 1342 scoped_ptr<const Request> request(pointer.value()); |
1342 pending_requests_.Erase(pointer); | 1343 pending_requests_.Erase(pointer); |
1343 // If there are no more requests, kill the backup timer. | 1344 // If there are no more requests, kill the backup timer. |
1344 if (pending_requests_.empty()) | 1345 if (pending_requests_.empty()) |
1345 backup_job_timer_.Stop(); | 1346 backup_job_timer_.Stop(); |
1346 request->CrashIfInvalid(); | 1347 request->CrashIfInvalid(); |
1347 return request.Pass(); | 1348 return request; |
1348 } | 1349 } |
1349 | 1350 |
1350 } // namespace internal | 1351 } // namespace internal |
1351 | 1352 |
1352 } // namespace net | 1353 } // namespace net |
OLD | NEW |