Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: net/socket/client_socket_pool_base.cc

Issue 2870030: Implement SSLClientSocketPool. (Closed)
Patch Set: Rebase and fix mac compile error Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/stats_counters.h" 10 #include "base/stats_counters.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 this); 250 this);
251 StartBackupSocketTimer(group_name); 251 StartBackupSocketTimer(group_name);
252 } 252 }
253 253
254 connecting_socket_count_++; 254 connecting_socket_count_++;
255 255
256 ConnectJob* job = connect_job.release(); 256 ConnectJob* job = connect_job.release();
257 group.jobs.insert(job); 257 group.jobs.insert(job);
258 } else { 258 } else {
259 LogBoundConnectJobToRequest(connect_job->net_log().source(), request); 259 LogBoundConnectJobToRequest(connect_job->net_log().source(), request);
260 connect_job->GetAdditionalErrorState(handle);
260 ClientSocket* error_socket = connect_job->ReleaseSocket(); 261 ClientSocket* error_socket = connect_job->ReleaseSocket();
261 if (error_socket) { 262 if (error_socket) {
262 HandOutSocket(error_socket, false /* not reused */, handle, 263 HandOutSocket(error_socket, false /* not reused */, handle,
263 base::TimeDelta(), &group, request->net_log()); 264 base::TimeDelta(), &group, request->net_log());
264 } 265 }
265 if (group.IsEmpty()) 266 if (group.IsEmpty())
266 group_map_.erase(group_name); 267 group_map_.erase(group_name);
267 } 268 }
268 269
269 return rv; 270 return rv;
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 586
586 DCHECK_NE(ERR_IO_PENDING, result); 587 DCHECK_NE(ERR_IO_PENDING, result);
587 const std::string group_name = job->group_name(); 588 const std::string group_name = job->group_name();
588 GroupMap::iterator group_it = group_map_.find(group_name); 589 GroupMap::iterator group_it = group_map_.find(group_name);
589 CHECK(group_it != group_map_.end()); 590 CHECK(group_it != group_map_.end());
590 Group& group = group_it->second; 591 Group& group = group_it->second;
591 592
592 scoped_ptr<ClientSocket> socket(job->ReleaseSocket()); 593 scoped_ptr<ClientSocket> socket(job->ReleaseSocket());
593 594
594 BoundNetLog job_log = job->net_log(); 595 BoundNetLog job_log = job->net_log();
595 RemoveConnectJob(job, &group);
596 596
597 if (result == OK) { 597 if (result == OK) {
598 DCHECK(socket.get()); 598 DCHECK(socket.get());
599 RemoveConnectJob(job, &group);
599 if (!group.pending_requests.empty()) { 600 if (!group.pending_requests.empty()) {
600 scoped_ptr<const Request> r(RemoveRequestFromQueue( 601 scoped_ptr<const Request> r(RemoveRequestFromQueue(
601 group.pending_requests.begin(), &group.pending_requests)); 602 group.pending_requests.begin(), &group.pending_requests));
602 LogBoundConnectJobToRequest(job_log.source(), r.get()); 603 LogBoundConnectJobToRequest(job_log.source(), r.get());
603 HandOutSocket( 604 HandOutSocket(
604 socket.release(), false /* unused socket */, r->handle(), 605 socket.release(), false /* unused socket */, r->handle(),
605 base::TimeDelta(), &group, r->net_log()); 606 base::TimeDelta(), &group, r->net_log());
606 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL); 607 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
607 r->callback()->Run(result); 608 r->callback()->Run(result);
608 } else { 609 } else {
609 AddIdleSocket(socket.release(), false /* unused socket */, &group); 610 AddIdleSocket(socket.release(), false /* unused socket */, &group);
610 OnAvailableSocketSlot(group_name, MayHaveStalledGroups()); 611 OnAvailableSocketSlot(group_name, MayHaveStalledGroups());
611 } 612 }
612 } else { 613 } else {
613 // If we got a socket, it must contain error information so pass that 614 // If we got a socket, it must contain error information so pass that
614 // up so that the caller can retrieve it. 615 // up so that the caller can retrieve it.
615 bool handed_out_socket = false; 616 bool handed_out_socket = false;
616 if (!group.pending_requests.empty()) { 617 if (!group.pending_requests.empty()) {
617 scoped_ptr<const Request> r(RemoveRequestFromQueue( 618 scoped_ptr<const Request> r(RemoveRequestFromQueue(
618 group.pending_requests.begin(), &group.pending_requests)); 619 group.pending_requests.begin(), &group.pending_requests));
619 LogBoundConnectJobToRequest(job_log.source(), r.get()); 620 LogBoundConnectJobToRequest(job_log.source(), r.get());
621 job->GetAdditionalErrorState(r->handle());
622 RemoveConnectJob(job, &group);
620 if (socket.get()) { 623 if (socket.get()) {
621 handed_out_socket = true; 624 handed_out_socket = true;
622 HandOutSocket(socket.release(), false /* unused socket */, r->handle(), 625 HandOutSocket(socket.release(), false /* unused socket */, r->handle(),
623 base::TimeDelta(), &group, r->net_log()); 626 base::TimeDelta(), &group, r->net_log());
624 } 627 }
625 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, 628 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL,
626 new NetLogIntegerParameter("net_error", result)); 629 new NetLogIntegerParameter("net_error", result));
630 if (socket.get()) {
631 handed_out_socket = true;
632 HandOutSocket(
633 socket.release(), false /* unused socket */, r->handle(),
634 base::TimeDelta(), &group, r->net_log());
willchan no longer on Chromium 2010/07/15 00:52:24 Is this a bad merge? Did this get copied twice?
635 }
627 r->callback()->Run(result); 636 r->callback()->Run(result);
637 } else {
638 RemoveConnectJob(job, &group);
628 } 639 }
629 if (!handed_out_socket) 640 if (!handed_out_socket)
630 OnAvailableSocketSlot(group_name, MayHaveStalledGroups()); 641 OnAvailableSocketSlot(group_name, MayHaveStalledGroups());
631 } 642 }
632 } 643 }
633 644
634 void ClientSocketPoolBaseHelper::OnIPAddressChanged() { 645 void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
635 Flush(); 646 Flush();
636 } 647 }
637 648
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 return; 802 return;
792 } 803 }
793 } 804 }
794 805
795 LOG(DFATAL) << "No idle socket found to close!."; 806 LOG(DFATAL) << "No idle socket found to close!.";
796 } 807 }
797 808
798 } // namespace internal 809 } // namespace internal
799 810
800 } // namespace net 811 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698