Roll WebRTC 7546:7549.
[chromium-blink-merge.git] / content / renderer / p2p / port_allocator.h
blob3cb1377a1dee89dfa9516c877e9254dbc6fea597
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_
6 #define CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_
8 #include "third_party/webrtc/p2p/client/basicportallocator.h"
10 namespace content {
12 class P2PPortAllocatorSession;
13 class P2PSocketDispatcher;
15 class P2PPortAllocator : public cricket::BasicPortAllocator {
16 public:
17 struct Config {
18 Config();
19 ~Config();
21 struct RelayServerConfig {
22 RelayServerConfig();
23 ~RelayServerConfig();
25 std::string username;
26 std::string password;
27 std::string server_address;
28 int port;
29 std::string transport_type;
30 bool secure;
33 std::set<rtc::SocketAddress> stun_servers;
35 std::vector<RelayServerConfig> relays;
37 // Disable TCP-based transport when set to true.
38 bool disable_tcp_transport;
41 P2PPortAllocator(P2PSocketDispatcher* socket_dispatcher,
42 rtc::NetworkManager* network_manager,
43 rtc::PacketSocketFactory* socket_factory,
44 const Config& config);
45 ~P2PPortAllocator() override;
47 cricket::PortAllocatorSession* CreateSessionInternal(
48 const std::string& content_name,
49 int component,
50 const std::string& ice_username_fragment,
51 const std::string& ice_password) override;
53 private:
54 friend class P2PPortAllocatorSession;
56 P2PSocketDispatcher* socket_dispatcher_;
57 Config config_;
59 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator);
62 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession {
63 public:
64 P2PPortAllocatorSession(
65 P2PPortAllocator* allocator,
66 const std::string& content_name,
67 int component,
68 const std::string& ice_username_fragment,
69 const std::string& ice_password);
70 ~P2PPortAllocatorSession() override;
72 protected:
73 // Overrides for cricket::BasicPortAllocatorSession.
74 void GetPortConfigurations() override;
76 private:
77 P2PPortAllocator* allocator_;
79 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession);
82 } // namespace content
84 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_