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

Unified Diff: net/socket/transport_client_socket_pool.cc

Issue 1096203006: Collect all ConnectionAttempts from both sockets in TransportConnectJob. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@domrel_serverip1
Patch Set: rebase Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: net/socket/transport_client_socket_pool.cc
diff --git a/net/socket/transport_client_socket_pool.cc b/net/socket/transport_client_socket_pool.cc
index b728cb9ca03e47fec481f8c1942e7f58333c995d..94887ebe44e792fc555275f69fd65327c9a331af 100644
--- a/net/socket/transport_client_socket_pool.cc
+++ b/net/socket/transport_client_socket_pool.cc
@@ -237,15 +237,15 @@ void TransportConnectJob::GetAdditionalErrorState(ClientSocketHandle* handle) {
// If hostname resolution failed, record an empty endpoint and the result.
// If the actual socket Connect call failed, record the result and the last
// address attempted.
- // TODO(ttuttle): Plumb into the socket layer and record *all* attempts.
ConnectionAttempts attempts;
if (resolve_result_ != OK) {
DCHECK_EQ(0u, helper_.addresses().size());
attempts.push_back(ConnectionAttempt(IPEndPoint(), resolve_result_));
} else if (connect_result_ != OK) {
- DCHECK_LT(0u, helper_.addresses().size());
- attempts.push_back(
- ConnectionAttempt(helper_.addresses().back(), connect_result_));
+ attempts.insert(attempts.begin(), connection_attempts_.begin(),
+ connection_attempts_.end());
+ attempts.insert(attempts.begin(), fallback_connection_attempts_.begin(),
+ fallback_connection_attempts_.end());
}
handle->set_connection_attempts(attempts);
}
@@ -330,6 +330,14 @@ int TransportConnectJob::DoTransportConnect() {
int TransportConnectJob::DoTransportConnectComplete(int result) {
if (result == OK) {
+ // Success will be returned via the main socket, so also include connection
+ // attempts made on the fallback socket.
Randy Smith (Not in Mondays) 2015/05/12 20:11:09 Acknowledgement of ugly hack in comment? :-} :-J.
Deprecated (see juliatuttle) 2015/05/13 18:22:28 Done.
+ if (fallback_transport_socket_) {
+ ConnectionAttempts fallback_attempts;
+ fallback_transport_socket_->GetConnectionAttempts(&fallback_attempts);
+ transport_socket_->AddConnectionAttempts(fallback_attempts);
+ }
+
bool is_ipv4 =
helper_.addresses().front().GetFamily() == ADDRESS_FAMILY_IPV4;
TransportConnectJobHelper::ConnectionLatencyHistogram race_result =
@@ -378,6 +386,10 @@ int TransportConnectJob::DoTransportConnectComplete(int result) {
SetSocket(transport_socket_.Pass());
fallback_timer_.Stop();
} else {
+ // Failure will be returned via |GetAdditionalErrorState|, so save
+ // connection attempts from both sockets for use there.
+ CopyConnectionAttemptsFromClientSocketHandles();
+
// Be a bit paranoid and kill off the fallback members to prevent reuse.
fallback_transport_socket_.reset();
fallback_addresses_.reset();
@@ -428,6 +440,15 @@ void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) {
if (result == OK) {
DCHECK(!fallback_connect_start_time_.is_null());
+
+ // Success will be returned via the fallback socket, so also include
+ // connection attempts made on the main socket.
+ if (transport_socket_) {
+ ConnectionAttempts attempts;
+ transport_socket_->GetConnectionAttempts(&attempts);
+ fallback_transport_socket_->AddConnectionAttempts(attempts);
+ }
+
connect_timing_.connect_start = fallback_connect_start_time_;
helper_.HistogramDuration(
TransportConnectJobHelper::CONNECTION_LATENCY_IPV4_WINS_RACE);
@@ -435,6 +456,10 @@ void TransportConnectJob::DoIPv6FallbackTransportConnectComplete(int result) {
helper_.set_next_state(TransportConnectJobHelper::STATE_NONE);
transport_socket_.reset();
} else {
+ // Failure will be returned via |GetAdditionalErrorState|, so save
+ // connection attempts from both sockets for use there.
+ CopyConnectionAttemptsFromClientSocketHandles();
+
// Be a bit paranoid and kill off the fallback members to prevent reuse.
fallback_transport_socket_.reset();
fallback_addresses_.reset();
@@ -446,6 +471,15 @@ int TransportConnectJob::ConnectInternal() {
return helper_.DoConnectInternal(this);
}
+void TransportConnectJob::CopyConnectionAttemptsFromClientSocketHandles() {
+ if (transport_socket_)
+ transport_socket_->GetConnectionAttempts(&connection_attempts_);
+ if (fallback_transport_socket_) {
+ fallback_transport_socket_->GetConnectionAttempts(
+ &fallback_connection_attempts_);
+ }
+}
+
scoped_ptr<ConnectJob>
TransportClientSocketPool::TransportConnectJobFactory::NewConnectJob(
const std::string& group_name,
« net/socket/transport_client_socket_pool.h ('K') | « net/socket/transport_client_socket_pool.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698