| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 // it does not handle logging into NetLog of the queueing status of | 574 // it does not handle logging into NetLog of the queueing status of |
| 570 // |request|. | 575 // |request|. |
| 571 int RequestSocketInternal(const std::string& group_name, | 576 int RequestSocketInternal(const std::string& group_name, |
| 572 const Request& request); | 577 const Request& request); |
| 573 | 578 |
| 574 // Assigns an idle socket for the group to the request. | 579 // Assigns an idle socket for the group to the request. |
| 575 // Returns |true| if an idle socket is available, false otherwise. | 580 // Returns |true| if an idle socket is available, false otherwise. |
| 576 bool AssignIdleSocketToRequest(const Request& request, Group* group); | 581 bool AssignIdleSocketToRequest(const Request& request, Group* group); |
| 577 | 582 |
| 578 static void LogBoundConnectJobToRequest( | 583 static void LogBoundConnectJobToRequest( |
| 579 const NetLog::Source& connect_job_source, const Request& request); | 584 const NetLogSource& connect_job_source, |
| 585 const Request& request); |
| 580 | 586 |
| 581 // Same as CloseOneIdleSocket() except it won't close an idle socket in | 587 // Same as CloseOneIdleSocket() except it won't close an idle socket in |
| 582 // |group|. If |group| is NULL, it is ignored. Returns true if it closed a | 588 // |group|. If |group| is NULL, it is ignored. Returns true if it closed a |
| 583 // socket. | 589 // socket. |
| 584 bool CloseOneIdleSocketExceptInGroup(const Group* group); | 590 bool CloseOneIdleSocketExceptInGroup(const Group* group); |
| 585 | 591 |
| 586 // Checks if there are stalled socket groups that should be notified | 592 // Checks if there are stalled socket groups that should be notified |
| 587 // for possible wakeup. | 593 // for possible wakeup. |
| 588 void CheckForStalledSocketGroups(); | 594 void CheckForStalledSocketGroups(); |
| 589 | 595 |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 }; | 873 }; |
| 868 | 874 |
| 869 internal::ClientSocketPoolBaseHelper helper_; | 875 internal::ClientSocketPoolBaseHelper helper_; |
| 870 | 876 |
| 871 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 877 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
| 872 }; | 878 }; |
| 873 | 879 |
| 874 } // namespace net | 880 } // namespace net |
| 875 | 881 |
| 876 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 882 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
| OLD | NEW |