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

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

Issue 4291001: Convert implicit scoped_refptr constructor calls to explicit ones, part 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/build
Patch Set: comments Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/socket/client_socket_handle.cc ('k') | net/socket/socks5_client_socket.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/metrics/stats_counters.h" 10 #include "base/metrics/stats_counters.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 return rv; 80 return rv;
81 } 81 }
82 82
83 void ConnectJob::UseForNormalRequest() { 83 void ConnectJob::UseForNormalRequest() {
84 DCHECK_EQ(UNUSED_PRECONNECT, preconnect_state_); 84 DCHECK_EQ(UNUSED_PRECONNECT, preconnect_state_);
85 preconnect_state_ = USED_PRECONNECT; 85 preconnect_state_ = USED_PRECONNECT;
86 } 86 }
87 87
88 void ConnectJob::set_socket(ClientSocket* socket) { 88 void ConnectJob::set_socket(ClientSocket* socket) {
89 if (socket) { 89 if (socket) {
90 net_log().AddEvent(NetLog::TYPE_CONNECT_JOB_SET_SOCKET, 90 net_log().AddEvent(NetLog::TYPE_CONNECT_JOB_SET_SOCKET, make_scoped_refptr(
91 new NetLogSourceParameter("source_dependency", 91 new NetLogSourceParameter("source_dependency",
92 socket->NetLog().source())); 92 socket->NetLog().source())));
93 } 93 }
94 socket_.reset(socket); 94 socket_.reset(socket);
95 } 95 }
96 96
97 void ConnectJob::NotifyDelegateOfCompletion(int rv) { 97 void ConnectJob::NotifyDelegateOfCompletion(int rv) {
98 // The delegate will delete |this|. 98 // The delegate will delete |this|.
99 Delegate *delegate = delegate_; 99 Delegate *delegate = delegate_;
100 delegate_ = NULL; 100 delegate_ = NULL;
101 101
102 LogConnectCompletion(rv); 102 LogConnectCompletion(rv);
103 delegate->OnConnectJobComplete(rv, this); 103 delegate->OnConnectJobComplete(rv, this);
104 } 104 }
105 105
106 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) { 106 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) {
107 timer_.Stop(); 107 timer_.Stop();
108 timer_.Start(remaining_time, this, &ConnectJob::OnTimeout); 108 timer_.Start(remaining_time, this, &ConnectJob::OnTimeout);
109 } 109 }
110 110
111 void ConnectJob::LogConnectStart() { 111 void ConnectJob::LogConnectStart() {
112 net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, 112 net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT,
113 new NetLogStringParameter("group_name", group_name_)); 113 make_scoped_refptr(new NetLogStringParameter("group_name", group_name_)));
114 } 114 }
115 115
116 void ConnectJob::LogConnectCompletion(int net_error) { 116 void ConnectJob::LogConnectCompletion(int net_error) {
117 scoped_refptr<NetLog::EventParameters> params; 117 scoped_refptr<NetLog::EventParameters> params;
118 if (net_error != OK) 118 if (net_error != OK)
119 params = new NetLogIntegerParameter("net_error", net_error); 119 params = new NetLogIntegerParameter("net_error", net_error);
120 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, params); 120 net_log().EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_CONNECT, params);
121 } 121 }
122 122
123 void ConnectJob::OnTimeout() { 123 void ConnectJob::OnTimeout() {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 DCHECK(!request.callback()); 232 DCHECK(!request.callback());
233 DCHECK(!request.handle()); 233 DCHECK(!request.handle());
234 234
235 if (num_sockets > max_sockets_per_group_) { 235 if (num_sockets > max_sockets_per_group_) {
236 NOTREACHED(); 236 NOTREACHED();
237 num_sockets = max_sockets_per_group_; 237 num_sockets = max_sockets_per_group_;
238 } 238 }
239 239
240 request.net_log().BeginEvent( 240 request.net_log().BeginEvent(
241 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS, 241 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS,
242 new NetLogIntegerParameter("num_sockets", num_sockets)); 242 make_scoped_refptr(new NetLogIntegerParameter(
243 "num_sockets", num_sockets)));
243 244
244 Group* group = GetOrCreateGroup(group_name); 245 Group* group = GetOrCreateGroup(group_name);
245 246
246 for (int num_iterations_left = num_sockets; 247 for (int num_iterations_left = num_sockets;
247 group->NumActiveSocketSlots() < num_sockets && 248 group->NumActiveSocketSlots() < num_sockets &&
248 num_iterations_left > 0 ; num_iterations_left--) { 249 num_iterations_left > 0 ; num_iterations_left--) {
249 int rv = RequestSocketInternal(group_name, &request); 250 int rv = RequestSocketInternal(group_name, &request);
250 if (rv < 0 && rv != ERR_IO_PENDING) { 251 if (rv < 0 && rv != ERR_IO_PENDING) {
251 // We're encountering a synchronous error. Give up. 252 // We're encountering a synchronous error. Give up.
252 break; 253 break;
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 388 }
388 389
389 return false; 390 return false;
390 } 391 }
391 392
392 // static 393 // static
393 void ClientSocketPoolBaseHelper::LogBoundConnectJobToRequest( 394 void ClientSocketPoolBaseHelper::LogBoundConnectJobToRequest(
394 const NetLog::Source& connect_job_source, const Request* request) { 395 const NetLog::Source& connect_job_source, const Request* request) {
395 request->net_log().AddEvent( 396 request->net_log().AddEvent(
396 NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB, 397 NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB,
397 new NetLogSourceParameter("source_dependency", connect_job_source)); 398 make_scoped_refptr(new NetLogSourceParameter(
399 "source_dependency", connect_job_source)));
398 } 400 }
399 401
400 void ClientSocketPoolBaseHelper::CancelRequest( 402 void ClientSocketPoolBaseHelper::CancelRequest(
401 const std::string& group_name, ClientSocketHandle* handle) { 403 const std::string& group_name, ClientSocketHandle* handle) {
402 PendingCallbackMap::iterator callback_it = pending_callback_map_.find(handle); 404 PendingCallbackMap::iterator callback_it = pending_callback_map_.find(handle);
403 if (callback_it != pending_callback_map_.end()) { 405 if (callback_it != pending_callback_map_.end()) {
404 int result = callback_it->second.result; 406 int result = callback_it->second.result;
405 pending_callback_map_.erase(callback_it); 407 pending_callback_map_.erase(callback_it);
406 ClientSocket* socket = handle->release_socket(); 408 ClientSocket* socket = handle->release_socket();
407 if (socket) { 409 if (socket) {
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 scoped_ptr<const Request> r(RemoveRequestFromQueue( 758 scoped_ptr<const Request> r(RemoveRequestFromQueue(
757 group->mutable_pending_requests()->begin(), group)); 759 group->mutable_pending_requests()->begin(), group));
758 LogBoundConnectJobToRequest(job_log.source(), r.get()); 760 LogBoundConnectJobToRequest(job_log.source(), r.get());
759 job->GetAdditionalErrorState(r->handle()); 761 job->GetAdditionalErrorState(r->handle());
760 RemoveConnectJob(job, group); 762 RemoveConnectJob(job, group);
761 if (socket.get()) { 763 if (socket.get()) {
762 handed_out_socket = true; 764 handed_out_socket = true;
763 HandOutSocket(socket.release(), false /* unused socket */, r->handle(), 765 HandOutSocket(socket.release(), false /* unused socket */, r->handle(),
764 base::TimeDelta(), group, r->net_log()); 766 base::TimeDelta(), group, r->net_log());
765 } 767 }
766 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, 768 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, make_scoped_refptr(
767 new NetLogIntegerParameter("net_error", result)); 769 new NetLogIntegerParameter("net_error", result)));
768 InvokeUserCallbackLater(r->handle(), r->callback(), result); 770 InvokeUserCallbackLater(r->handle(), r->callback(), result);
769 } else { 771 } else {
770 RemoveConnectJob(job, group); 772 RemoveConnectJob(job, group);
771 } 773 }
772 if (!handed_out_socket) { 774 if (!handed_out_socket) {
773 OnAvailableSocketSlot(group_name, group); 775 OnAvailableSocketSlot(group_name, group);
774 CheckForStalledSocketGroups(); 776 CheckForStalledSocketGroups();
775 } 777 }
776 } 778 }
777 } 779 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 const BoundNetLog& net_log) { 844 const BoundNetLog& net_log) {
843 DCHECK(socket); 845 DCHECK(socket);
844 handle->set_socket(socket); 846 handle->set_socket(socket);
845 handle->set_is_reused(reused); 847 handle->set_is_reused(reused);
846 handle->set_idle_time(idle_time); 848 handle->set_idle_time(idle_time);
847 handle->set_pool_id(pool_generation_number_); 849 handle->set_pool_id(pool_generation_number_);
848 850
849 if (reused) { 851 if (reused) {
850 net_log.AddEvent( 852 net_log.AddEvent(
851 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, 853 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET,
852 new NetLogIntegerParameter( 854 make_scoped_refptr(new NetLogIntegerParameter(
853 "idle_ms", static_cast<int>(idle_time.InMilliseconds()))); 855 "idle_ms", static_cast<int>(idle_time.InMilliseconds()))));
854 } 856 }
855 857
856 net_log.AddEvent(NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, 858 net_log.AddEvent(NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET,
857 new NetLogSourceParameter( 859 make_scoped_refptr(new NetLogSourceParameter(
858 "source_dependency", socket->NetLog().source())); 860 "source_dependency", socket->NetLog().source())));
859 861
860 handed_out_socket_count_++; 862 handed_out_socket_count_++;
861 group->IncrementActiveSocketCount(); 863 group->IncrementActiveSocketCount();
862 } 864 }
863 865
864 void ClientSocketPoolBaseHelper::AddIdleSocket( 866 void ClientSocketPoolBaseHelper::AddIdleSocket(
865 ClientSocket* socket, Group* group) { 867 ClientSocket* socket, Group* group) {
866 DCHECK(socket); 868 DCHECK(socket);
867 IdleSocket idle_socket; 869 IdleSocket idle_socket;
868 idle_socket.socket = socket; 870 idle_socket.socket = socket;
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 // Delete active jobs. 1048 // Delete active jobs.
1047 STLDeleteElements(&jobs_); 1049 STLDeleteElements(&jobs_);
1048 1050
1049 // Cancel pending backup job. 1051 // Cancel pending backup job.
1050 method_factory_.RevokeAll(); 1052 method_factory_.RevokeAll();
1051 } 1053 }
1052 1054
1053 } // namespace internal 1055 } // namespace internal
1054 1056
1055 } // namespace net 1057 } // namespace net
OLDNEW
« no previous file with comments | « net/socket/client_socket_handle.cc ('k') | net/socket/socks5_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698