Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_wrapper.h" | 5 #include "net/http/http_proxy_client_socket_wrapper.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/metrics/histogram_macros.h" | |
| 13 #include "base/profiler/scoped_tracker.h" | 14 #include "base/profiler/scoped_tracker.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "net/base/proxy_delegate.h" | 16 #include "net/base/proxy_delegate.h" |
| 16 #include "net/http/http_proxy_client_socket.h" | 17 #include "net/http/http_proxy_client_socket.h" |
| 17 #include "net/http/http_response_info.h" | 18 #include "net/http/http_response_info.h" |
| 18 #include "net/log/net_log_event_type.h" | 19 #include "net/log/net_log_event_type.h" |
| 19 #include "net/log/net_log_source.h" | 20 #include "net/log/net_log_source.h" |
| 20 #include "net/log/net_log_source_type.h" | 21 #include "net/log/net_log_source_type.h" |
| 21 #include "net/socket/client_socket_handle.h" | 22 #include "net/socket/client_socket_handle.h" |
| 22 #include "net/spdy/spdy_proxy_client_socket.h" | 23 #include "net/spdy/spdy_proxy_client_socket.h" |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 NOTREACHED() << "bad state"; | 381 NOTREACHED() << "bad state"; |
| 381 rv = ERR_FAILED; | 382 rv = ERR_FAILED; |
| 382 break; | 383 break; |
| 383 } | 384 } |
| 384 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); | 385 } while (rv != ERR_IO_PENDING && next_state_ != STATE_NONE); |
| 385 | 386 |
| 386 return rv; | 387 return rv; |
| 387 } | 388 } |
| 388 | 389 |
| 389 int HttpProxyClientSocketWrapper::DoBeginConnect() { | 390 int HttpProxyClientSocketWrapper::DoBeginConnect() { |
| 391 connect_start_time_ = base::TimeTicks::Now(); | |
| 390 SetConnectTimer(connect_timeout_duration_); | 392 SetConnectTimer(connect_timeout_duration_); |
| 391 if (transport_params_) { | 393 if (transport_params_) { |
| 392 next_state_ = STATE_TCP_CONNECT; | 394 next_state_ = STATE_TCP_CONNECT; |
| 393 } else { | 395 } else { |
| 394 next_state_ = STATE_SSL_CONNECT; | 396 next_state_ = STATE_SSL_CONNECT; |
| 395 } | 397 } |
| 396 | 398 |
| 397 return OK; | 399 return OK; |
| 398 } | 400 } |
| 399 | 401 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; | 496 next_state_ = STATE_SPDY_PROXY_CREATE_STREAM; |
| 495 } else { | 497 } else { |
| 496 next_state_ = STATE_HTTP_PROXY_CONNECT; | 498 next_state_ = STATE_HTTP_PROXY_CONNECT; |
| 497 } | 499 } |
| 498 return result; | 500 return result; |
| 499 } | 501 } |
| 500 | 502 |
| 501 int HttpProxyClientSocketWrapper::DoHttpProxyConnect() { | 503 int HttpProxyClientSocketWrapper::DoHttpProxyConnect() { |
| 502 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; | 504 next_state_ = STATE_HTTP_PROXY_CONNECT_COMPLETE; |
| 503 | 505 |
| 506 if (transport_params_) { | |
| 507 UMA_HISTOGRAM_MEDIUM_TIMES("Net.Proxy.ConnectLatency.Insecure.Success", | |
| 508 base::TimeTicks::Now() - connect_start_time_); | |
| 509 } else { | |
| 510 UMA_HISTOGRAM_MEDIUM_TIMES("Net.Proxy.ConnectLatency.Secure.Success", | |
| 511 base::TimeTicks::Now() - connect_start_time_); | |
|
mmenke
2017/03/27 16:36:33
These names should make it clear that they're only
tbansal1
2017/03/27 18:29:30
Done.
| |
| 512 } | |
| 513 | |
| 504 // Add a HttpProxy connection on top of the tcp socket. | 514 // Add a HttpProxy connection on top of the tcp socket. |
| 505 transport_socket_.reset(new HttpProxyClientSocket( | 515 transport_socket_.reset(new HttpProxyClientSocket( |
| 506 transport_socket_handle_.release(), user_agent_, endpoint_, | 516 transport_socket_handle_.release(), user_agent_, endpoint_, |
| 507 GetDestination().host_port_pair(), http_auth_controller_.get(), tunnel_, | 517 GetDestination().host_port_pair(), http_auth_controller_.get(), tunnel_, |
| 508 using_spdy_, negotiated_protocol_, proxy_delegate_, | 518 using_spdy_, negotiated_protocol_, proxy_delegate_, |
| 509 ssl_params_.get() != nullptr)); | 519 ssl_params_.get() != nullptr)); |
| 510 return transport_socket_->Connect(base::Bind( | 520 return transport_socket_->Connect(base::Bind( |
| 511 &HttpProxyClientSocketWrapper::OnIOComplete, base::Unretained(this))); | 521 &HttpProxyClientSocketWrapper::OnIOComplete, base::Unretained(this))); |
| 512 } | 522 } |
| 513 | 523 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 connect_timer_.Stop(); | 621 connect_timer_.Stop(); |
| 612 connect_timer_.Start(FROM_HERE, delay, this, | 622 connect_timer_.Start(FROM_HERE, delay, this, |
| 613 &HttpProxyClientSocketWrapper::ConnectTimeout); | 623 &HttpProxyClientSocketWrapper::ConnectTimeout); |
| 614 } | 624 } |
| 615 | 625 |
| 616 void HttpProxyClientSocketWrapper::ConnectTimeout() { | 626 void HttpProxyClientSocketWrapper::ConnectTimeout() { |
| 617 // Timer shouldn't be running if next_state_ is STATE_NONE. | 627 // Timer shouldn't be running if next_state_ is STATE_NONE. |
| 618 DCHECK_NE(STATE_NONE, next_state_); | 628 DCHECK_NE(STATE_NONE, next_state_); |
| 619 DCHECK(!connect_callback_.is_null()); | 629 DCHECK(!connect_callback_.is_null()); |
| 620 | 630 |
| 631 if (next_state_ == STATE_TCP_CONNECT_COMPLETE || | |
| 632 next_state_ == STATE_SSL_CONNECT_COMPLETE) { | |
|
mmenke
2017/03/27 16:39:11
One other question: What about other errors? Loo
tbansal1
2017/03/27 18:29:30
Yes, this histogram records time until only the ti
| |
| 633 if (transport_params_) { | |
| 634 UMA_HISTOGRAM_MEDIUM_TIMES("Net.Proxy.ConnectLatency.Insecure.TimedOut", | |
| 635 base::TimeTicks::Now() - connect_start_time_); | |
| 636 } else { | |
| 637 UMA_HISTOGRAM_MEDIUM_TIMES("Net.Proxy.ConnectLatency.Secure.TimedOut", | |
| 638 base::TimeTicks::Now() - connect_start_time_); | |
| 639 } | |
| 640 } | |
| 641 | |
| 621 NotifyProxyDelegateOfCompletion(ERR_CONNECTION_TIMED_OUT); | 642 NotifyProxyDelegateOfCompletion(ERR_CONNECTION_TIMED_OUT); |
| 622 | 643 |
| 623 CompletionCallback callback = connect_callback_; | 644 CompletionCallback callback = connect_callback_; |
| 624 Disconnect(); | 645 Disconnect(); |
| 625 callback.Run(ERR_CONNECTION_TIMED_OUT); | 646 callback.Run(ERR_CONNECTION_TIMED_OUT); |
| 626 } | 647 } |
| 627 | 648 |
| 628 const HostResolver::RequestInfo& | 649 const HostResolver::RequestInfo& |
| 629 HttpProxyClientSocketWrapper::GetDestination() { | 650 HttpProxyClientSocketWrapper::GetDestination() { |
| 630 if (transport_params_) { | 651 if (transport_params_) { |
| 631 return transport_params_->destination(); | 652 return transport_params_->destination(); |
| 632 } else { | 653 } else { |
| 633 return ssl_params_->GetDirectConnectionParams()->destination(); | 654 return ssl_params_->GetDirectConnectionParams()->destination(); |
| 634 } | 655 } |
| 635 } | 656 } |
| 636 | 657 |
| 637 } // namespace net | 658 } // namespace net |
| OLD | NEW |