OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // Begins connecting the socket. Returns OK on success, ERR_IO_PENDING if it | 83 // Begins connecting the socket. Returns OK on success, ERR_IO_PENDING if it |
84 // cannot complete synchronously without blocking, or another net error code | 84 // cannot complete synchronously without blocking, or another net error code |
85 // on error. In asynchronous completion, the ConnectJob will notify | 85 // on error. In asynchronous completion, the ConnectJob will notify |
86 // |delegate_| via OnConnectJobComplete. In both asynchronous and synchronous | 86 // |delegate_| via OnConnectJobComplete. In both asynchronous and synchronous |
87 // completion, ReleaseSocket() can be called to acquire the connected socket | 87 // completion, ReleaseSocket() can be called to acquire the connected socket |
88 // if it succeeded. | 88 // if it succeeded. |
89 int Connect(); | 89 int Connect(); |
90 | 90 |
91 virtual LoadState GetLoadState() const = 0; | 91 virtual LoadState GetLoadState() const = 0; |
92 | 92 |
| 93 // If Connect returns an error (or OnConnectJobComplete reports an error |
| 94 // result) this method will be called, allowing the pool to add |
| 95 // additional error state to the ClientSocketHandle (post late-binding). |
| 96 virtual void GetAdditionalErrorState(ClientSocketHandle* handle) {} |
| 97 |
93 protected: | 98 protected: |
94 void set_socket(ClientSocket* socket); | 99 void set_socket(ClientSocket* socket); |
95 ClientSocket* socket() { return socket_.get(); } | 100 ClientSocket* socket() { return socket_.get(); } |
96 void NotifyDelegateOfCompletion(int rv); | 101 void NotifyDelegateOfCompletion(int rv); |
97 void ResetTimer(base::TimeDelta remainingTime); | 102 void ResetTimer(base::TimeDelta remainingTime); |
98 | 103 |
99 private: | 104 private: |
100 virtual int ConnectInternal() = 0; | 105 virtual int ConnectInternal() = 0; |
101 | 106 |
102 void LogConnectStart(); | 107 void LogConnectStart(); |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 // ClientSocketPoolBase<T> reference to drop to zero. While we're deep | 614 // ClientSocketPoolBase<T> reference to drop to zero. While we're deep |
610 // in cleanup code, we'll often hold a reference to |self|. | 615 // in cleanup code, we'll often hold a reference to |self|. |
611 scoped_refptr<internal::ClientSocketPoolBaseHelper> helper_; | 616 scoped_refptr<internal::ClientSocketPoolBaseHelper> helper_; |
612 | 617 |
613 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); | 618 DISALLOW_COPY_AND_ASSIGN(ClientSocketPoolBase); |
614 }; | 619 }; |
615 | 620 |
616 } // namespace net | 621 } // namespace net |
617 | 622 |
618 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ | 623 #endif // NET_SOCKET_CLIENT_SOCKET_POOL_BASE_H_ |
OLD | NEW |