diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-02 16:42:15 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-02 16:42:15 +0000 |
commit | d49a6264617043a450e776984a76468b542ba411 (patch) | |
tree | 739da24590680b5c6e6e789db4d1b44e4ac8115a /net | |
parent | bcfad371249f11b922d3b7695286626331551b12 (diff) | |
download | chromium_src-d49a6264617043a450e776984a76468b542ba411.zip chromium_src-d49a6264617043a450e776984a76468b542ba411.tar.gz chromium_src-d49a6264617043a450e776984a76468b542ba411.tar.bz2 |
Initial pass at simple event tracing. I added a few traces to tcp_socket and test_shell to get an idea of what a simple trace might look like.
Here's a sample output line:
11:24:19.660604 0x1e278:0x1e24c BEGIN url.load [0x5 http://mail.google.com/mail/] <E:\src\cr\src\webkit\tools\test_shell\test_webview_delegate.cc:189>
format is:hh:mm:ss.us pid:tid TYPE NAME [id, extra] <file:line>
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1641 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/tcp_client_socket.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/net/base/tcp_client_socket.cc b/net/base/tcp_client_socket.cc index 9b6959e..fc65995 100644 --- a/net/base/tcp_client_socket.cc +++ b/net/base/tcp_client_socket.cc @@ -4,6 +4,8 @@ #include "net/base/tcp_client_socket.h" +#include "base/string_util.h" +#include "base/trace_event.h" #include "net/base/net_errors.h" #include "net/base/winsock_init.h" @@ -67,6 +69,7 @@ int TCPClientSocket::Connect(CompletionCallback* callback) { if (socket_ != INVALID_SOCKET) return OK; + TRACE_EVENT_BEGIN("socket.connect", this, ""); const struct addrinfo* ai = current_ai_; DCHECK(ai); @@ -80,6 +83,7 @@ int TCPClientSocket::Connect(CompletionCallback* callback) { WSAEventSelect(socket_, overlapped_.hEvent, FD_CONNECT); if (!connect(socket_, ai->ai_addr, static_cast<int>(ai->ai_addrlen))) { + TRACE_EVENT_END("socket.connect", this, ""); // Connected without waiting! return OK; } @@ -105,6 +109,8 @@ void TCPClientSocket::Disconnect() { if (socket_ == INVALID_SOCKET) return; + TRACE_EVENT_INSTANT("socket.disconnect", this, ""); + // Make sure the message loop is not watching this object anymore. watcher_.StopWatching(); @@ -224,6 +230,7 @@ void TCPClientSocket::DoCallback(int rv) { void TCPClientSocket::DidCompleteConnect() { int result; + TRACE_EVENT_END("socket.connect", this, ""); wait_state_ = NOT_WAITING; WSANETWORKEVENTS events; @@ -263,6 +270,13 @@ void TCPClientSocket::DidCompleteIO() { BOOL ok = WSAGetOverlappedResult( socket_, &overlapped_, &num_bytes, FALSE, &flags); WSAResetEvent(overlapped_.hEvent); + if (wait_state_ == WAITING_READ) { + TRACE_EVENT_INSTANT("socket.read", this, + StringPrintf("%d bytes", num_bytes)); + } else { + TRACE_EVENT_INSTANT("socket.write", this, + StringPrintf("%d bytes", num_bytes)); + } wait_state_ = NOT_WAITING; DoCallback(ok ? num_bytes : MapWinsockError(WSAGetLastError())); } |