OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
| 6 #define CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "net/base/net_util.h" |
| 10 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
| 11 #include "webkit/glue/p2p_transport.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 class P2PHostAddressRequest; |
| 16 class P2PPortAllocatorSession; |
| 17 class P2PSocketDispatcher; |
| 18 |
| 19 class P2PPortAllocator : public cricket::BasicPortAllocator{ |
| 20 public: |
| 21 P2PPortAllocator(P2PSocketDispatcher* socket_dispatcher, |
| 22 talk_base::NetworkManager* network_manager, |
| 23 talk_base::PacketSocketFactory* socket_factory, |
| 24 const webkit_glue::P2PTransport::Config& config); |
| 25 virtual ~P2PPortAllocator(); |
| 26 |
| 27 virtual cricket::PortAllocatorSession* CreateSession( |
| 28 const std::string& name, |
| 29 const std::string& session_type) OVERRIDE; |
| 30 |
| 31 private: |
| 32 friend class P2PPortAllocatorSession; |
| 33 |
| 34 P2PSocketDispatcher* socket_dispatcher_; |
| 35 webkit_glue::P2PTransport::Config config_; |
| 36 |
| 37 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator); |
| 38 }; |
| 39 |
| 40 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession { |
| 41 public: |
| 42 P2PPortAllocatorSession( |
| 43 P2PPortAllocator* allocator, |
| 44 const std::string& name, |
| 45 const std::string& session_type); |
| 46 virtual ~P2PPortAllocatorSession(); |
| 47 |
| 48 protected: |
| 49 // Overrides for cricket::BasicPortAllocatorSession. |
| 50 virtual void GetPortConfigurations() OVERRIDE; |
| 51 |
| 52 private: |
| 53 void ResolveStunServerAddress(); |
| 54 void OnStunServerAddress(const net::IPAddressNumber& address); |
| 55 |
| 56 P2PPortAllocator* allocator_; |
| 57 |
| 58 scoped_refptr<P2PHostAddressRequest> stun_address_request_; |
| 59 |
| 60 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession); |
| 61 }; |
| 62 |
| 63 } // namespace content |
| 64 |
| 65 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_ |
OLD | NEW |