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

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

Issue 11464028: Introduce ERR_NETWORK_CHANGED and allow URLFetcher to automatically retry on that error. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 8 years 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_pool.h ('k') | 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) 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 // 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 235
236 // See ClientSocketPool::CancelRequest for documentation on this function. 236 // See ClientSocketPool::CancelRequest for documentation on this function.
237 void CancelRequest(const std::string& group_name, 237 void CancelRequest(const std::string& group_name,
238 ClientSocketHandle* handle); 238 ClientSocketHandle* handle);
239 239
240 // See ClientSocketPool::ReleaseSocket for documentation on this function. 240 // See ClientSocketPool::ReleaseSocket for documentation on this function.
241 void ReleaseSocket(const std::string& group_name, 241 void ReleaseSocket(const std::string& group_name,
242 StreamSocket* socket, 242 StreamSocket* socket,
243 int id); 243 int id);
244 244
245 // See ClientSocketPool::Flush for documentation on this function. 245 // See ClientSocketPool::FlushWithError for documentation on this function.
246 void Flush(); 246 void FlushWithError(int error);
247 247
248 // See ClientSocketPool::IsStalled for documentation on this function. 248 // See ClientSocketPool::IsStalled for documentation on this function.
249 bool IsStalled() const; 249 bool IsStalled() const;
250 250
251 // See ClientSocketPool::CloseIdleSockets for documentation on this function. 251 // See ClientSocketPool::CloseIdleSockets for documentation on this function.
252 void CloseIdleSockets(); 252 void CloseIdleSockets();
253 253
254 // See ClientSocketPool::IdleSocketCount() for documentation on this function. 254 // See ClientSocketPool::IdleSocketCount() for documentation on this function.
255 int idle_socket_count() const { 255 int idle_socket_count() const {
256 return idle_socket_count_; 256 return idle_socket_count_;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 Group* group, 498 Group* group,
499 const BoundNetLog& net_log); 499 const BoundNetLog& net_log);
500 500
501 // Adds |socket| to the list of idle sockets for |group|. 501 // Adds |socket| to the list of idle sockets for |group|.
502 void AddIdleSocket(StreamSocket* socket, Group* group); 502 void AddIdleSocket(StreamSocket* socket, Group* group);
503 503
504 // Iterates through |group_map_|, canceling all ConnectJobs and deleting 504 // Iterates through |group_map_|, canceling all ConnectJobs and deleting
505 // groups if they are no longer needed. 505 // groups if they are no longer needed.
506 void CancelAllConnectJobs(); 506 void CancelAllConnectJobs();
507 507
508 // Iterates through |group_map_|, posting ERR_ABORTED callbacks for all 508 // Iterates through |group_map_|, posting |error| callbacks for all
509 // requests, and then deleting groups if they are no longer needed. 509 // requests, and then deleting groups if they are no longer needed.
510 void AbortAllRequests(); 510 void CancelAllRequestsWithError(int error);
511 511
512 // Returns true if we can't create any more sockets due to the total limit. 512 // Returns true if we can't create any more sockets due to the total limit.
513 bool ReachedMaxSocketsLimit() const; 513 bool ReachedMaxSocketsLimit() const;
514 514
515 // This is the internal implementation of RequestSocket(). It differs in that 515 // This is the internal implementation of RequestSocket(). It differs in that
516 // it does not handle logging into NetLog of the queueing status of 516 // it does not handle logging into NetLog of the queueing status of
517 // |request|. 517 // |request|.
518 int RequestSocketInternal(const std::string& group_name, 518 int RequestSocketInternal(const std::string& group_name,
519 const Request* request); 519 const Request* request);
520 520
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 577
578 // The time to wait until closing idle sockets. 578 // The time to wait until closing idle sockets.
579 const base::TimeDelta unused_idle_socket_timeout_; 579 const base::TimeDelta unused_idle_socket_timeout_;
580 const base::TimeDelta used_idle_socket_timeout_; 580 const base::TimeDelta used_idle_socket_timeout_;
581 581
582 const scoped_ptr<ConnectJobFactory> connect_job_factory_; 582 const scoped_ptr<ConnectJobFactory> connect_job_factory_;
583 583
584 // TODO(vandebo) Remove when backup jobs move to TransportClientSocketPool 584 // TODO(vandebo) Remove when backup jobs move to TransportClientSocketPool
585 bool connect_backup_jobs_enabled_; 585 bool connect_backup_jobs_enabled_;
586 586
587 // A unique id for the pool. It gets incremented every time we Flush() the 587 // A unique id for the pool. It gets incremented every time we
588 // pool. This is so that when sockets get released back to the pool, we can 588 // FlushWithError() the pool. This is so that when sockets get released back
589 // make sure that they are discarded rather than reused. 589 // to the pool, we can make sure that they are discarded rather than reused.
590 int pool_generation_number_; 590 int pool_generation_number_;
591 591
592 std::set<LayeredPool*> higher_layer_pools_; 592 std::set<LayeredPool*> higher_layer_pools_;
593 593
594 base::WeakPtrFactory<ClientSocketPoolBaseHelper> weak_factory_; 594 base::WeakPtrFactory<ClientSocketPoolBaseHelper> weak_factory_;
595 595
596 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBaseHelper); 596 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBaseHelper);
597 }; 597 };
598 598
599 } // namespace internal 599 } // namespace internal
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void CancelRequest(const std::string& group_name, 701 void CancelRequest(const std::string& group_name,
702 ClientSocketHandle* handle) { 702 ClientSocketHandle* handle) {
703 return helper_.CancelRequest(group_name, handle); 703 return helper_.CancelRequest(group_name, handle);
704 } 704 }
705 705
706 void ReleaseSocket(const std::string& group_name, StreamSocket* socket, 706 void ReleaseSocket(const std::string& group_name, StreamSocket* socket,
707 int id) { 707 int id) {
708 return helper_.ReleaseSocket(group_name, socket, id); 708 return helper_.ReleaseSocket(group_name, socket, id);
709 } 709 }
710 710
711 void Flush() { helper_.Flush(); } 711 void FlushWithError(int error) { helper_.FlushWithError(error); }
712 712
713 bool IsStalled() const { return helper_.IsStalled(); } 713 bool IsStalled() const { return helper_.IsStalled(); }
714 714
715 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } 715 void CloseIdleSockets() { return helper_.CloseIdleSockets(); }
716 716
717 int idle_socket_count() const { return helper_.idle_socket_count(); } 717 int idle_socket_count() const { return helper_.idle_socket_count(); }
718 718
719 int IdleSocketCountInGroup(const std::string& group_name) const { 719 int IdleSocketCountInGroup(const std::string& group_name) const {
720 return helper_.IdleSocketCountInGroup(group_name); 720 return helper_.IdleSocketCountInGroup(group_name);
721 } 721 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // Histograms for the pool 805 // Histograms for the pool
806 ClientSocketPoolHistograms* const histograms_; 806 ClientSocketPoolHistograms* const histograms_;
807 internal::ClientSocketPoolBaseHelper helper_; 807 internal::ClientSocketPoolBaseHelper helper_;
808 808
809 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 809 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
810 }; 810 };
811 811
812 } // namespace net 812 } // namespace net
813 813
814 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 814 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW
« no previous file with comments | « net/socket/client_socket_pool.h ('k') | net/socket/client_socket_pool_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698