Chromium Code Reviews| Index: content/browser/renderer_host/p2p/socket_host_udp.h |
| diff --git a/content/browser/renderer_host/p2p/socket_host_udp.h b/content/browser/renderer_host/p2p/socket_host_udp.h |
| index 6db6faa0e929d5c22ab895c2f82765d287ac7528..4a5bd434b207c1a0d92330c14750f677cd4e3d7c 100644 |
| --- a/content/browser/renderer_host/p2p/socket_host_udp.h |
| +++ b/content/browser/renderer_host/p2p/socket_host_udp.h |
| @@ -43,6 +43,20 @@ class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { |
| int id) override; |
| bool SetOption(P2PSocketOption option, int value) override; |
| + // Helper functions to hijack upper 32 bits for latency calculation. |
| + // PackCallRecord will return a "CallRecord". A "CallRecord" has its lower 32 |
| + // bits as the lower 32 bits of packet id (without the random prefix) and its |
| + // higher 32 bits as the lower 32 bits of tick count when the packet arrives |
| + // at Send(). |
| + static uint64 PackCallRecord(const uint64 packet_id, const uint64 ticks_now); |
|
Alexei Svitkine (slow)
2014/11/04 15:17:50
Nit: Usually primitive params aren't marked const.
guoweis2
2014/11/07 22:18:19
Code removed.
|
| + // |ticks_diff| contains the difference between the time when |
| + // |packed_call_record| is packed and |ticks_now|. |
| + static void UnpackCallRecord(const uint64 packed_call_record, |
| + const uint64 random_socket_id_prefix, |
| + const uint64 ticks_now, |
| + uint64* packet_id, |
| + uint64* ticks_diff); |
| + |
| private: |
| friend class P2PSocketHostUdpTest; |
| @@ -63,6 +77,8 @@ class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { |
| void OnError(); |
| + void SetSendBufferSize(); |
| + |
| void DoRead(); |
| void OnRecv(int result); |
| void HandleReadResult(int result); |
| @@ -79,6 +95,18 @@ class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { |
| bool send_pending_; |
| net::DiffServCodePoint last_dscp_; |
| + // When the renderer sends the packet through IPC, an unique packet_id is |
| + // stamped at each packet to allow tracing infrastructure to uniquely identify |
| + // each packet. The packet id is always constructed as a random number at |
| + // upper 32 bits and a sequence number starting from 0 at lower 32 bits. The |
| + // packet id is also sent to socket::SendTo as a callback parameter in case |
| + // when the socket can't send it synchronously. The callback only allows an |
| + // int64 as a parameter. To allow us to track the latency across the |
| + // asynchronous socket::SendTo, we are hijacking the higher 32 bits for |
| + // latency calculation. The |random_socket_id_prefix| is kept here so we could |
| + // reconstruct the correct packet id. |
| + uint64 random_socket_id_prefix_; |
|
Alexei Svitkine (slow)
2014/11/04 15:17:50
Nit: I think for new code, uint64_t is preferred (
guoweis2
2014/11/07 22:18:19
Code removed.
|
| + |
| // Set of peer for which we have received STUN binding request or |
| // response or relay allocation request or response. |
| ConnectedPeerSet connected_peers_; |