diff options
-rw-r--r-- | net/socket/client_socket.cc | 8 | ||||
-rw-r--r-- | net/socket/client_socket.h | 4 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_libevent.cc | 9 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_libevent.h | 3 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_win.cc | 11 | ||||
-rw-r--r-- | net/socket/tcp_client_socket_win.h | 3 |
6 files changed, 35 insertions, 3 deletions
diff --git a/net/socket/client_socket.cc b/net/socket/client_socket.cc index 6f38eae..6b12841 100644 --- a/net/socket/client_socket.cc +++ b/net/socket/client_socket.cc @@ -58,6 +58,14 @@ ClientSocket::UseHistory::~UseHistory() { EmitPreconnectionHistograms(); } +void ClientSocket::UseHistory::Reset() { + EmitPreconnectionHistograms(); + was_ever_connected_ = false; + was_used_to_convey_data_ = false; + // omnibox_speculation_ and subresource_speculation_ values + // are intentionally preserved. +} + void ClientSocket::UseHistory::EmitPreconnectionHistograms() const { DCHECK(!subresource_speculation_ || !omnibox_speculation_); // 0 ==> non-speculative, never connected. diff --git a/net/socket/client_socket.h b/net/socket/client_socket.h index b4173c0..78b2f16 100644 --- a/net/socket/client_socket.h +++ b/net/socket/client_socket.h @@ -80,6 +80,10 @@ class ClientSocket : public Socket { UseHistory(); ~UseHistory(); + // Resets the state of UseHistory and emits histograms for the + // current state. + void Reset(); + void set_was_ever_connected(); void set_was_used_to_convey_data(); diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc index aedbf8a..cda0955 100644 --- a/net/socket/tcp_client_socket_libevent.cc +++ b/net/socket/tcp_client_socket_libevent.cc @@ -120,7 +120,8 @@ TCPClientSocketLibevent::TCPClientSocketLibevent( write_callback_(NULL), next_connect_state_(CONNECT_STATE_NONE), connect_os_error_(0), - net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { + net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)), + previously_disconnected_(false) { scoped_refptr<NetLog::EventParameters> params; if (source.is_valid()) params = new NetLogSourceParameter("source_dependency", source); @@ -194,6 +195,11 @@ int TCPClientSocketLibevent::DoConnect() { DCHECK_EQ(0, connect_os_error_); + if (previously_disconnected_) { + use_history_.Reset(); + previously_disconnected_ = false; + } + net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, new NetLogStringParameter( "address", NetAddressToStringWithPort(current_ai_))); @@ -278,6 +284,7 @@ void TCPClientSocketLibevent::DoDisconnect() { if (HANDLE_EINTR(close(socket_)) < 0) PLOG(ERROR) << "close"; socket_ = kInvalidSocket; + previously_disconnected_ = true; } bool TCPClientSocketLibevent::IsConnected() const { diff --git a/net/socket/tcp_client_socket_libevent.h b/net/socket/tcp_client_socket_libevent.h index 980e4cd..72f7d2d 100644 --- a/net/socket/tcp_client_socket_libevent.h +++ b/net/socket/tcp_client_socket_libevent.h @@ -165,6 +165,9 @@ class TCPClientSocketLibevent : public ClientSocket, NonThreadSafe { BoundNetLog net_log_; + // This socket was previously disconnected and has not been re-connected. + bool previously_disconnected_; + // Record of connectivity and transmissions, for use in speculative connection // histograms. UseHistory use_history_; diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc index 9143b81..f70d61b 100644 --- a/net/socket/tcp_client_socket_win.cc +++ b/net/socket/tcp_client_socket_win.cc @@ -290,8 +290,8 @@ TCPClientSocketWin::TCPClientSocketWin(const AddressList& addresses, write_callback_(NULL), next_connect_state_(CONNECT_STATE_NONE), connect_os_error_(0), - net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)) { - + net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SOCKET)), + previously_disconnected_(false) { scoped_refptr<NetLog::EventParameters> params; if (source.is_valid()) params = new NetLogSourceParameter("source_dependency", source); @@ -364,6 +364,11 @@ int TCPClientSocketWin::DoConnect() { DCHECK(ai); DCHECK_EQ(0, connect_os_error_); + if (previously_disconnected_) { + use_history_.Reset(); + previously_disconnected_ = false; + } + net_log_.BeginEvent(NetLog::TYPE_TCP_CONNECT_ATTEMPT, new NetLogStringParameter( "address", NetAddressToStringWithPort(current_ai_))); @@ -478,6 +483,8 @@ void TCPClientSocketWin::DoDisconnect() { core_->Detach(); core_ = NULL; + + previously_disconnected_ = true; } bool TCPClientSocketWin::IsConnected() const { diff --git a/net/socket/tcp_client_socket_win.h b/net/socket/tcp_client_socket_win.h index be25157..5d560d6 100644 --- a/net/socket/tcp_client_socket_win.h +++ b/net/socket/tcp_client_socket_win.h @@ -117,6 +117,9 @@ class TCPClientSocketWin : public ClientSocket, NonThreadSafe { BoundNetLog net_log_; + // This socket was previously disconnected and has not been re-connected. + bool previously_disconnected_; + // Record of connectivity and transmissions, for use in speculative connection // histograms. UseHistory use_history_; |