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

Unified Diff: net/base/tcp_client_socket_libevent.cc

Issue 16467: Add TRACE_EVENT calls to tcp_client_socket_linux. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/tcp_client_socket_libevent.cc
===================================================================
--- net/base/tcp_client_socket_libevent.cc (revision 7488)
+++ net/base/tcp_client_socket_libevent.cc (working copy)
@@ -10,6 +10,8 @@
#include <sys/socket.h>
#include "base/message_loop.h"
+#include "base/string_util.h"
+#include "base/trace_event.h"
#include "net/base/net_errors.h"
#include "third_party/libevent/event.h"
@@ -83,6 +85,7 @@
DCHECK(!waiting_connect_);
+ TRACE_EVENT_BEGIN("socket.connect", this, "");
const addrinfo* ai = current_ai_;
DCHECK(ai);
@@ -91,6 +94,7 @@
return rv;
if (!connect(socket_, ai->ai_addr, static_cast<int>(ai->ai_addrlen))) {
+ TRACE_EVENT_END("socket.connect", this, "");
// Connected without waiting!
return OK;
}
@@ -131,6 +135,8 @@
if (socket_ == kInvalidSocket)
return;
+ TRACE_EVENT_INSTANT("socket.disconnect", this, "");
+
socket_watcher_.StopWatchingFileDescriptor();
close(socket_);
socket_ = kInvalidSocket;
@@ -165,8 +171,10 @@
DCHECK(callback);
DCHECK(buf_len > 0);
+ TRACE_EVENT_BEGIN("socket.read", this, "");
int nread = read(socket_, buf, buf_len);
if (nread >= 0) {
+ TRACE_EVENT_END("socket.read", this, StringPrintf("%d bytes", nread));
return nread;
}
if (errno != EAGAIN && errno != EWOULDBLOCK) {
@@ -197,8 +205,10 @@
DCHECK(callback);
DCHECK(buf_len > 0);
+ TRACE_EVENT_BEGIN("socket.write", this, "");
int nwrite = write(socket_, buf, buf_len);
if (nwrite >= 0) {
+ TRACE_EVENT_END("socket.write", this, StringPrintf("%d bytes", nwrite));
return nwrite;
}
if (errno != EAGAIN && errno != EWOULDBLOCK)
@@ -223,7 +233,6 @@
if (socket_ == kInvalidSocket)
return MapPosixError(errno);
- // All our socket I/O is nonblocking
if (SetNonBlocking(socket_))
return MapPosixError(errno);
@@ -253,6 +262,8 @@
void TCPClientSocket::DidCompleteConnect() {
int result = ERR_UNEXPECTED;
+ TRACE_EVENT_END("socket.connect", this, "");
+
// Check to see if connect succeeded
int error_code = 0;
socklen_t len = sizeof(error_code);
@@ -291,6 +302,8 @@
int result;
if (bytes_transferred >= 0) {
+ TRACE_EVENT_END("socket.read", this,
+ StringPrintf("%d bytes", bytes_transferred));
result = bytes_transferred;
} else {
result = MapPosixError(errno);
@@ -311,6 +324,8 @@
int result;
if (bytes_transferred >= 0) {
result = bytes_transferred;
+ TRACE_EVENT_END("socket.write", this,
+ StringPrintf("%d bytes", bytes_transferred));
} else {
result = MapPosixError(errno);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698