| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 public: | 27 public: |
| 28 P2PSocketHostUdp(IPC::Sender* message_sender, int id, | 28 P2PSocketHostUdp(IPC::Sender* message_sender, int id, |
| 29 P2PMessageThrottler* throttler); | 29 P2PMessageThrottler* throttler); |
| 30 virtual ~P2PSocketHostUdp(); | 30 virtual ~P2PSocketHostUdp(); |
| 31 | 31 |
| 32 // P2PSocketHost overrides. | 32 // P2PSocketHost overrides. |
| 33 virtual bool Init(const net::IPEndPoint& local_address, | 33 virtual bool Init(const net::IPEndPoint& local_address, |
| 34 const net::IPEndPoint& remote_address) OVERRIDE; | 34 const net::IPEndPoint& remote_address) OVERRIDE; |
| 35 virtual void Send(const net::IPEndPoint& to, | 35 virtual void Send(const net::IPEndPoint& to, |
| 36 const std::vector<char>& data, | 36 const std::vector<char>& data, |
| 37 net::DiffServCodePoint dscp, |
| 37 uint64 packet_id) OVERRIDE; | 38 uint64 packet_id) OVERRIDE; |
| 38 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 39 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 39 const net::IPEndPoint& remote_address, int id) OVERRIDE; | 40 const net::IPEndPoint& remote_address, int id) OVERRIDE; |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 friend class P2PSocketHostUdpTest; | 43 friend class P2PSocketHostUdpTest; |
| 43 | 44 |
| 44 typedef std::set<net::IPEndPoint> ConnectedPeerSet; | 45 typedef std::set<net::IPEndPoint> ConnectedPeerSet; |
| 45 | 46 |
| 46 struct PendingPacket { | 47 struct PendingPacket { |
| 47 PendingPacket(const net::IPEndPoint& to, | 48 PendingPacket(const net::IPEndPoint& to, |
| 48 const std::vector<char>& content, | 49 const std::vector<char>& content, |
| 50 net::DiffServCodePoint dscp, |
| 49 uint64 id); | 51 uint64 id); |
| 50 ~PendingPacket(); | 52 ~PendingPacket(); |
| 51 net::IPEndPoint to; | 53 net::IPEndPoint to; |
| 52 scoped_refptr<net::IOBuffer> data; | 54 scoped_refptr<net::IOBuffer> data; |
| 53 int size; | 55 int size; |
| 56 net::DiffServCodePoint dscp; |
| 54 uint64 id; | 57 uint64 id; |
| 55 }; | 58 }; |
| 56 | 59 |
| 57 void OnError(); | 60 void OnError(); |
| 58 | 61 |
| 59 void DoRead(); | 62 void DoRead(); |
| 60 void OnRecv(int result); | 63 void OnRecv(int result); |
| 61 void HandleReadResult(int result); | 64 void HandleReadResult(int result); |
| 62 | 65 |
| 63 void DoSend(const PendingPacket& packet); | 66 void DoSend(const PendingPacket& packet); |
| 64 void OnSend(uint64 packet_id, int result); | 67 void OnSend(uint64 packet_id, int result); |
| 65 void HandleSendResult(uint64 packet_id, int result); | 68 void HandleSendResult(uint64 packet_id, int result); |
| 66 | 69 |
| 67 scoped_ptr<net::DatagramServerSocket> socket_; | 70 scoped_ptr<net::DatagramServerSocket> socket_; |
| 68 scoped_refptr<net::IOBuffer> recv_buffer_; | 71 scoped_refptr<net::IOBuffer> recv_buffer_; |
| 69 net::IPEndPoint recv_address_; | 72 net::IPEndPoint recv_address_; |
| 70 | 73 |
| 71 std::deque<PendingPacket> send_queue_; | 74 std::deque<PendingPacket> send_queue_; |
| 72 bool send_pending_; | 75 bool send_pending_; |
| 76 net::DiffServCodePoint last_dscp_; |
| 73 | 77 |
| 74 // Set of peer for which we have received STUN binding request or | 78 // Set of peer for which we have received STUN binding request or |
| 75 // response or relay allocation request or response. | 79 // response or relay allocation request or response. |
| 76 ConnectedPeerSet connected_peers_; | 80 ConnectedPeerSet connected_peers_; |
| 77 P2PMessageThrottler* throttler_; | 81 P2PMessageThrottler* throttler_; |
| 78 | 82 |
| 79 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp); | 83 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp); |
| 80 }; | 84 }; |
| 81 | 85 |
| 82 } // namespace content | 86 } // namespace content |
| 83 | 87 |
| 84 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ | 88 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ |
| OLD | NEW |