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

Unified Diff: net/socket/tcp_client_socket_win.cc

Issue 6394004: Log source ip and port in NetLog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix DCHECK. Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_client_socket_win.cc
diff --git a/net/socket/tcp_client_socket_win.cc b/net/socket/tcp_client_socket_win.cc
index b33c6de3d493796f81053a773e93e0587e32fced..d98485e8abb429be3c02e7226e25529da6444aa6 100644
--- a/net/socket/tcp_client_socket_win.cc
+++ b/net/socket/tcp_client_socket_win.cc
@@ -757,12 +757,37 @@ int TCPClientSocketWin::SetupSocket() {
}
void TCPClientSocketWin::LogConnectCompletion(int net_error) {
- scoped_refptr<NetLog::EventParameters> params;
- if (net_error != OK)
- params = new NetLogIntegerParameter("net_error", net_error);
- net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT, params);
if (net_error == OK)
UpdateConnectionTypeHistograms(CONNECTION_ANY);
+
+ if (net_error != OK) {
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT,
+ make_scoped_refptr(
+ new NetLogIntegerParameter("net_error", net_error)));
+ return;
+ }
+
+ struct sockaddr_storage source_address;
+ socklen_t addrlen = sizeof(source_address);
+ int rv = getsockname(
+ socket_, reinterpret_cast<struct sockaddr*>(&source_address), &addrlen);
+ if (rv != 0) {
+ LOG(ERROR) << "getsockname() [rv: " << rv
+ << "] error: " << WSAGetLastError();
+ NOTREACHED();
+ scoped_refptr<NetLog::EventParameters> params;
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT, NULL);
+ return;
+ }
+
+ const std::string source_address_str =
+ NetAddressToStringWithPort(
+ reinterpret_cast<const struct sockaddr*>(&source_address),
+ sizeof(source_address));
+ net_log_.EndEvent(NetLog::TYPE_TCP_CONNECT,
+ make_scoped_refptr(new NetLogStringParameter(
+ "source address",
+ source_address_str)));
}
void TCPClientSocketWin::DoReadCallback(int rv) {
« no previous file with comments | « net/socket/tcp_client_socket_libevent.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698