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

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

Issue 1746012: More cleanup of net_log.h (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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 | Annotate | Revision Log
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 30 matching lines...) Expand all
41 net_log_(net_log), 41 net_log_(net_log),
42 idle_(true) { 42 idle_(true) {
43 DCHECK(!group_name.empty()); 43 DCHECK(!group_name.empty());
44 DCHECK(delegate); 44 DCHECK(delegate);
45 } 45 }
46 46
47 ConnectJob::~ConnectJob() { 47 ConnectJob::~ConnectJob() {
48 if (delegate_ && !idle_) { 48 if (delegate_ && !idle_) {
49 // If the delegate was not NULLed, then NotifyDelegateOfCompletion has 49 // If the delegate was not NULLed, then NotifyDelegateOfCompletion has
50 // not been called yet. If we've started then we are cancelling. 50 // not been called yet. If we've started then we are cancelling.
51 net_log_.AddEvent(NetLog::TYPE_CANCELLED); 51 net_log_.AddEvent(NetLog::TYPE_CANCELLED, NULL);
52 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); 52 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, NULL);
53 } 53 }
54 } 54 }
55 55
56 int ConnectJob::Connect() { 56 int ConnectJob::Connect() {
57 if (timeout_duration_ != base::TimeDelta()) 57 if (timeout_duration_ != base::TimeDelta())
58 timer_.Start(timeout_duration_, this, &ConnectJob::OnTimeout); 58 timer_.Start(timeout_duration_, this, &ConnectJob::OnTimeout);
59 59
60 net_log_.BeginEventWithString(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, 60 net_log_.BeginEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB,
61 "group_name", group_name_); 61 new NetLogStringParameter("group_name", group_name_));
62 idle_ = false; 62 idle_ = false;
63 63
64 int rv = ConnectInternal(); 64 int rv = ConnectInternal();
65 65
66 if (rv != ERR_IO_PENDING) { 66 if (rv != ERR_IO_PENDING) {
67 delegate_ = NULL; 67 delegate_ = NULL;
68 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); 68 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, NULL);
69 } 69 }
70 70
71 return rv; 71 return rv;
72 } 72 }
73 73
74 void ConnectJob::NotifyDelegateOfCompletion(int rv) { 74 void ConnectJob::NotifyDelegateOfCompletion(int rv) {
75 // The delegate will delete |this|. 75 // The delegate will delete |this|.
76 Delegate *delegate = delegate_; 76 Delegate *delegate = delegate_;
77 delegate_ = NULL; 77 delegate_ = NULL;
78 78
79 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB); 79 net_log_.EndEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB, NULL);
80 80
81 delegate->OnConnectJobComplete(rv, this); 81 delegate->OnConnectJobComplete(rv, this);
82 } 82 }
83 83
84 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) { 84 void ConnectJob::ResetTimer(base::TimeDelta remaining_time) {
85 timer_.Stop(); 85 timer_.Stop();
86 timer_.Start(remaining_time, this, &ConnectJob::OnTimeout); 86 timer_.Start(remaining_time, this, &ConnectJob::OnTimeout);
87 } 87 }
88 88
89 void ConnectJob::OnTimeout() { 89 void ConnectJob::OnTimeout() {
90 // Make sure the socket is NULL before calling into |delegate|. 90 // Make sure the socket is NULL before calling into |delegate|.
91 set_socket(NULL); 91 set_socket(NULL);
92 92
93 net_log_.AddEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT); 93 net_log_.AddEvent(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_TIMED_OUT, NULL);
94 94
95 NotifyDelegateOfCompletion(ERR_TIMED_OUT); 95 NotifyDelegateOfCompletion(ERR_TIMED_OUT);
96 } 96 }
97 97
98 namespace internal { 98 namespace internal {
99 99
100 ClientSocketPoolBaseHelper::Request::Request( 100 ClientSocketPoolBaseHelper::Request::Request(
101 ClientSocketHandle* handle, 101 ClientSocketHandle* handle,
102 CompletionCallback* callback, 102 CompletionCallback* callback,
103 RequestPriority priority, 103 RequestPriority priority,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 ClientSocketPoolBaseHelper::RemoveRequestFromQueue( 165 ClientSocketPoolBaseHelper::RemoveRequestFromQueue(
166 RequestQueue::iterator it, RequestQueue* pending_requests) { 166 RequestQueue::iterator it, RequestQueue* pending_requests) {
167 const Request* req = *it; 167 const Request* req = *it;
168 pending_requests->erase(it); 168 pending_requests->erase(it);
169 return req; 169 return req;
170 } 170 }
171 171
172 int ClientSocketPoolBaseHelper::RequestSocket( 172 int ClientSocketPoolBaseHelper::RequestSocket(
173 const std::string& group_name, 173 const std::string& group_name,
174 const Request* request) { 174 const Request* request) {
175 request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL); 175 request->net_log().BeginEvent(NetLog::TYPE_SOCKET_POOL, NULL);
176 Group& group = group_map_[group_name]; 176 Group& group = group_map_[group_name];
177 int rv = RequestSocketInternal(group_name, request); 177 int rv = RequestSocketInternal(group_name, request);
178 if (rv != ERR_IO_PENDING) 178 if (rv != ERR_IO_PENDING)
179 request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); 179 request->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
180 else 180 else
181 InsertRequestIntoQueue(request, &group.pending_requests); 181 InsertRequestIntoQueue(request, &group.pending_requests);
182 return rv; 182 return rv;
183 } 183 }
184 184
185 int ClientSocketPoolBaseHelper::RequestSocketInternal( 185 int ClientSocketPoolBaseHelper::RequestSocketInternal(
186 const std::string& group_name, 186 const std::string& group_name,
187 const Request* request) { 187 const Request* request) {
188 DCHECK_GE(request->priority(), 0); 188 DCHECK_GE(request->priority(), 0);
189 CompletionCallback* const callback = request->callback(); 189 CompletionCallback* const callback = request->callback();
190 CHECK(callback); 190 CHECK(callback);
191 ClientSocketHandle* const handle = request->handle(); 191 ClientSocketHandle* const handle = request->handle();
192 CHECK(handle); 192 CHECK(handle);
193 Group& group = group_map_[group_name]; 193 Group& group = group_map_[group_name];
194 194
195 // Can we make another active socket now? 195 // Can we make another active socket now?
196 if (ReachedMaxSocketsLimit() || 196 if (ReachedMaxSocketsLimit() ||
197 !group.HasAvailableSocketSlot(max_sockets_per_group_)) { 197 !group.HasAvailableSocketSlot(max_sockets_per_group_)) {
198 if (ReachedMaxSocketsLimit()) { 198 if (ReachedMaxSocketsLimit()) {
199 // We could check if we really have a stalled group here, but it requires 199 // We could check if we really have a stalled group here, but it requires
200 // a scan of all groups, so just flip a flag here, and do the check later. 200 // a scan of all groups, so just flip a flag here, and do the check later.
201 may_have_stalled_group_ = true; 201 may_have_stalled_group_ = true;
202 202
203 request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS); 203 request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS,
204 NULL);
204 } else { 205 } else {
205 request->net_log().AddEvent( 206 request->net_log().AddEvent(
206 NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP); 207 NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP, NULL);
207 } 208 }
208 return ERR_IO_PENDING; 209 return ERR_IO_PENDING;
209 } 210 }
210 211
211 // Try to reuse a socket. 212 // Try to reuse a socket.
212 while (!group.idle_sockets.empty()) { 213 while (!group.idle_sockets.empty()) {
213 IdleSocket idle_socket = group.idle_sockets.back(); 214 IdleSocket idle_socket = group.idle_sockets.back();
214 group.idle_sockets.pop_back(); 215 group.idle_sockets.pop_back();
215 DecrementIdleCount(); 216 DecrementIdleCount();
216 if (idle_socket.socket->IsConnectedAndIdle()) { 217 if (idle_socket.socket->IsConnectedAndIdle()) {
(...skipping 10 matching lines...) Expand all
227 228
228 // See if we already have enough connect jobs or sockets that will be released 229 // See if we already have enough connect jobs or sockets that will be released
229 // soon. 230 // soon.
230 if (group.HasReleasingSockets()) { 231 if (group.HasReleasingSockets()) {
231 return ERR_IO_PENDING; 232 return ERR_IO_PENDING;
232 } 233 }
233 234
234 // We couldn't find a socket to reuse, so allocate and connect a new one. 235 // We couldn't find a socket to reuse, so allocate and connect a new one.
235 BoundNetLog job_net_log = BoundNetLog::Make( 236 BoundNetLog job_net_log = BoundNetLog::Make(
236 request->net_log().net_log(), NetLog::SOURCE_CONNECT_JOB); 237 request->net_log().net_log(), NetLog::SOURCE_CONNECT_JOB);
237 request->net_log().BeginEventWithInteger( 238 request->net_log().BeginEvent(
238 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, 239 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
239 "source_id", job_net_log.source().id); 240 new NetLogIntegerParameter("source_id", job_net_log.source().id));
240 241
241 scoped_ptr<ConnectJob> connect_job( 242 scoped_ptr<ConnectJob> connect_job(
242 connect_job_factory_->NewConnectJob(group_name, *request, this, 243 connect_job_factory_->NewConnectJob(group_name, *request, this,
243 job_net_log)); 244 job_net_log));
244 245
245 int rv = connect_job->Connect(); 246 int rv = connect_job->Connect();
246 if (rv == OK) { 247 if (rv == OK) {
247 request->net_log().EndEventWithInteger( 248 request->net_log().EndEvent(
248 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, 249 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
249 "source_id", job_net_log.source().id); 250 new NetLogIntegerParameter("source_id", job_net_log.source().id));
250 HandOutSocket(connect_job->ReleaseSocket(), false /* not reused */, 251 HandOutSocket(connect_job->ReleaseSocket(), false /* not reused */,
251 handle, base::TimeDelta(), &group, request->net_log()); 252 handle, base::TimeDelta(), &group, request->net_log());
252 } else if (rv == ERR_IO_PENDING) { 253 } else if (rv == ERR_IO_PENDING) {
253 // If we don't have any sockets in this group, set a timer for potentially 254 // If we don't have any sockets in this group, set a timer for potentially
254 // creating a new one. If the SYN is lost, this backup socket may complete 255 // creating a new one. If the SYN is lost, this backup socket may complete
255 // before the slow socket, improving end user latency. 256 // before the slow socket, improving end user latency.
256 if (group.IsEmpty() && !group.backup_job && backup_jobs_enabled_) { 257 if (group.IsEmpty() && !group.backup_job && backup_jobs_enabled_) {
257 group.backup_job = connect_job_factory_->NewConnectJob(group_name, 258 group.backup_job = connect_job_factory_->NewConnectJob(group_name,
258 *request, 259 *request,
259 this, 260 this,
260 job_net_log); 261 job_net_log);
261 StartBackupSocketTimer(group_name); 262 StartBackupSocketTimer(group_name);
262 } 263 }
263 264
264 connecting_socket_count_++; 265 connecting_socket_count_++;
265 266
266 ConnectJob* job = connect_job.release(); 267 ConnectJob* job = connect_job.release();
267 group.jobs.insert(job); 268 group.jobs.insert(job);
268 } else { 269 } else {
269 request->net_log().EndEventWithInteger( 270 request->net_log().EndEvent(
270 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, 271 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
271 "source_id", job_net_log.source().id); 272 new NetLogIntegerParameter("source_id", job_net_log.source().id));
272 if (group.IsEmpty()) 273 if (group.IsEmpty())
273 group_map_.erase(group_name); 274 group_map_.erase(group_name);
274 } 275 }
275 276
276 return rv; 277 return rv;
277 } 278 }
278 279
279 void ClientSocketPoolBaseHelper::StartBackupSocketTimer( 280 void ClientSocketPoolBaseHelper::StartBackupSocketTimer(
280 const std::string& group_name) { 281 const std::string& group_name) {
281 CHECK(ContainsKey(group_map_, group_name)); 282 CHECK(ContainsKey(group_map_, group_name));
(...skipping 19 matching lines...) Expand all
301 group.backup_task = NULL; 302 group.backup_task = NULL;
302 303
303 CHECK(group.backup_job); 304 CHECK(group.backup_job);
304 305
305 // If our backup job is waiting on DNS, or if we can't create any sockets 306 // If our backup job is waiting on DNS, or if we can't create any sockets
306 // right now due to limits, just reset the timer. 307 // right now due to limits, just reset the timer.
307 CHECK(group.jobs.size()); 308 CHECK(group.jobs.size());
308 if (ReachedMaxSocketsLimit() || 309 if (ReachedMaxSocketsLimit() ||
309 !group.HasAvailableSocketSlot(max_sockets_per_group_) || 310 !group.HasAvailableSocketSlot(max_sockets_per_group_) ||
310 (*group.jobs.begin())->GetLoadState() == LOAD_STATE_RESOLVING_HOST) { 311 (*group.jobs.begin())->GetLoadState() == LOAD_STATE_RESOLVING_HOST) {
311 group.backup_job->net_log().EndEvent( 312 group.backup_job->net_log().AddEvent(
312 NetLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED); 313 NetLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED, NULL);
313 StartBackupSocketTimer(group_name); 314 StartBackupSocketTimer(group_name);
314 return; 315 return;
315 } 316 }
316 317
317 group.backup_job->net_log().AddEvent(NetLog::TYPE_SOCKET_BACKUP_CREATED); 318 group.backup_job->net_log().AddEvent(NetLog::TYPE_SOCKET_BACKUP_CREATED,
319 NULL);
318 SIMPLE_STATS_COUNTER("socket.backup_created"); 320 SIMPLE_STATS_COUNTER("socket.backup_created");
319 int rv = group.backup_job->Connect(); 321 int rv = group.backup_job->Connect();
320 connecting_socket_count_++; 322 connecting_socket_count_++;
321 group.jobs.insert(group.backup_job); 323 group.jobs.insert(group.backup_job);
322 ConnectJob* job = group.backup_job; 324 ConnectJob* job = group.backup_job;
323 group.backup_job = NULL; 325 group.backup_job = NULL;
324 if (rv != ERR_IO_PENDING) 326 if (rv != ERR_IO_PENDING)
325 OnConnectJobComplete(rv, job); 327 OnConnectJobComplete(rv, job);
326 } 328 }
327 329
328 void ClientSocketPoolBaseHelper::CancelRequest( 330 void ClientSocketPoolBaseHelper::CancelRequest(
329 const std::string& group_name, const ClientSocketHandle* handle) { 331 const std::string& group_name, const ClientSocketHandle* handle) {
330 CHECK(ContainsKey(group_map_, group_name)); 332 CHECK(ContainsKey(group_map_, group_name));
331 333
332 Group& group = group_map_[group_name]; 334 Group& group = group_map_[group_name];
333 335
334 // Search pending_requests for matching handle. 336 // Search pending_requests for matching handle.
335 RequestQueue::iterator it = group.pending_requests.begin(); 337 RequestQueue::iterator it = group.pending_requests.begin();
336 for (; it != group.pending_requests.end(); ++it) { 338 for (; it != group.pending_requests.end(); ++it) {
337 if ((*it)->handle() == handle) { 339 if ((*it)->handle() == handle) {
338 const Request* req = RemoveRequestFromQueue(it, &group.pending_requests); 340 const Request* req = RemoveRequestFromQueue(it, &group.pending_requests);
339 req->net_log().AddEvent(NetLog::TYPE_CANCELLED); 341 req->net_log().AddEvent(NetLog::TYPE_CANCELLED, NULL);
340 req->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); 342 req->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
341 delete req; 343 delete req;
342 // Let one connect job connect and become idle for potential future use. 344 // Let one connect job connect and become idle for potential future use.
343 if (group.jobs.size() > group.pending_requests.size() + 1) { 345 if (group.jobs.size() > group.pending_requests.size() + 1) {
344 // TODO(willchan): Cancel the job in the earliest LoadState. 346 // TODO(willchan): Cancel the job in the earliest LoadState.
345 RemoveConnectJob(*group.jobs.begin(), &group); 347 RemoveConnectJob(*group.jobs.begin(), &group);
346 OnAvailableSocketSlot(group_name, &group); 348 OnAvailableSocketSlot(group_name, &group);
347 } 349 }
348 return; 350 return;
349 } 351 }
350 } 352 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 scoped_ptr<ClientSocket> socket(job->ReleaseSocket()); 570 scoped_ptr<ClientSocket> socket(job->ReleaseSocket());
569 571
570 BoundNetLog job_log = job->net_log(); 572 BoundNetLog job_log = job->net_log();
571 RemoveConnectJob(job, &group); 573 RemoveConnectJob(job, &group);
572 574
573 if (result == OK) { 575 if (result == OK) {
574 DCHECK(socket.get()); 576 DCHECK(socket.get());
575 if (!group.pending_requests.empty()) { 577 if (!group.pending_requests.empty()) {
576 scoped_ptr<const Request> r(RemoveRequestFromQueue( 578 scoped_ptr<const Request> r(RemoveRequestFromQueue(
577 group.pending_requests.begin(), &group.pending_requests)); 579 group.pending_requests.begin(), &group.pending_requests));
578 r->net_log().EndEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, 580 r->net_log().EndEvent(
579 "source_id", job_log.source().id); 581 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
580 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); 582 new NetLogIntegerParameter("source_id", job_log.source().id));
583 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
581 HandOutSocket( 584 HandOutSocket(
582 socket.release(), false /* unused socket */, r->handle(), 585 socket.release(), false /* unused socket */, r->handle(),
583 base::TimeDelta(), &group, r->net_log()); 586 base::TimeDelta(), &group, r->net_log());
584 r->callback()->Run(result); 587 r->callback()->Run(result);
585 } else { 588 } else {
586 AddIdleSocket(socket.release(), false /* unused socket */, &group); 589 AddIdleSocket(socket.release(), false /* unused socket */, &group);
587 OnAvailableSocketSlot(group_name, &group); 590 OnAvailableSocketSlot(group_name, &group);
588 } 591 }
589 } else { 592 } else {
590 DCHECK(!socket.get()); 593 DCHECK(!socket.get());
591 if (!group.pending_requests.empty()) { 594 if (!group.pending_requests.empty()) {
592 scoped_ptr<const Request> r(RemoveRequestFromQueue( 595 scoped_ptr<const Request> r(RemoveRequestFromQueue(
593 group.pending_requests.begin(), &group.pending_requests)); 596 group.pending_requests.begin(), &group.pending_requests));
594 r->net_log().EndEventWithInteger(NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID, 597 r->net_log().EndEvent(
595 "source_id", job_log.source().id); 598 NetLog::TYPE_SOCKET_POOL_CONNECT_JOB_ID,
596 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); 599 new NetLogIntegerParameter("source_id", job_log.source().id));
600 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
597 r->callback()->Run(result); 601 r->callback()->Run(result);
598 } 602 }
599 MaybeOnAvailableSocketSlot(group_name); 603 MaybeOnAvailableSocketSlot(group_name);
600 } 604 }
601 } 605 }
602 606
603 void ClientSocketPoolBaseHelper::OnIPAddressChanged() { 607 void ClientSocketPoolBaseHelper::OnIPAddressChanged() {
604 CloseIdleSockets(); 608 CloseIdleSockets();
605 } 609 }
606 610
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 group_map_.erase(group_name); 651 group_map_.erase(group_name);
648 } 652 }
649 } 653 }
650 654
651 void ClientSocketPoolBaseHelper::ProcessPendingRequest( 655 void ClientSocketPoolBaseHelper::ProcessPendingRequest(
652 const std::string& group_name, Group* group) { 656 const std::string& group_name, Group* group) {
653 scoped_ptr<const Request> r(*group->pending_requests.begin()); 657 scoped_ptr<const Request> r(*group->pending_requests.begin());
654 int rv = RequestSocketInternal(group_name, r.get()); 658 int rv = RequestSocketInternal(group_name, r.get());
655 659
656 if (rv != ERR_IO_PENDING) { 660 if (rv != ERR_IO_PENDING) {
657 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL); 661 r->net_log().EndEvent(NetLog::TYPE_SOCKET_POOL, NULL);
658 RemoveRequestFromQueue(group->pending_requests.begin(), 662 RemoveRequestFromQueue(group->pending_requests.begin(),
659 &group->pending_requests); 663 &group->pending_requests);
660 r->callback()->Run(rv); 664 r->callback()->Run(rv);
661 if (rv != OK) { 665 if (rv != OK) {
662 // |group| may be invalid after the callback, we need to search 666 // |group| may be invalid after the callback, we need to search
663 // |group_map_| again. 667 // |group_map_| again.
664 MaybeOnAvailableSocketSlot(group_name); 668 MaybeOnAvailableSocketSlot(group_name);
665 } 669 }
666 } else { 670 } else {
667 r.release(); 671 r.release();
668 } 672 }
669 } 673 }
670 674
671 void ClientSocketPoolBaseHelper::HandOutSocket( 675 void ClientSocketPoolBaseHelper::HandOutSocket(
672 ClientSocket* socket, 676 ClientSocket* socket,
673 bool reused, 677 bool reused,
674 ClientSocketHandle* handle, 678 ClientSocketHandle* handle,
675 base::TimeDelta idle_time, 679 base::TimeDelta idle_time,
676 Group* group, 680 Group* group,
677 const BoundNetLog& net_log) { 681 const BoundNetLog& net_log) {
678 DCHECK(socket); 682 DCHECK(socket);
679 handle->set_socket(socket); 683 handle->set_socket(socket);
680 handle->set_is_reused(reused); 684 handle->set_is_reused(reused);
681 handle->set_idle_time(idle_time); 685 handle->set_idle_time(idle_time);
682 686
683 if (reused) { 687 if (reused) {
684 net_log.AddEventWithInteger( 688 net_log.AddEvent(
685 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET, 689 NetLog::TYPE_SOCKET_POOL_REUSED_AN_EXISTING_SOCKET,
686 "idle_ms", static_cast<int>(idle_time.InMilliseconds())); 690 new NetLogIntegerParameter(
691 "idle_ms", static_cast<int>(idle_time.InMilliseconds())));
687 } 692 }
688 693
689 net_log.AddEventWithInteger(NetLog::TYPE_SOCKET_POOL_SOCKET_ID, 694 net_log.AddEvent(NetLog::TYPE_SOCKET_POOL_SOCKET_ID,
690 "source_id", socket->NetLog().source().id); 695 new NetLogIntegerParameter(
696 "source_id", socket->NetLog().source().id));
691 697
692 handed_out_socket_count_++; 698 handed_out_socket_count_++;
693 group->active_socket_count++; 699 group->active_socket_count++;
694 } 700 }
695 701
696 void ClientSocketPoolBaseHelper::AddIdleSocket( 702 void ClientSocketPoolBaseHelper::AddIdleSocket(
697 ClientSocket* socket, bool used, Group* group) { 703 ClientSocket* socket, bool used, Group* group) {
698 DCHECK(socket); 704 DCHECK(socket);
699 IdleSocket idle_socket; 705 IdleSocket idle_socket;
700 idle_socket.socket = socket; 706 idle_socket.socket = socket;
(...skipping 30 matching lines...) Expand all
731 DCHECK_LE(total, max_sockets_); 737 DCHECK_LE(total, max_sockets_);
732 if (total < max_sockets_) 738 if (total < max_sockets_)
733 return false; 739 return false;
734 LOG(WARNING) << "ReachedMaxSocketsLimit: " << total << "/" << max_sockets_; 740 LOG(WARNING) << "ReachedMaxSocketsLimit: " << total << "/" << max_sockets_;
735 return true; 741 return true;
736 } 742 }
737 743
738 } // namespace internal 744 } // namespace internal
739 745
740 } // namespace net 746 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/single_threaded_proxy_resolver_unittest.cc ('k') | net/socket/socks5_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698