| 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 "net/base/net_util.h" | 10 #include "net/base/net_util.h" |
| 10 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 11 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
| 11 #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" |
| 12 #include "webkit/glue/p2p_transport.h" | 13 #include "webkit/glue/p2p_transport.h" |
| 13 | 14 |
| 14 namespace WebKit { | 15 namespace WebKit { |
| 15 class WebFrame; | 16 class WebFrame; |
| 16 class WebURLLoader; | 17 class WebURLLoader; |
| 17 } // namespace WebKit | 18 } // namespace WebKit |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 | 21 |
| 21 class P2PHostAddressRequest; | 22 class P2PHostAddressRequest; |
| 22 class P2PPortAllocatorSession; | 23 class P2PPortAllocatorSession; |
| 23 class P2PSocketDispatcher; | 24 class P2PSocketDispatcher; |
| 24 | 25 |
| 25 // TODO(sergeyu): There is overlap between this class and | 26 // TODO(sergeyu): There is overlap between this class and |
| 26 // HttpPortAllocator. Refactor HttpPortAllocator | 27 // HttpPortAllocator. Refactor HttpPortAllocator |
| 27 class P2PPortAllocator : public cricket::BasicPortAllocator { | 28 class P2PPortAllocator : public cricket::BasicPortAllocator { |
| 28 public: | 29 public: |
| 29 P2PPortAllocator(WebKit::WebFrame* web_frame, | 30 P2PPortAllocator(WebKit::WebFrame* web_frame, |
| 30 P2PSocketDispatcher* socket_dispatcher, | 31 P2PSocketDispatcher* socket_dispatcher, |
| 31 talk_base::NetworkManager* network_manager, | 32 talk_base::NetworkManager* network_manager, |
| 32 talk_base::PacketSocketFactory* socket_factory, | 33 talk_base::PacketSocketFactory* socket_factory, |
| 33 const webkit_glue::P2PTransport::Config& config); | 34 const webkit_glue::P2PTransport::Config& config); |
| 34 virtual ~P2PPortAllocator(); | 35 virtual ~P2PPortAllocator(); |
| 35 | 36 |
| 36 virtual cricket::PortAllocatorSession* CreateSession( | 37 virtual cricket::PortAllocatorSession* CreateSession( |
| 37 const std::string& name, | 38 const std::string& channel_name, |
| 38 const std::string& session_type) OVERRIDE; | 39 int component) OVERRIDE; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 friend class P2PPortAllocatorSession; | 42 friend class P2PPortAllocatorSession; |
| 42 | 43 |
| 43 WebKit::WebFrame* web_frame_; | 44 WebKit::WebFrame* web_frame_; |
| 44 P2PSocketDispatcher* socket_dispatcher_; | 45 P2PSocketDispatcher* socket_dispatcher_; |
| 45 webkit_glue::P2PTransport::Config config_; | 46 webkit_glue::P2PTransport::Config config_; |
| 46 | 47 |
| 47 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); | 48 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, | 51 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession, |
| 51 public WebKit::WebURLLoaderClient { | 52 public WebKit::WebURLLoaderClient { |
| 52 public: | 53 public: |
| 53 P2PPortAllocatorSession( | 54 P2PPortAllocatorSession( |
| 54 P2PPortAllocator* allocator, | 55 P2PPortAllocator* allocator, |
| 55 const std::string& name, | 56 const std::string& channel_name, |
| 56 const std::string& session_type); | 57 int candidate); |
| 57 virtual ~P2PPortAllocatorSession(); | 58 virtual ~P2PPortAllocatorSession(); |
| 58 | 59 |
| 59 // WebKit::WebURLLoaderClient overrides. | 60 // WebKit::WebURLLoaderClient overrides. |
| 60 virtual void didReceiveData(WebKit::WebURLLoader* loader, | 61 virtual void didReceiveData(WebKit::WebURLLoader* loader, |
| 61 const char* data, | 62 const char* data, |
| 62 int data_length, | 63 int data_length, |
| 63 int encoded_data_length) OVERRIDE; | 64 int encoded_data_length) OVERRIDE; |
| 64 virtual void didFinishLoading(WebKit::WebURLLoader* loader, | 65 virtual void didFinishLoading(WebKit::WebURLLoader* loader, |
| 65 double finish_time) OVERRIDE; | 66 double finish_time) OVERRIDE; |
| 66 virtual void didFail(WebKit::WebURLLoader* loader, | 67 virtual void didFail(WebKit::WebURLLoader* loader, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 91 int relay_udp_port_; | 92 int relay_udp_port_; |
| 92 int relay_tcp_port_; | 93 int relay_tcp_port_; |
| 93 int relay_ssltcp_port_; | 94 int relay_ssltcp_port_; |
| 94 | 95 |
| 95 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); | 96 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); |
| 96 }; | 97 }; |
| 97 | 98 |
| 98 } // namespace content | 99 } // namespace content |
| 99 | 100 |
| 100 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ | 101 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
| OLD | NEW |