| 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 #include "net/socket/tcp_client_socket_pool.h" | 5 #include "net/socket/tcp_client_socket_pool.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // TODO(willchan): Update all unittests so we don't need this. | 31 // TODO(willchan): Update all unittests so we don't need this. |
| 32 TCPSocketParams::TCPSocketParams(const std::string& host, int port, | 32 TCPSocketParams::TCPSocketParams(const std::string& host, int port, |
| 33 RequestPriority priority, const GURL& referrer, | 33 RequestPriority priority, const GURL& referrer, |
| 34 bool disable_resolver_cache) | 34 bool disable_resolver_cache) |
| 35 : destination_(HostPortPair(host, port)) { | 35 : destination_(HostPortPair(host, port)) { |
| 36 Initialize(priority, referrer, disable_resolver_cache); | 36 Initialize(priority, referrer, disable_resolver_cache); |
| 37 } | 37 } |
| 38 | 38 |
| 39 TCPSocketParams::~TCPSocketParams() {} | 39 TCPSocketParams::~TCPSocketParams() {} |
| 40 | 40 |
| 41 void TCPSocketParams::Initialize(RequestPriority priority, |
| 42 const GURL& referrer, |
| 43 bool disable_resolver_cache) { |
| 44 // The referrer is used by the DNS prefetch system to correlate resolutions |
| 45 // with the page that triggered them. It doesn't impact the actual addresses |
| 46 // that we resolve to. |
| 47 destination_.set_referrer(referrer); |
| 48 destination_.set_priority(priority); |
| 49 if (disable_resolver_cache) |
| 50 destination_.set_allow_cached_response(false); |
| 51 } |
| 52 |
| 41 // TCPConnectJobs will time out after this many seconds. Note this is the total | 53 // TCPConnectJobs will time out after this many seconds. Note this is the total |
| 42 // time, including both host resolution and TCP connect() times. | 54 // time, including both host resolution and TCP connect() times. |
| 43 // | 55 // |
| 44 // TODO(eroman): The use of this constant needs to be re-evaluated. The time | 56 // TODO(eroman): The use of this constant needs to be re-evaluated. The time |
| 45 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since | 57 // needed for TCPClientSocketXXX::Connect() can be arbitrarily long, since |
| 46 // the address list may contain many alternatives, and most of those may | 58 // the address list may contain many alternatives, and most of those may |
| 47 // timeout. Even worse, the per-connect timeout threshold varies greatly | 59 // timeout. Even worse, the per-connect timeout threshold varies greatly |
| 48 // between systems (anywhere from 20 seconds to 190 seconds). | 60 // between systems (anywhere from 20 seconds to 190 seconds). |
| 49 // See comment #12 at http://crbug.com/23364 for specifics. | 61 // See comment #12 at http://crbug.com/23364 for specifics. |
| 50 static const int kTCPConnectJobTimeoutInSeconds = 240; // 4 minutes. | 62 static const int kTCPConnectJobTimeoutInSeconds = 240; // 4 minutes. |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 277 } |
| 266 | 278 |
| 267 void TCPClientSocketPool::Flush() { | 279 void TCPClientSocketPool::Flush() { |
| 268 base_.Flush(); | 280 base_.Flush(); |
| 269 } | 281 } |
| 270 | 282 |
| 271 void TCPClientSocketPool::CloseIdleSockets() { | 283 void TCPClientSocketPool::CloseIdleSockets() { |
| 272 base_.CloseIdleSockets(); | 284 base_.CloseIdleSockets(); |
| 273 } | 285 } |
| 274 | 286 |
| 287 int TCPClientSocketPool::IdleSocketCount() const { |
| 288 return base_.idle_socket_count(); |
| 289 } |
| 290 |
| 275 int TCPClientSocketPool::IdleSocketCountInGroup( | 291 int TCPClientSocketPool::IdleSocketCountInGroup( |
| 276 const std::string& group_name) const { | 292 const std::string& group_name) const { |
| 277 return base_.IdleSocketCountInGroup(group_name); | 293 return base_.IdleSocketCountInGroup(group_name); |
| 278 } | 294 } |
| 279 | 295 |
| 280 LoadState TCPClientSocketPool::GetLoadState( | 296 LoadState TCPClientSocketPool::GetLoadState( |
| 281 const std::string& group_name, const ClientSocketHandle* handle) const { | 297 const std::string& group_name, const ClientSocketHandle* handle) const { |
| 282 return base_.GetLoadState(group_name, handle); | 298 return base_.GetLoadState(group_name, handle); |
| 283 } | 299 } |
| 284 | 300 |
| 301 DictionaryValue* TCPClientSocketPool::GetInfoAsValue( |
| 302 const std::string& name, |
| 303 const std::string& type, |
| 304 bool include_nested_pools) const { |
| 305 return base_.GetInfoAsValue(name, type); |
| 306 } |
| 307 |
| 308 base::TimeDelta TCPClientSocketPool::ConnectionTimeout() const { |
| 309 return base_.ConnectionTimeout(); |
| 310 } |
| 311 |
| 312 ClientSocketPoolHistograms* TCPClientSocketPool::histograms() const { |
| 313 return base_.histograms(); |
| 314 } |
| 315 |
| 285 } // namespace net | 316 } // namespace net |
| OLD | NEW |