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 #ifndef CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ | 5 #ifndef CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
6 #define CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ | 6 #define CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
11 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 11 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLLoader
Client.h" |
13 #include "webkit/glue/p2p_transport.h" | |
14 | 13 |
15 namespace WebKit { | 14 namespace WebKit { |
16 class WebFrame; | 15 class WebFrame; |
17 class WebURLLoader; | 16 class WebURLLoader; |
18 } // namespace WebKit | 17 } // namespace WebKit |
19 | 18 |
20 namespace content { | 19 namespace content { |
21 | 20 |
22 class P2PHostAddressRequest; | 21 class P2PHostAddressRequest; |
23 class P2PPortAllocatorSession; | 22 class P2PPortAllocatorSession; |
24 class P2PSocketDispatcher; | 23 class P2PSocketDispatcher; |
25 | 24 |
26 // TODO(sergeyu): There is overlap between this class and | 25 // TODO(sergeyu): There is overlap between this class and HttpPortAllocator. |
27 // HttpPortAllocator. Refactor HttpPortAllocator | 26 // Refactor this class to inherit from HttpPortAllocator to avoid code |
| 27 // duplication. |
28 class P2PPortAllocator : public cricket::BasicPortAllocator { | 28 class P2PPortAllocator : public cricket::BasicPortAllocator { |
29 public: | 29 public: |
| 30 struct Config { |
| 31 Config(); |
| 32 ~Config(); |
| 33 |
| 34 // STUN server address and port. |
| 35 std::string stun_server; |
| 36 int stun_server_port; |
| 37 |
| 38 // Relay server address and port. |
| 39 std::string relay_server; |
| 40 int relay_server_port; |
| 41 |
| 42 // Relay server username. |
| 43 std::string relay_username; |
| 44 |
| 45 // Relay server password. |
| 46 std::string relay_password; |
| 47 |
| 48 // When set to true relay is a legacy Google relay (not TURN compliant). |
| 49 bool legacy_relay; |
| 50 |
| 51 // Disable TCP-based transport when set to true. |
| 52 bool disable_tcp_transport; |
| 53 }; |
| 54 |
30 P2PPortAllocator(WebKit::WebFrame* web_frame, | 55 P2PPortAllocator(WebKit::WebFrame* web_frame, |
31 P2PSocketDispatcher* socket_dispatcher, | 56 P2PSocketDispatcher* socket_dispatcher, |
32 talk_base::NetworkManager* network_manager, | 57 talk_base::NetworkManager* network_manager, |
33 talk_base::PacketSocketFactory* socket_factory, | 58 talk_base::PacketSocketFactory* socket_factory, |
34 const webkit_glue::P2PTransport::Config& config); | 59 const Config& config); |
35 virtual ~P2PPortAllocator(); | 60 virtual ~P2PPortAllocator(); |
36 | 61 |
37 virtual cricket::PortAllocatorSession* CreateSessionInternal( | 62 virtual cricket::PortAllocatorSession* CreateSessionInternal( |
38 const std::string& content_name, | 63 const std::string& content_name, |
39 int component, | 64 int component, |
40 const std::string& ice_username_fragment, | 65 const std::string& ice_username_fragment, |
41 const std::string& ice_password) OVERRIDE; | 66 const std::string& ice_password) OVERRIDE; |
42 | 67 |
43 private: | 68 private: |
44 friend class P2PPortAllocatorSession; | 69 friend class P2PPortAllocatorSession; |
45 | 70 |
46 WebKit::WebFrame* web_frame_; | 71 WebKit::WebFrame* web_frame_; |
47 P2PSocketDispatcher* socket_dispatcher_; | 72 P2PSocketDispatcher* socket_dispatcher_; |
48 webkit_glue::P2PTransport::Config config_; | 73 Config config_; |
49 | 74 |
50 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); | 75 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); |
51 }; | 76 }; |
52 | 77 |
53 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, | 78 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, |
54 public WebKit::WebURLLoaderClient { | 79 public WebKit::WebURLLoaderClient { |
55 public: | 80 public: |
56 P2PPortAllocatorSession( | 81 P2PPortAllocatorSession( |
57 P2PPortAllocator* allocator, | 82 P2PPortAllocator* allocator, |
58 const std::string& content_name, | 83 const std::string& content_name, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 int relay_udp_port_; | 121 int relay_udp_port_; |
97 int relay_tcp_port_; | 122 int relay_tcp_port_; |
98 int relay_ssltcp_port_; | 123 int relay_ssltcp_port_; |
99 | 124 |
100 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); | 125 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); |
101 }; | 126 }; |
102 | 127 |
103 } // namespace content | 128 } // namespace content |
104 | 129 |
105 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ | 130 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
OLD | NEW |