| 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 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { | 24 class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { |
| 25 public: | 25 public: |
| 26 P2PSocketHostUdp(IPC::Sender* message_sender, int id); | 26 P2PSocketHostUdp(IPC::Sender* message_sender, int id); |
| 27 virtual ~P2PSocketHostUdp(); | 27 virtual ~P2PSocketHostUdp(); |
| 28 | 28 |
| 29 // P2PSocketHost overrides. | 29 // P2PSocketHost overrides. |
| 30 virtual bool Init(const net::IPEndPoint& local_address, | 30 virtual bool Init(const net::IPEndPoint& local_address, |
| 31 const net::IPEndPoint& remote_address) OVERRIDE; | 31 const net::IPEndPoint& remote_address) OVERRIDE; |
| 32 virtual void Send(const net::IPEndPoint& to, | 32 virtual void Send(const net::IPEndPoint& to, |
| 33 const std::vector<char>& data) OVERRIDE; | 33 const std::vector<char>& data, |
| 34 net::DiffServCodePoint dscp) OVERRIDE; |
| 34 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 35 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 35 const net::IPEndPoint& remote_address, int id) OVERRIDE; | 36 const net::IPEndPoint& remote_address, int id) OVERRIDE; |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 friend class P2PSocketHostUdpTest; | 39 friend class P2PSocketHostUdpTest; |
| 39 | 40 |
| 40 typedef std::set<net::IPEndPoint> ConnectedPeerSet; | 41 typedef std::set<net::IPEndPoint> ConnectedPeerSet; |
| 41 | 42 |
| 42 struct PendingPacket { | 43 struct PendingPacket { |
| 43 PendingPacket(const net::IPEndPoint& to, | 44 PendingPacket(const net::IPEndPoint& to, |
| 44 const std::vector<char>& content, | 45 const std::vector<char>& content, |
| 45 uint64 id); | 46 uint64 id, |
| 47 net::DiffServCodePoint dscp); |
| 46 ~PendingPacket(); | 48 ~PendingPacket(); |
| 47 net::IPEndPoint to; | 49 net::IPEndPoint to; |
| 48 scoped_refptr<net::IOBuffer> data; | 50 scoped_refptr<net::IOBuffer> data; |
| 49 int size; | 51 int size; |
| 50 uint64 id; | 52 uint64 id; |
| 53 net::DiffServCodePoint dscp; |
| 51 }; | 54 }; |
| 52 | 55 |
| 53 void OnError(); | 56 void OnError(); |
| 54 | 57 |
| 55 void DoRead(); | 58 void DoRead(); |
| 56 void OnRecv(int result); | 59 void OnRecv(int result); |
| 57 void HandleReadResult(int result); | 60 void HandleReadResult(int result); |
| 58 | 61 |
| 59 void DoSend(const PendingPacket& packet); | 62 void DoSend(const PendingPacket& packet); |
| 60 void OnSend(uint64 packet_id, int result); | 63 void OnSend(uint64 packet_id, int result); |
| 61 void HandleSendResult(uint64 packet_id, int result); | 64 void HandleSendResult(uint64 packet_id, int result); |
| 62 | 65 |
| 63 scoped_ptr<net::DatagramServerSocket> socket_; | 66 scoped_ptr<net::DatagramServerSocket> socket_; |
| 64 scoped_refptr<net::IOBuffer> recv_buffer_; | 67 scoped_refptr<net::IOBuffer> recv_buffer_; |
| 65 net::IPEndPoint recv_address_; | 68 net::IPEndPoint recv_address_; |
| 66 | 69 |
| 67 std::deque<PendingPacket> send_queue_; | 70 std::deque<PendingPacket> send_queue_; |
| 68 bool send_pending_; | 71 bool send_pending_; |
| 69 uint64 send_packet_count_; | 72 uint64 send_packet_count_; |
| 73 net::DiffServCodePoint last_dscp_; |
| 70 | 74 |
| 71 // Set of peer for which we have received STUN binding request or | 75 // Set of peer for which we have received STUN binding request or |
| 72 // response or relay allocation request or response. | 76 // response or relay allocation request or response. |
| 73 ConnectedPeerSet connected_peers_; | 77 ConnectedPeerSet connected_peers_; |
| 74 | 78 |
| 75 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp); | 79 DISALLOW_COPY_AND_ASSIGN(P2PSocketHostUdp); |
| 76 }; | 80 }; |
| 77 | 81 |
| 78 } // namespace content | 82 } // namespace content |
| 79 | 83 |
| 80 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ | 84 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_UDP_H_ |
| OLD | NEW |