| OLD | NEW |
| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "base/timer/timer.h" | 42 #include "base/timer/timer.h" |
| 43 #include "net/base/address_list.h" | 43 #include "net/base/address_list.h" |
| 44 #include "net/base/completion_callback.h" | 44 #include "net/base/completion_callback.h" |
| 45 #include "net/base/load_states.h" | 45 #include "net/base/load_states.h" |
| 46 #include "net/base/load_timing_info.h" | 46 #include "net/base/load_timing_info.h" |
| 47 #include "net/base/net_errors.h" | 47 #include "net/base/net_errors.h" |
| 48 #include "net/base/net_export.h" | 48 #include "net/base/net_export.h" |
| 49 #include "net/base/network_change_notifier.h" | 49 #include "net/base/network_change_notifier.h" |
| 50 #include "net/base/priority_queue.h" | 50 #include "net/base/priority_queue.h" |
| 51 #include "net/base/request_priority.h" | 51 #include "net/base/request_priority.h" |
| 52 #include "net/log/net_log.h" | 52 #include "net/log/net_log_with_source.h" |
| 53 #include "net/socket/client_socket_handle.h" | 53 #include "net/socket/client_socket_handle.h" |
| 54 #include "net/socket/client_socket_pool.h" | 54 #include "net/socket/client_socket_pool.h" |
| 55 #include "net/socket/stream_socket.h" | 55 #include "net/socket/stream_socket.h" |
| 56 | 56 |
| 57 namespace base { |
| 58 class DictionaryValue; |
| 59 } |
| 60 |
| 57 namespace net { | 61 namespace net { |
| 58 | 62 |
| 59 class ClientSocketHandle; | 63 class ClientSocketHandle; |
| 64 struct NetLogSource; |
| 60 | 65 |
| 61 // ConnectJob provides an abstract interface for "connecting" a socket. | 66 // ConnectJob provides an abstract interface for "connecting" a socket. |
| 62 // The connection may involve host resolution, tcp connection, ssl connection, | 67 // The connection may involve host resolution, tcp connection, ssl connection, |
| 63 // etc. | 68 // etc. |
| 64 class NET_EXPORT_PRIVATE ConnectJob { | 69 class NET_EXPORT_PRIVATE ConnectJob { |
| 65 public: | 70 public: |
| 66 class NET_EXPORT_PRIVATE Delegate { | 71 class NET_EXPORT_PRIVATE Delegate { |
| 67 public: | 72 public: |
| 68 Delegate() {} | 73 Delegate() {} |
| 69 virtual ~Delegate() {} | 74 virtual ~Delegate() {} |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 // it does not handle logging into NetLog of the queueing status of | 572 // it does not handle logging into NetLog of the queueing status of |
| 568 // |request|. | 573 // |request|. |
| 569 int RequestSocketInternal(const std::string& group_name, | 574 int RequestSocketInternal(const std::string& group_name, |
| 570 const Request& request); | 575 const Request& request); |
| 571 | 576 |
| 572 // Assigns an idle socket for the group to the request. | 577 // Assigns an idle socket for the group to the request. |
| 573 // Returns |true| if an idle socket is available, false otherwise. | 578 // Returns |true| if an idle socket is available, false otherwise. |
| 574 bool AssignIdleSocketToRequest(const Request& request, Group* group); | 579 bool AssignIdleSocketToRequest(const Request& request, Group* group); |
| 575 | 580 |
| 576 static void LogBoundConnectJobToRequest( | 581 static void LogBoundConnectJobToRequest( |
| 577 const NetLog::Source& connect_job_source, const Request& request); | 582 const NetLogSource& connect_job_source, |
| 583 const Request& request); |
| 578 | 584 |
| 579 // Same as CloseOneIdleSocket() except it won't close an idle socket in | 585 // Same as CloseOneIdleSocket() except it won't close an idle socket in |
| 580 // |group|. If |group| is NULL, it is ignored. Returns true if it closed a | 586 // |group|. If |group| is NULL, it is ignored. Returns true if it closed a |
| 581 // socket. | 587 // socket. |
| 582 bool CloseOneIdleSocketExceptInGroup(const Group* group); | 588 bool CloseOneIdleSocketExceptInGroup(const Group* group); |
| 583 | 589 |
| 584 // Checks if there are stalled socket groups that should be notified | 590 // Checks if there are stalled socket groups that should be notified |
| 585 // for possible wakeup. | 591 // for possible wakeup. |
| 586 void CheckForStalledSocketGroups(); | 592 void CheckForStalledSocketGroups(); |
| 587 | 593 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 }; | 871 }; |
| 866 | 872 |
| 867 internal::ClientSocketPoolBaseHelper helper_; | 873 internal::ClientSocketPoolBaseHelper helper_; |
| 868 | 874 |
| 869 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 875 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 870 }; | 876 }; |
| 871 | 877 |
| 872 } // namespace net | 878 } // namespace net |
| 873 | 879 |
| 874 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 880 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |