OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/renderer_host/p2p/socket_host.h" | 5 #include "content/browser/renderer_host/p2p/socket_host.h" |
6 | 6 |
7 #include "base/sys_byteorder.h" | 7 #include "base/sys_byteorder.h" |
8 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" | 8 #include "content/browser/renderer_host/p2p/socket_host_tcp.h" |
9 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" | 9 #include "content/browser/renderer_host/p2p/socket_host_tcp_server.h" |
10 #include "content/browser/renderer_host/p2p/socket_host_udp.h" | 10 #include "content/browser/renderer_host/p2p/socket_host_udp.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 const int kStunHeaderSize = 20; | 13 const int kStunHeaderSize = 20; |
14 const uint32 kStunMagicCookie = 0x2112A442; | 14 const uint32 kStunMagicCookie = 0x2112A442; |
15 } // namespace | 15 } // namespace |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 P2PSocketHost::P2PSocketHost(IPC::Message::Sender* message_sender, | 19 P2PSocketHost::P2PSocketHost(IPC::Sender* message_sender, |
20 int routing_id, int id) | 20 int routing_id, int id) |
21 : message_sender_(message_sender), | 21 : message_sender_(message_sender), |
22 routing_id_(routing_id), | 22 routing_id_(routing_id), |
23 id_(id), | 23 id_(id), |
24 state_(STATE_UNINITIALIZED) { | 24 state_(STATE_UNINITIALIZED) { |
25 } | 25 } |
26 | 26 |
27 P2PSocketHost::~P2PSocketHost() { } | 27 P2PSocketHost::~P2PSocketHost() { } |
28 | 28 |
29 // Verifies that the packet |data| has a valid STUN header. | 29 // Verifies that the packet |data| has a valid STUN header. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 68 } |
69 | 69 |
70 // static | 70 // static |
71 bool P2PSocketHost::IsRequestOrResponse(StunMessageType type) { | 71 bool P2PSocketHost::IsRequestOrResponse(StunMessageType type) { |
72 return type == STUN_BINDING_REQUEST || type == STUN_BINDING_RESPONSE || | 72 return type == STUN_BINDING_REQUEST || type == STUN_BINDING_RESPONSE || |
73 type == STUN_ALLOCATE_REQUEST || type == STUN_ALLOCATE_RESPONSE; | 73 type == STUN_ALLOCATE_REQUEST || type == STUN_ALLOCATE_RESPONSE; |
74 } | 74 } |
75 | 75 |
76 // static | 76 // static |
77 P2PSocketHost* P2PSocketHost::Create( | 77 P2PSocketHost* P2PSocketHost::Create( |
78 IPC::Message::Sender* message_sender, int routing_id, int id, | 78 IPC::Sender* message_sender, int routing_id, int id, |
79 P2PSocketType type) { | 79 P2PSocketType type) { |
80 switch (type) { | 80 switch (type) { |
81 case P2P_SOCKET_UDP: | 81 case P2P_SOCKET_UDP: |
82 return new P2PSocketHostUdp(message_sender, routing_id, id); | 82 return new P2PSocketHostUdp(message_sender, routing_id, id); |
83 | 83 |
84 case P2P_SOCKET_TCP_SERVER: | 84 case P2P_SOCKET_TCP_SERVER: |
85 return new P2PSocketHostTcpServer(message_sender, routing_id, id); | 85 return new P2PSocketHostTcpServer(message_sender, routing_id, id); |
86 | 86 |
87 case P2P_SOCKET_TCP_CLIENT: | 87 case P2P_SOCKET_TCP_CLIENT: |
88 return new P2PSocketHostTcp(message_sender, routing_id, id); | 88 return new P2PSocketHostTcp(message_sender, routing_id, id); |
89 } | 89 } |
90 | 90 |
91 NOTREACHED(); | 91 NOTREACHED(); |
92 return NULL; | 92 return NULL; |
93 } | 93 } |
94 | 94 |
95 } // namespace content | 95 } // namespace content |
OLD | NEW |