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

Unified Diff: net/socket/tcp_client_socket_libevent.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/base/net_util.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/tcp_client_socket_libevent.cc
diff --git a/net/socket/tcp_client_socket_libevent.cc b/net/socket/tcp_client_socket_libevent.cc
index 52956aa6f15866f1758d34a7dbcfb1676a34dcfb..83528dd70412307c685e76963c35084e08a7f301 100644
--- a/net/socket/tcp_client_socket_libevent.cc
+++ b/net/socket/tcp_client_socket_libevent.cc
@@ -19,6 +19,7 @@
#include "base/metrics/stats_counters.h"
#include "base/string_util.h"
#include "net/base/address_list_net_log_param.h"
+#include "net/base/connection_type_histograms.h"
#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/net_log.h"
@@ -522,10 +523,36 @@ int TCPClientSocketLibevent::SetupSocket() {
}
void TCPClientSocketLibevent::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) {
+ PLOG(ERROR) << "getsockname() [rv: " << rv << "] error: ";
+ 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 TCPClientSocketLibevent::DoReadCallback(int rv) {
« no previous file with comments | « net/base/net_util.cc ('k') | net/socket/tcp_client_socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698