| 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/WebKit/public/platform/WebURLLoaderClient.h" | 11 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" |
| 12 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 12 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
| 13 | 13 |
| 14 namespace WebKit { | 14 namespace blink { |
| 15 class WebFrame; | 15 class WebFrame; |
| 16 class WebURLLoader; | 16 class WebURLLoader; |
| 17 } // namespace WebKit | 17 } // namespace blink |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class P2PHostAddressRequest; | 21 class P2PHostAddressRequest; |
| 22 class P2PPortAllocatorSession; | 22 class P2PPortAllocatorSession; |
| 23 class P2PSocketDispatcher; | 23 class P2PSocketDispatcher; |
| 24 | 24 |
| 25 // TODO(sergeyu): There is overlap between this class and HttpPortAllocator. | 25 // TODO(sergeyu): There is overlap between this class and HttpPortAllocator. |
| 26 // Refactor this class to inherit from HttpPortAllocator to avoid code | 26 // Refactor this class to inherit from HttpPortAllocator to avoid code |
| 27 // duplication. | 27 // duplication. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 47 std::string stun_server; | 47 std::string stun_server; |
| 48 int stun_server_port; | 48 int stun_server_port; |
| 49 | 49 |
| 50 std::vector<RelayServerConfig> relays; | 50 std::vector<RelayServerConfig> relays; |
| 51 | 51 |
| 52 bool legacy_relay; | 52 bool legacy_relay; |
| 53 // Disable TCP-based transport when set to true. | 53 // Disable TCP-based transport when set to true. |
| 54 bool disable_tcp_transport; | 54 bool disable_tcp_transport; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 P2PPortAllocator(WebKit::WebFrame* web_frame, | 57 P2PPortAllocator(blink::WebFrame* web_frame, |
| 58 P2PSocketDispatcher* socket_dispatcher, | 58 P2PSocketDispatcher* socket_dispatcher, |
| 59 talk_base::NetworkManager* network_manager, | 59 talk_base::NetworkManager* network_manager, |
| 60 talk_base::PacketSocketFactory* socket_factory, | 60 talk_base::PacketSocketFactory* socket_factory, |
| 61 const Config& config); | 61 const Config& config); |
| 62 virtual ~P2PPortAllocator(); | 62 virtual ~P2PPortAllocator(); |
| 63 | 63 |
| 64 virtual cricket::PortAllocatorSession* CreateSessionInternal( | 64 virtual cricket::PortAllocatorSession* CreateSessionInternal( |
| 65 const std::string& content_name, | 65 const std::string& content_name, |
| 66 int component, | 66 int component, |
| 67 const std::string& ice_username_fragment, | 67 const std::string& ice_username_fragment, |
| 68 const std::string& ice_password) OVERRIDE; | 68 const std::string& ice_password) OVERRIDE; |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 friend class P2PPortAllocatorSession; | 71 friend class P2PPortAllocatorSession; |
| 72 | 72 |
| 73 WebKit::WebFrame* web_frame_; | 73 blink::WebFrame* web_frame_; |
| 74 P2PSocketDispatcher* socket_dispatcher_; | 74 P2PSocketDispatcher* socket_dispatcher_; |
| 75 Config config_; | 75 Config config_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); | 77 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, | 80 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, |
| 81 public WebKit::WebURLLoaderClient { | 81 public blink::WebURLLoaderClient { |
| 82 public: | 82 public: |
| 83 P2PPortAllocatorSession( | 83 P2PPortAllocatorSession( |
| 84 P2PPortAllocator* allocator, | 84 P2PPortAllocator* allocator, |
| 85 const std::string& content_name, | 85 const std::string& content_name, |
| 86 int component, | 86 int component, |
| 87 const std::string& ice_username_fragment, | 87 const std::string& ice_username_fragment, |
| 88 const std::string& ice_password); | 88 const std::string& ice_password); |
| 89 virtual ~P2PPortAllocatorSession(); | 89 virtual ~P2PPortAllocatorSession(); |
| 90 | 90 |
| 91 // WebKit::WebURLLoaderClient overrides. | 91 // blink::WebURLLoaderClient overrides. |
| 92 virtual void didReceiveData(WebKit::WebURLLoader* loader, | 92 virtual void didReceiveData(blink::WebURLLoader* loader, |
| 93 const char* data, | 93 const char* data, |
| 94 int data_length, | 94 int data_length, |
| 95 int encoded_data_length) OVERRIDE; | 95 int encoded_data_length) OVERRIDE; |
| 96 virtual void didFinishLoading(WebKit::WebURLLoader* loader, | 96 virtual void didFinishLoading(blink::WebURLLoader* loader, |
| 97 double finish_time) OVERRIDE; | 97 double finish_time) OVERRIDE; |
| 98 virtual void didFail(WebKit::WebURLLoader* loader, | 98 virtual void didFail(blink::WebURLLoader* loader, |
| 99 const WebKit::WebURLError& error) OVERRIDE; | 99 const blink::WebURLError& error) OVERRIDE; |
| 100 | 100 |
| 101 protected: | 101 protected: |
| 102 // Overrides for cricket::BasicPortAllocatorSession. | 102 // Overrides for cricket::BasicPortAllocatorSession. |
| 103 virtual void GetPortConfigurations() OVERRIDE; | 103 virtual void GetPortConfigurations() OVERRIDE; |
| 104 | 104 |
| 105 private: | 105 private: |
| 106 | 106 |
| 107 struct RelayServer { | 107 struct RelayServer { |
| 108 RelayServer(); | 108 RelayServer(); |
| 109 ~RelayServer(); | 109 ~RelayServer(); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 void AddConfig(); | 128 void AddConfig(); |
| 129 | 129 |
| 130 P2PPortAllocator* allocator_; | 130 P2PPortAllocator* allocator_; |
| 131 | 131 |
| 132 scoped_refptr<P2PHostAddressRequest> stun_address_request_; | 132 scoped_refptr<P2PHostAddressRequest> stun_address_request_; |
| 133 talk_base::SocketAddress stun_server_address_; | 133 talk_base::SocketAddress stun_server_address_; |
| 134 | 134 |
| 135 std::vector<RelayServer> relay_info_; | 135 std::vector<RelayServer> relay_info_; |
| 136 | 136 |
| 137 scoped_ptr<WebKit::WebURLLoader> relay_session_request_; | 137 scoped_ptr<blink::WebURLLoader> relay_session_request_; |
| 138 int relay_session_attempts_; | 138 int relay_session_attempts_; |
| 139 std::string relay_session_response_; | 139 std::string relay_session_response_; |
| 140 talk_base::SocketAddress relay_ip_; | 140 talk_base::SocketAddress relay_ip_; |
| 141 int relay_udp_port_; | 141 int relay_udp_port_; |
| 142 int relay_tcp_port_; | 142 int relay_tcp_port_; |
| 143 int relay_ssltcp_port_; | 143 int relay_ssltcp_port_; |
| 144 int pending_relay_requests_; | 144 int pending_relay_requests_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); | 146 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace content | 149 } // namespace content |
| 150 | 150 |
| 151 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ | 151 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
| OLD | NEW |