diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 08:57:41 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 08:57:41 +0000 |
commit | 6308d0f4328ac4108e9fae8e481e6796829e76e5 (patch) | |
tree | 7c9cbfa7da9e8375d04ce2f58630c7e1cf9abfed /content/renderer/p2p | |
parent | ee4379ebef30d92167b756092d9535351be3f036 (diff) | |
download | chromium_src-6308d0f4328ac4108e9fae8e481e6796829e76e5.zip chromium_src-6308d0f4328ac4108e9fae8e481e6796829e76e5.tar.gz chromium_src-6308d0f4328ac4108e9fae8e481e6796829e76e5.tar.bz2 |
Trace events for P2P Socket
Trace time spent on IPCs and system socket for sending a packet through
P2P Socket.
Review URL: https://codereview.chromium.org/25648007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229083 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer/p2p')
-rw-r--r-- | content/renderer/p2p/socket_client.cc | 22 | ||||
-rw-r--r-- | content/renderer/p2p/socket_client.h | 4 |
2 files changed, 24 insertions, 2 deletions
diff --git a/content/renderer/p2p/socket_client.cc b/content/renderer/p2p/socket_client.cc index 68797db..57e0339 100644 --- a/content/renderer/p2p/socket_client.cc +++ b/content/renderer/p2p/socket_client.cc @@ -8,6 +8,18 @@ #include "base/message_loop/message_loop_proxy.h" #include "content/common/p2p_messages.h" #include "content/renderer/p2p/socket_dispatcher.h" +#include "crypto/random.h" + +namespace { + +uint64 GetUniqueId(uint32 random_socket_id, uint32 packet_id) { + uint64 uid = random_socket_id; + uid <<= 32; + uid |= packet_id; + return uid; +} + +} // namespace namespace content { @@ -16,7 +28,10 @@ P2PSocketClient::P2PSocketClient(P2PSocketDispatcher* dispatcher) ipc_message_loop_(dispatcher->message_loop()), delegate_message_loop_(base::MessageLoopProxy::current()), socket_id_(0), delegate_(NULL), - state_(STATE_UNINITIALIZED) { + state_(STATE_UNINITIALIZED), + random_socket_id_(0), + next_packet_id_(0) { + crypto::RandBytes(&random_socket_id_, sizeof(random_socket_id_)); } P2PSocketClient::~P2PSocketClient() { @@ -59,7 +74,10 @@ void P2PSocketClient::Send(const net::IPEndPoint& address, // Can send data only when the socket is open. DCHECK(state_ == STATE_OPEN || state_ == STATE_ERROR); if (state_ == STATE_OPEN) { - dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data)); + uint64 unique_id = GetUniqueId(random_socket_id_, ++next_packet_id_); + TRACE_EVENT_ASYNC_BEGIN0("p2p", "Send", unique_id); + dispatcher_->SendP2PMessage(new P2PHostMsg_Send(socket_id_, address, data, + unique_id)); } } diff --git a/content/renderer/p2p/socket_client.h b/content/renderer/p2p/socket_client.h index fd8537e..fbdca27 100644 --- a/content/renderer/p2p/socket_client.h +++ b/content/renderer/p2p/socket_client.h @@ -116,6 +116,10 @@ class P2PSocketClient : public base::RefCountedThreadSafe<P2PSocketClient> { Delegate* delegate_; State state_; + // These two fields are used to identify packets for tracing. + uint32 random_socket_id_; + uint32 next_packet_id_; + DISALLOW_COPY_AND_ASSIGN(P2PSocketClient); }; |