Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / content / renderer / p2p / port_allocator.h
blob3d1ae5fa161a85cc81d6ea66a3e2f8ea9b1631f2
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"
9 #include "url/gurl.h"
11 namespace content {
13 class P2PPortAllocatorSession;
14 class P2PSocketDispatcher;
16 class P2PPortAllocator : public cricket::BasicPortAllocator {
17 public:
18 struct Config {
19 Config();
20 ~Config();
22 struct RelayServerConfig {
23 RelayServerConfig();
24 ~RelayServerConfig();
26 std::string username;
27 std::string password;
28 std::string server_address;
29 int port;
30 std::string transport_type;
31 bool secure;
34 std::set<rtc::SocketAddress> stun_servers;
36 std::vector<RelayServerConfig> relays;
38 // Disable TCP-based transport when set to true.
39 bool disable_tcp_transport;
41 // Disable binding to individual NICs when set to false.
42 bool enable_multiple_routes;
45 P2PPortAllocator(P2PSocketDispatcher* socket_dispatcher,
46 rtc::NetworkManager* network_manager,
47 rtc::PacketSocketFactory* socket_factory,
48 const Config& config,
49 const GURL& origin);
50 ~P2PPortAllocator() override;
52 cricket::PortAllocatorSession* CreateSessionInternal(
53 const std::string& content_name,
54 int component,
55 const std::string& ice_username_fragment,
56 const std::string& ice_password) override;
58 private:
59 friend class P2PPortAllocatorSession;
61 P2PSocketDispatcher* socket_dispatcher_;
62 Config config_;
63 GURL origin_;
65 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocator);
68 class P2PPortAllocatorSession : public cricket::BasicPortAllocatorSession {
69 public:
70 P2PPortAllocatorSession(
71 P2PPortAllocator* allocator,
72 const std::string& content_name,
73 int component,
74 const std::string& ice_username_fragment,
75 const std::string& ice_password);
76 ~P2PPortAllocatorSession() override;
78 protected:
79 // Overrides for cricket::BasicPortAllocatorSession.
80 void GetPortConfigurations() override;
82 private:
83 P2PPortAllocator* allocator_;
85 DISALLOW_COPY_AND_ASSIGN(P2PPortAllocatorSession);
88 } // namespace content
90 #endif // CONTENT_RENDERER_P2P_PORT_ALLOCATOR_H_