| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 5 #ifndef NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| 6 #define NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 6 #define NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 base::TimeDelta idle_time() const { return idle_time_; } | 97 base::TimeDelta idle_time() const { return idle_time_; } |
| 98 SocketReuseType reuse_type() const { | 98 SocketReuseType reuse_type() const { |
| 99 if (is_reused()) { | 99 if (is_reused()) { |
| 100 return REUSED_IDLE; | 100 return REUSED_IDLE; |
| 101 } else if (idle_time() == base::TimeDelta()) { | 101 } else if (idle_time() == base::TimeDelta()) { |
| 102 return UNUSED; | 102 return UNUSED; |
| 103 } else { | 103 } else { |
| 104 return UNUSED_IDLE; | 104 return UNUSED_IDLE; |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 bool ShouldResendFailedRequest(int error) const { |
| 108 // NOTE: we resend a request only if we reused a keep-alive connection. |
| 109 // This automatically prevents an infinite resend loop because we'll run |
| 110 // out of the cached keep-alive connections eventually. |
| 111 if ( // We used a socket that was never idle. |
| 112 reuse_type() == ClientSocketHandle::UNUSED || |
| 113 // We used an unused, idle socket and got a error that wasn't a TCP RST. |
| 114 (reuse_type() == ClientSocketHandle::UNUSED_IDLE && |
| 115 (error != OK && error != ERR_CONNECTION_RESET))) { |
| 116 return false; |
| 117 } |
| 118 return true; |
| 119 } |
| 107 | 120 |
| 108 private: | 121 private: |
| 109 // Called on asynchronous completion of an Init() request. | 122 // Called on asynchronous completion of an Init() request. |
| 110 void OnIOComplete(int result); | 123 void OnIOComplete(int result); |
| 111 | 124 |
| 112 // Called on completion (both asynchronous & synchronous) of an Init() | 125 // Called on completion (both asynchronous & synchronous) of an Init() |
| 113 // request. | 126 // request. |
| 114 void HandleInitCompletion(int result); | 127 void HandleInitCompletion(int result); |
| 115 | 128 |
| 116 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or | 129 // Resets the state of the ClientSocketHandle. |cancel| indicates whether or |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 user_callback_ = callback; | 165 user_callback_ = callback; |
| 153 } else { | 166 } else { |
| 154 HandleInitCompletion(rv); | 167 HandleInitCompletion(rv); |
| 155 } | 168 } |
| 156 return rv; | 169 return rv; |
| 157 } | 170 } |
| 158 | 171 |
| 159 } // namespace net | 172 } // namespace net |
| 160 | 173 |
| 161 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ | 174 #endif // NET_SOCKET_CLIENT_SOCKET_HANDLE_H_ |
| OLD | NEW |