| 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 15 matching lines...) Expand all Loading... |
| 26 class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { | 26 class CONTENT_EXPORT P2PSocketHostUdp : public P2PSocketHost { |
| 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) OVERRIDE; | 36 const std::vector<char>& data, |
| 37 net::DiffServCodePoint dscp) OVERRIDE; |
| 37 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 38 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
| 38 const net::IPEndPoint& remote_address, int id) OVERRIDE; | 39 const net::IPEndPoint& remote_address, int id) OVERRIDE; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 friend class P2PSocketHostUdpTest; | 42 friend class P2PSocketHostUdpTest; |
| 42 | 43 |
| 43 typedef std::set<net::IPEndPoint> ConnectedPeerSet; | 44 typedef std::set<net::IPEndPoint> ConnectedPeerSet; |
| 44 | 45 |
| 45 struct PendingPacket { | 46 struct PendingPacket { |
| 46 PendingPacket(const net::IPEndPoint& to, | 47 PendingPacket(const net::IPEndPoint& to, |
| 47 const std::vector<char>& content, | 48 const std::vector<char>& content, |
| 48 uint64 id); | 49 uint64 id, |
| 50 net::DiffServCodePoint dscp); |
| 49 ~PendingPacket(); | 51 ~PendingPacket(); |
| 50 net::IPEndPoint to; | 52 net::IPEndPoint to; |
| 51 scoped_refptr<net::IOBuffer> data; | 53 scoped_refptr<net::IOBuffer> data; |
| 52 int size; | 54 int size; |
| 53 uint64 id; | 55 uint64 id; |
| 56 net::DiffServCodePoint dscp; |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 void OnError(); | 59 void OnError(); |
| 57 | 60 |
| 58 void DoRead(); | 61 void DoRead(); |
| 59 void OnRecv(int result); | 62 void OnRecv(int result); |
| 60 void HandleReadResult(int result); | 63 void HandleReadResult(int result); |
| 61 | 64 |
| 62 void DoSend(const PendingPacket& packet); | 65 void DoSend(const PendingPacket& packet); |
| 63 void OnSend(uint64 packet_id, int result); | 66 void OnSend(uint64 packet_id, int result); |
| 64 void HandleSendResult(uint64 packet_id, int result); | 67 void HandleSendResult(uint64 packet_id, int result); |
| 65 | 68 |
| 66 scoped_ptr<net::DatagramServerSocket> socket_; | 69 scoped_ptr<net::DatagramServerSocket> socket_; |
| 67 scoped_refptr<net::IOBuffer> recv_buffer_; | 70 scoped_refptr<net::IOBuffer> recv_buffer_; |
| 68 net::IPEndPoint recv_address_; | 71 net::IPEndPoint recv_address_; |
| 69 | 72 |
| 70 std::deque<PendingPacket> send_queue_; | 73 std::deque<PendingPacket> send_queue_; |
| 71 bool send_pending_; | 74 bool send_pending_; |
| 72 uint64 send_packet_count_; | 75 uint64 send_packet_count_; |
| 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 |