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

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: addressed comments 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
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::Flush for documentation on this function.
246 void Flush(); 246 // Each request aborted by this call will get |error| as the failure reason.
247 void Flush(int error);
247 248
248 // See ClientSocketPool::IsStalled for documentation on this function. 249 // See ClientSocketPool::IsStalled for documentation on this function.
249 bool IsStalled() const; 250 bool IsStalled() const;
250 251
251 // See ClientSocketPool::CloseIdleSockets for documentation on this function. 252 // See ClientSocketPool::CloseIdleSockets for documentation on this function.
252 void CloseIdleSockets(); 253 void CloseIdleSockets();
253 254
254 // See ClientSocketPool::IdleSocketCount() for documentation on this function. 255 // See ClientSocketPool::IdleSocketCount() for documentation on this function.
255 int idle_socket_count() const { 256 int idle_socket_count() const {
256 return idle_socket_count_; 257 return idle_socket_count_;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 Group* group, 499 Group* group,
499 const BoundNetLog& net_log); 500 const BoundNetLog& net_log);
500 501
501 // Adds |socket| to the list of idle sockets for |group|. 502 // Adds |socket| to the list of idle sockets for |group|.
502 void AddIdleSocket(StreamSocket* socket, Group* group); 503 void AddIdleSocket(StreamSocket* socket, Group* group);
503 504
504 // Iterates through |group_map_|, canceling all ConnectJobs and deleting 505 // Iterates through |group_map_|, canceling all ConnectJobs and deleting
505 // groups if they are no longer needed. 506 // groups if they are no longer needed.
506 void CancelAllConnectJobs(); 507 void CancelAllConnectJobs();
507 508
508 // Iterates through |group_map_|, posting ERR_ABORTED callbacks for all 509 // Iterates through |group_map_|, posting |error| callbacks for all
509 // requests, and then deleting groups if they are no longer needed. 510 // requests, and then deleting groups if they are no longer needed.
510 void AbortAllRequests(); 511 void AbortAllRequests(int error);
511 512
512 // Returns true if we can't create any more sockets due to the total limit. 513 // Returns true if we can't create any more sockets due to the total limit.
513 bool ReachedMaxSocketsLimit() const; 514 bool ReachedMaxSocketsLimit() const;
514 515
515 // This is the internal implementation of RequestSocket(). It differs in that 516 // This is the internal implementation of RequestSocket(). It differs in that
516 // it does not handle logging into NetLog of the queueing status of 517 // it does not handle logging into NetLog of the queueing status of
517 // |request|. 518 // |request|.
518 int RequestSocketInternal(const std::string& group_name, 519 int RequestSocketInternal(const std::string& group_name,
519 const Request* request); 520 const Request* request);
520 521
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 void CancelRequest(const std::string& group_name, 702 void CancelRequest(const std::string& group_name,
702 ClientSocketHandle* handle) { 703 ClientSocketHandle* handle) {
703 return helper_.CancelRequest(group_name, handle); 704 return helper_.CancelRequest(group_name, handle);
704 } 705 }
705 706
706 void ReleaseSocket(const std::string& group_name, StreamSocket* socket, 707 void ReleaseSocket(const std::string& group_name, StreamSocket* socket,
707 int id) { 708 int id) {
708 return helper_.ReleaseSocket(group_name, socket, id); 709 return helper_.ReleaseSocket(group_name, socket, id);
709 } 710 }
710 711
711 void Flush() { helper_.Flush(); } 712 void Flush() { helper_.Flush(ERR_NETWORK_CHANGED); }
willchan no longer on Chromium 2012/12/11 17:39:33 It's non-obvious that Flush() should always mean E
Joao da Silva 2012/12/11 17:52:57 The previous patch sets had ERR_ABORTED here, but
szym 2012/12/11 17:54:45 I agree it's not obvious. I followed the call grap
willchan no longer on Chromium 2012/12/11 18:06:14 Assuming ERR_NETWORK_CHANGED sounds wrong here the
Joao da Silva 2012/12/11 21:14:55 Flush() has been changed to FlushWithError(int) as
712 713
713 bool IsStalled() const { return helper_.IsStalled(); } 714 bool IsStalled() const { return helper_.IsStalled(); }
714 715
715 void CloseIdleSockets() { return helper_.CloseIdleSockets(); } 716 void CloseIdleSockets() { return helper_.CloseIdleSockets(); }
716 717
717 int idle_socket_count() const { return helper_.idle_socket_count(); } 718 int idle_socket_count() const { return helper_.idle_socket_count(); }
718 719
719 int IdleSocketCountInGroup(const std::string& group_name) const { 720 int IdleSocketCountInGroup(const std::string& group_name) const {
720 return helper_.IdleSocketCountInGroup(group_name); 721 return helper_.IdleSocketCountInGroup(group_name);
721 } 722 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 // Histograms for the pool 806 // Histograms for the pool
806 ClientSocketPoolHistograms* const histograms_; 807 ClientSocketPoolHistograms* const histograms_;
807 internal::ClientSocketPoolBaseHelper helper_; 808 internal::ClientSocketPoolBaseHelper helper_;
808 809
809 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); 810 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase);
810 }; 811 };
811 812
812 } // namespace net 813 } // namespace net
813 814
814 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ 815 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698