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

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

Issue 1120007: Disable backup connect jobs for all pools except TCPClientSocketPool (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 // A ClientSocketPoolBase is used to restrict the number of sockets open at 5 // A ClientSocketPoolBase is used to restrict the number of sockets open at
6 // a time. It also maintains a list of idle persistent sockets for reuse. 6 // a time. It also maintains a list of idle persistent sockets for reuse.
7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle 7 // Subclasses of ClientSocketPool should compose ClientSocketPoolBase to handle
8 // the core logic of (1) restricting the number of active (connected or 8 // the core logic of (1) restricting the number of active (connected or
9 // connecting) sockets per "group" (generally speaking, the hostname), (2) 9 // connecting) sockets per "group" (generally speaking, the hostname), (2)
10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3) 10 // maintaining a per-group list of idle, persistent sockets for reuse, and (3)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool may_have_stalled_group() const { return may_have_stalled_group_; } 215 bool may_have_stalled_group() const { return may_have_stalled_group_; }
216 216
217 int NumConnectJobsInGroup(const std::string& group_name) const { 217 int NumConnectJobsInGroup(const std::string& group_name) const {
218 return group_map_.find(group_name)->second.jobs.size(); 218 return group_map_.find(group_name)->second.jobs.size();
219 } 219 }
220 220
221 // Closes all idle sockets if |force| is true. Else, only closes idle 221 // Closes all idle sockets if |force| is true. Else, only closes idle
222 // sockets that timed out or can't be reused. Made public for testing. 222 // sockets that timed out or can't be reused. Made public for testing.
223 void CleanupIdleSockets(bool force); 223 void CleanupIdleSockets(bool force);
224 224
225 void enable_backup_jobs() { backup_jobs_enabled_ = true; };
226
225 private: 227 private:
226 friend class base::RefCounted<ClientSocketPoolBaseHelper>; 228 friend class base::RefCounted<ClientSocketPoolBaseHelper>;
227 229
228 ~ClientSocketPoolBaseHelper(); 230 ~ClientSocketPoolBaseHelper();
229 231
230 // Entry for a persistent socket which became idle at time |start_time|. 232 // Entry for a persistent socket which became idle at time |start_time|.
231 struct IdleSocket { 233 struct IdleSocket {
232 IdleSocket() : socket(NULL), used(false) {} 234 IdleSocket() : socket(NULL), used(false) {}
233 ClientSocket* socket; 235 ClientSocket* socket;
234 base::TimeTicks start_time; 236 base::TimeTicks start_time;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 // 422 //
421 // Since reaching the maximum number of sockets is an edge case, we make note 423 // Since reaching the maximum number of sockets is an edge case, we make note
422 // of when it happens, and thus avoid doing the slower "scan all groups" 424 // of when it happens, and thus avoid doing the slower "scan all groups"
423 // in the common case. 425 // in the common case.
424 bool may_have_stalled_group_; 426 bool may_have_stalled_group_;
425 427
426 const scoped_ptr<ConnectJobFactory> connect_job_factory_; 428 const scoped_ptr<ConnectJobFactory> connect_job_factory_;
427 429
428 NetworkChangeNotifier* const network_change_notifier_; 430 NetworkChangeNotifier* const network_change_notifier_;
429 431
432 // TODO(vandebo) Remove when backup jobs move to TCPClientSocketPool
433 bool backup_jobs_enabled_;
434
430 // A factory to pin the backup_job tasks. 435 // A factory to pin the backup_job tasks.
431 ScopedRunnableMethodFactory<ClientSocketPoolBaseHelper> method_factory_; 436 ScopedRunnableMethodFactory<ClientSocketPoolBaseHelper> method_factory_;
432 }; 437 };
433 438
434 } // namespace internal 439 } // namespace internal
435 440
436 // The maximum duration, in seconds, to keep unused idle persistent sockets 441 // The maximum duration, in seconds, to keep unused idle persistent sockets
437 // alive. 442 // alive.
438 // TODO(willchan): Change this timeout after getting histogram data on how 443 // TODO(willchan): Change this timeout after getting histogram data on how
439 // long it should be. 444 // long it should be.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 553 }
549 554
550 int NumConnectJobsInGroup(const std::string& group_name) const { 555 int NumConnectJobsInGroup(const std::string& group_name) const {
551 return helper_->NumConnectJobsInGroup(group_name); 556 return helper_->NumConnectJobsInGroup(group_name);
552 } 557 }
553 558
554 void CleanupIdleSockets(bool force) { 559 void CleanupIdleSockets(bool force) {
555 return helper_->CleanupIdleSockets(force); 560 return helper_->CleanupIdleSockets(force);
556 } 561 }
557 562
563 void enable_backup_jobs() { helper_->enable_backup_jobs(); };
564
558 private: 565 private:
559 // This adaptor class exists to bridge the 566 // This adaptor class exists to bridge the
560 // internal::ClientSocketPoolBaseHelper::ConnectJobFactory and 567 // internal::ClientSocketPoolBaseHelper::ConnectJobFactory and
561 // ClientSocketPoolBase::ConnectJobFactory types, allowing clients to use the 568 // ClientSocketPoolBase::ConnectJobFactory types, allowing clients to use the
562 // typesafe ClientSocketPoolBase::ConnectJobFactory, rather than having to 569 // typesafe ClientSocketPoolBase::ConnectJobFactory, rather than having to
563 // static_cast themselves. 570 // static_cast themselves.
564 class ConnectJobFactoryAdaptor 571 class ConnectJobFactoryAdaptor
565 : public internal::ClientSocketPoolBaseHelper::ConnectJobFactory { 572 : public internal::ClientSocketPoolBaseHelper::ConnectJobFactory {
566 public: 573 public:
567 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory 574 typedef typename ClientSocketPoolBase<SocketParams>::ConnectJobFactory
(...skipping 23 matching lines...) Expand all
591 // the posting of the task and the execution, then we'll hit the DCHECK that 598 // the posting of the task and the execution, then we'll hit the DCHECK that
592 // |ClientSocketPoolBaseHelper::group_map_| is empty. 599 // |ClientSocketPoolBaseHelper::group_map_| is empty.
593 scoped_refptr<internal::ClientSocketPoolBaseHelper> helper_; 600 scoped_refptr<internal::ClientSocketPoolBaseHelper> helper_;
594 601
595 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 602 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
596 }; 603 };
597 604
598 } // namespace net 605 } // namespace net
599 606
600 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 607 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698