Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: net/http/http_proxy_client_socket_pool.cc

Issue 851503003: Update from https://crrev.com/311076 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "net/http/http_proxy_client_socket_pool.h" 5 #include "net/http/http_proxy_client_socket_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 static const int kHttpProxyConnectJobTimeoutInSeconds = 30; 79 static const int kHttpProxyConnectJobTimeoutInSeconds = 30;
80 #endif 80 #endif
81 81
82 HttpProxyConnectJob::HttpProxyConnectJob( 82 HttpProxyConnectJob::HttpProxyConnectJob(
83 const std::string& group_name, 83 const std::string& group_name,
84 RequestPriority priority, 84 RequestPriority priority,
85 const scoped_refptr<HttpProxySocketParams>& params, 85 const scoped_refptr<HttpProxySocketParams>& params,
86 const base::TimeDelta& timeout_duration, 86 const base::TimeDelta& timeout_duration,
87 TransportClientSocketPool* transport_pool, 87 TransportClientSocketPool* transport_pool,
88 SSLClientSocketPool* ssl_pool, 88 SSLClientSocketPool* ssl_pool,
89 HostResolver* host_resolver,
90 Delegate* delegate, 89 Delegate* delegate,
91 NetLog* net_log) 90 NetLog* net_log)
92 : ConnectJob(group_name, timeout_duration, priority, delegate, 91 : ConnectJob(group_name, timeout_duration, priority, delegate,
93 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)), 92 BoundNetLog::Make(net_log, NetLog::SOURCE_CONNECT_JOB)),
94 params_(params), 93 params_(params),
95 transport_pool_(transport_pool), 94 transport_pool_(transport_pool),
96 ssl_pool_(ssl_pool), 95 ssl_pool_(ssl_pool),
97 resolver_(host_resolver),
98 using_spdy_(false), 96 using_spdy_(false),
99 protocol_negotiated_(kProtoUnknown), 97 protocol_negotiated_(kProtoUnknown),
100 weak_ptr_factory_(this) { 98 weak_ptr_factory_(this) {
101 callback_= base::Bind(&HttpProxyConnectJob::OnIOComplete, 99 callback_= base::Bind(&HttpProxyConnectJob::OnIOComplete,
102 weak_ptr_factory_.GetWeakPtr()); 100 weak_ptr_factory_.GetWeakPtr());
103 } 101 }
104 102
105 HttpProxyConnectJob::~HttpProxyConnectJob() {} 103 HttpProxyConnectJob::~HttpProxyConnectJob() {}
106 104
107 LoadState HttpProxyConnectJob::GetLoadState() const { 105 LoadState HttpProxyConnectJob::GetLoadState() const {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 params_->ssl_params().get() != NULL)); 299 params_->ssl_params().get() != NULL));
302 return transport_socket_->Connect(callback_); 300 return transport_socket_->Connect(callback_);
303 } 301 }
304 302
305 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) { 303 int HttpProxyConnectJob::DoHttpProxyConnectComplete(int result) {
306 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED || 304 if (result == OK || result == ERR_PROXY_AUTH_REQUESTED ||
307 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) { 305 result == ERR_HTTPS_PROXY_TUNNEL_RESPONSE) {
308 SetSocket(transport_socket_.Pass()); 306 SetSocket(transport_socket_.Pass());
309 } 307 }
310 308
309 if (result == ERR_HTTP_1_1_REQUIRED)
310 return ERR_PROXY_HTTP_1_1_REQUIRED;
311
311 return result; 312 return result;
312 } 313 }
313 314
314 int HttpProxyConnectJob::DoSpdyProxyCreateStream() { 315 int HttpProxyConnectJob::DoSpdyProxyCreateStream() {
315 DCHECK(using_spdy_); 316 DCHECK(using_spdy_);
316 DCHECK(params_->tunnel()); 317 DCHECK(params_->tunnel());
317 SpdySessionKey key(params_->destination().host_port_pair(), 318 SpdySessionKey key(params_->destination().host_port_pair(),
318 ProxyServer::Direct(), 319 ProxyServer::Direct(),
319 PRIVACY_MODE_DISABLED); 320 PRIVACY_MODE_DISABLED);
320 SpdySessionPool* spdy_pool = params_->spdy_session_pool(); 321 SpdySessionPool* spdy_pool = params_->spdy_session_pool();
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 } 389 }
389 390
390 return rv; 391 return rv;
391 } 392 }
392 393
393 HttpProxyClientSocketPool:: 394 HttpProxyClientSocketPool::
394 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory( 395 HttpProxyConnectJobFactory::HttpProxyConnectJobFactory(
395 TransportClientSocketPool* transport_pool, 396 TransportClientSocketPool* transport_pool,
396 SSLClientSocketPool* ssl_pool, 397 SSLClientSocketPool* ssl_pool,
397 HostResolver* host_resolver, 398 HostResolver* host_resolver,
398 const ProxyDelegate* proxy_delegate,
399 NetLog* net_log) 399 NetLog* net_log)
400 : transport_pool_(transport_pool), 400 : transport_pool_(transport_pool),
401 ssl_pool_(ssl_pool), 401 ssl_pool_(ssl_pool),
402 host_resolver_(host_resolver), 402 host_resolver_(host_resolver),
403 proxy_delegate_(proxy_delegate),
404 net_log_(net_log) { 403 net_log_(net_log) {
405 base::TimeDelta max_pool_timeout = base::TimeDelta(); 404 base::TimeDelta max_pool_timeout = base::TimeDelta();
406 405
407 // TODO(kundaji): Proxy connect timeout should be independent of platform and be 406 // TODO(kundaji): Proxy connect timeout should be independent of platform and be
408 // based on proxy. Bug http://crbug.com/407446. 407 // based on proxy. Bug http://crbug.com/407446.
409 #if (defined(OS_ANDROID) || defined(OS_IOS)) 408 #if (defined(OS_ANDROID) || defined(OS_IOS))
410 #else 409 #else
411 if (transport_pool_) 410 if (transport_pool_)
412 max_pool_timeout = transport_pool_->ConnectionTimeout(); 411 max_pool_timeout = transport_pool_->ConnectionTimeout();
413 if (ssl_pool_) 412 if (ssl_pool_)
414 max_pool_timeout = std::max(max_pool_timeout, 413 max_pool_timeout = std::max(max_pool_timeout,
415 ssl_pool_->ConnectionTimeout()); 414 ssl_pool_->ConnectionTimeout());
416 #endif 415 #endif
417 timeout_ = max_pool_timeout + 416 timeout_ = max_pool_timeout +
418 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds); 417 base::TimeDelta::FromSeconds(kHttpProxyConnectJobTimeoutInSeconds);
419 } 418 }
420 419
421 420
422 scoped_ptr<ConnectJob> 421 scoped_ptr<ConnectJob>
423 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob( 422 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::NewConnectJob(
424 const std::string& group_name, 423 const std::string& group_name,
425 const PoolBase::Request& request, 424 const PoolBase::Request& request,
426 ConnectJob::Delegate* delegate) const { 425 ConnectJob::Delegate* delegate) const {
427 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(group_name, 426 return scoped_ptr<ConnectJob>(new HttpProxyConnectJob(group_name,
428 request.priority(), 427 request.priority(),
429 request.params(), 428 request.params(),
430 ConnectionTimeout(), 429 ConnectionTimeout(),
431 transport_pool_, 430 transport_pool_,
432 ssl_pool_, 431 ssl_pool_,
433 host_resolver_,
434 delegate, 432 delegate,
435 net_log_)); 433 net_log_));
436 } 434 }
437 435
438 base::TimeDelta 436 base::TimeDelta
439 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout( 437 HttpProxyClientSocketPool::HttpProxyConnectJobFactory::ConnectionTimeout(
440 ) const { 438 ) const {
441 return timeout_; 439 return timeout_;
442 } 440 }
443 441
444 HttpProxyClientSocketPool::HttpProxyClientSocketPool( 442 HttpProxyClientSocketPool::HttpProxyClientSocketPool(
445 int max_sockets, 443 int max_sockets,
446 int max_sockets_per_group, 444 int max_sockets_per_group,
447 ClientSocketPoolHistograms* histograms, 445 ClientSocketPoolHistograms* histograms,
448 HostResolver* host_resolver, 446 HostResolver* host_resolver,
449 TransportClientSocketPool* transport_pool, 447 TransportClientSocketPool* transport_pool,
450 SSLClientSocketPool* ssl_pool, 448 SSLClientSocketPool* ssl_pool,
451 const ProxyDelegate* proxy_delegate,
452 NetLog* net_log) 449 NetLog* net_log)
453 : transport_pool_(transport_pool), 450 : transport_pool_(transport_pool),
454 ssl_pool_(ssl_pool), 451 ssl_pool_(ssl_pool),
455 base_(this, max_sockets, max_sockets_per_group, histograms, 452 base_(this, max_sockets, max_sockets_per_group, histograms,
456 ClientSocketPool::unused_idle_socket_timeout(), 453 ClientSocketPool::unused_idle_socket_timeout(),
457 ClientSocketPool::used_idle_socket_timeout(), 454 ClientSocketPool::used_idle_socket_timeout(),
458 new HttpProxyConnectJobFactory(transport_pool, 455 new HttpProxyConnectJobFactory(transport_pool,
459 ssl_pool, 456 ssl_pool,
460 host_resolver, 457 host_resolver,
461 proxy_delegate,
462 net_log)) { 458 net_log)) {
463 // We should always have a |transport_pool_| except in unit tests. 459 // We should always have a |transport_pool_| except in unit tests.
464 if (transport_pool_) 460 if (transport_pool_)
465 base_.AddLowerLayeredPool(transport_pool_); 461 base_.AddLowerLayeredPool(transport_pool_);
466 if (ssl_pool_) 462 if (ssl_pool_)
467 base_.AddLowerLayeredPool(ssl_pool_); 463 base_.AddLowerLayeredPool(ssl_pool_);
468 } 464 }
469 465
470 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() { 466 HttpProxyClientSocketPool::~HttpProxyClientSocketPool() {
471 } 467 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 base_.RemoveHigherLayeredPool(higher_pool); 566 base_.RemoveHigherLayeredPool(higher_pool);
571 } 567 }
572 568
573 bool HttpProxyClientSocketPool::CloseOneIdleConnection() { 569 bool HttpProxyClientSocketPool::CloseOneIdleConnection() {
574 if (base_.CloseOneIdleSocket()) 570 if (base_.CloseOneIdleSocket())
575 return true; 571 return true;
576 return base_.CloseOneIdleConnectionInHigherLayeredPool(); 572 return base_.CloseOneIdleConnectionInHigherLayeredPool();
577 } 573 }
578 574
579 } // namespace net 575 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_proxy_client_socket_pool.h ('k') | net/http/http_proxy_client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698