OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ | 5 #ifndef REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ |
6 #define REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ | 6 #define REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "remoting/base/url_request.h" | 12 #include "remoting/base/url_request.h" |
| 13 #include "remoting/protocol/ice_config.h" |
| 14 #include "remoting/protocol/transport_context.h" |
13 #include "third_party/webrtc/p2p/client/basicportallocator.h" | 15 #include "third_party/webrtc/p2p/client/basicportallocator.h" |
14 | 16 |
15 namespace remoting { | 17 namespace remoting { |
16 namespace protocol { | 18 namespace protocol { |
17 | 19 |
18 class TransportContext; | |
19 | |
20 class PortAllocator : public cricket::BasicPortAllocator { | 20 class PortAllocator : public cricket::BasicPortAllocator { |
21 public: | 21 public: |
22 PortAllocator(scoped_ptr<rtc::NetworkManager> network_manager, | 22 PortAllocator(scoped_ptr<rtc::NetworkManager> network_manager, |
23 scoped_ptr<rtc::PacketSocketFactory> socket_factory, | 23 scoped_ptr<rtc::PacketSocketFactory> socket_factory, |
24 scoped_refptr<TransportContext> transport_context); | 24 scoped_refptr<TransportContext> transport_context); |
25 ~PortAllocator() override; | 25 ~PortAllocator() override; |
26 | 26 |
27 scoped_refptr<TransportContext> transport_context() { | 27 scoped_refptr<TransportContext> transport_context() { |
28 return transport_context_; | 28 return transport_context_; |
29 } | 29 } |
(...skipping 14 matching lines...) Expand all Loading... |
44 public: | 44 public: |
45 PortAllocatorSession(PortAllocator* allocator, | 45 PortAllocatorSession(PortAllocator* allocator, |
46 const std::string& content_name, | 46 const std::string& content_name, |
47 int component, | 47 int component, |
48 const std::string& ice_ufrag, | 48 const std::string& ice_ufrag, |
49 const std::string& ice_pwd); | 49 const std::string& ice_pwd); |
50 ~PortAllocatorSession() override; | 50 ~PortAllocatorSession() override; |
51 | 51 |
52 private: | 52 private: |
53 void GetPortConfigurations() override; | 53 void GetPortConfigurations() override; |
54 void OnJingleInfo(std::vector<rtc::SocketAddress> stun_hosts, | 54 void OnIceConfig(const IceConfig& ice_config); |
55 std::vector<std::string> relay_hosts, | |
56 std::string relay_token); | |
57 void TryCreateRelaySession(); | 55 void TryCreateRelaySession(); |
58 void OnSessionRequestResult(const UrlRequest::Result& result); | 56 void OnSessionRequestResult(const UrlRequest::Result& result); |
59 | 57 |
60 const std::string& relay_token() const { return relay_token_; } | |
61 | |
62 scoped_refptr<TransportContext> transport_context_; | 58 scoped_refptr<TransportContext> transport_context_; |
63 | 59 |
64 std::vector<rtc::SocketAddress> stun_hosts_; | 60 IceConfig ice_config_; |
65 std::vector<std::string> relay_hosts_; | |
66 std::string relay_token_; | |
67 | 61 |
68 int attempts_ = 0; | 62 int attempts_ = 0; |
69 | 63 |
70 std::set<scoped_ptr<UrlRequest>> url_requests_; | 64 std::set<scoped_ptr<UrlRequest>> url_requests_; |
71 | 65 |
72 base::WeakPtrFactory<PortAllocatorSession> weak_factory_; | 66 base::WeakPtrFactory<PortAllocatorSession> weak_factory_; |
73 }; | 67 }; |
74 | 68 |
75 } // namespace protocol | 69 } // namespace protocol |
76 } // namespace remoting | 70 } // namespace remoting |
77 | 71 |
78 #endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ | 72 #endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_H_ |
OLD | NEW |