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_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
7 | 7 |
8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
9 #include "content/common/p2p_socket_type.h" | 9 #include "content/common/p2p_socket_type.h" |
10 #include "net/base/ip_endpoint.h" | 10 #include "net/base/ip_endpoint.h" |
11 #include "net/udp/datagram_socket.h" | 11 #include "net/udp/datagram_socket.h" |
12 | 12 |
13 namespace IPC { | 13 namespace IPC { |
14 class Sender; | 14 class Sender; |
15 } | 15 } |
16 | 16 |
17 namespace net { | 17 namespace net { |
18 class URLRequestContextGetter; | 18 class URLRequestContextGetter; |
19 } | 19 } |
20 | 20 |
21 namespace talk_base { | |
22 struct PacketOptions; | |
23 } | |
24 | |
21 namespace content { | 25 namespace content { |
22 class P2PMessageThrottler; | 26 class P2PMessageThrottler; |
23 | 27 |
28 namespace packet_processing_helpers { | |
29 void MaybeUpdatePacketAbsSendTimeExtn(char* data, int length, | |
Solis
2014/03/03 10:22:29
Why aren't there any tests for this function?
Mallinath (Gone from Chromium)
2014/03/04 00:15:46
I am not sure how can I test this method in partic
Solis
2014/03/04 09:53:24
1. There's logic in the function which isn't that
Mallinath (Gone from Chromium)
2014/03/06 07:39:43
I added test cases for MaybeUpdatePacketAbsSendTim
| |
30 const talk_base::PacketOptions& options); | |
31 bool GetRtpPacketStartPositionAndLength(char* data, int length, | |
32 int* rtp_start_pos, | |
33 int* rtp_packet_length); | |
34 bool MaybeUpdateRtpAbsSendTimeExtn(char* rtp, int length, | |
35 int extension_id); | |
36 } // packet_processing_helpers | |
37 | |
24 // Base class for P2P sockets. | 38 // Base class for P2P sockets. |
25 class CONTENT_EXPORT P2PSocketHost { | 39 class CONTENT_EXPORT P2PSocketHost { |
26 public: | 40 public: |
27 static const int kStunHeaderSize = 20; | 41 static const int kStunHeaderSize = 20; |
28 // Creates P2PSocketHost of the specific type. | 42 // Creates P2PSocketHost of the specific type. |
29 static P2PSocketHost* Create(IPC::Sender* message_sender, | 43 static P2PSocketHost* Create(IPC::Sender* message_sender, |
30 int id, P2PSocketType type, | 44 int id, P2PSocketType type, |
31 net::URLRequestContextGetter* url_context, | 45 net::URLRequestContextGetter* url_context, |
32 P2PMessageThrottler* throttler); | 46 P2PMessageThrottler* throttler); |
33 | 47 |
34 virtual ~P2PSocketHost(); | 48 virtual ~P2PSocketHost(); |
35 | 49 |
36 // Initalizes the socket. Returns false when initiazations fails. | 50 // Initalizes the socket. Returns false when initiazations fails. |
37 virtual bool Init(const net::IPEndPoint& local_address, | 51 virtual bool Init(const net::IPEndPoint& local_address, |
38 const net::IPEndPoint& remote_address) = 0; | 52 const net::IPEndPoint& remote_address) = 0; |
39 | 53 |
40 // Sends |data| on the socket to |to|. | 54 // Sends |data| on the socket to |to|. |
41 virtual void Send(const net::IPEndPoint& to, | 55 virtual void Send(const net::IPEndPoint& to, |
42 const std::vector<char>& data, | 56 const std::vector<char>& data, |
43 net::DiffServCodePoint dscp, | 57 net::DiffServCodePoint dscp, |
44 uint64 packet_id) = 0; | 58 uint64 packet_id) = 0; |
45 | 59 |
46 virtual P2PSocketHost* AcceptIncomingTcpConnection( | 60 virtual P2PSocketHost* AcceptIncomingTcpConnection( |
47 const net::IPEndPoint& remote_address, int id) = 0; | 61 const net::IPEndPoint& remote_address, int id) = 0; |
48 | 62 |
49 virtual bool SetOption(P2PSocketOption option, int value) = 0; | 63 virtual bool SetOption(P2PSocketOption option, int value) = 0; |
50 | 64 |
51 protected: | 65 protected: |
52 friend class P2PSocketHostTcpTestBase; | |
53 | 66 |
54 // TODO(mallinath) - Remove this below enum and use one defined in | 67 // TODO(mallinath) - Remove this below enum and use one defined in |
55 // libjingle/souce/talk/p2p/base/stun.h | 68 // libjingle/souce/talk/p2p/base/stun.h |
56 enum StunMessageType { | 69 enum StunMessageType { |
57 STUN_BINDING_REQUEST = 0x0001, | 70 STUN_BINDING_REQUEST = 0x0001, |
58 STUN_BINDING_RESPONSE = 0x0101, | 71 STUN_BINDING_RESPONSE = 0x0101, |
59 STUN_BINDING_ERROR_RESPONSE = 0x0111, | 72 STUN_BINDING_ERROR_RESPONSE = 0x0111, |
60 STUN_SHARED_SECRET_REQUEST = 0x0002, | 73 STUN_SHARED_SECRET_REQUEST = 0x0002, |
61 STUN_SHARED_SECRET_RESPONSE = 0x0102, | 74 STUN_SHARED_SECRET_RESPONSE = 0x0102, |
62 STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, | 75 STUN_SHARED_SECRET_ERROR_RESPONSE = 0x0112, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 IPC::Sender* message_sender_; | 109 IPC::Sender* message_sender_; |
97 int id_; | 110 int id_; |
98 State state_; | 111 State state_; |
99 | 112 |
100 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); | 113 DISALLOW_COPY_AND_ASSIGN(P2PSocketHost); |
101 }; | 114 }; |
102 | 115 |
103 } // namespace content | 116 } // namespace content |
104 | 117 |
105 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ | 118 #endif // CONTENT_BROWSER_RENDERER_HOST_P2P_SOCKET_HOST_H_ |
OLD | NEW |