Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(337)

Side by Side Diff: remoting/protocol/port_allocator.h

Issue 1681393006: Use UrlRequest in PortAllocator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/jingle_session_unittest.cc ('k') | remoting/protocol/port_allocator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_BASE_H_ 5 #ifndef REMOTING_PROTOCOL_PORT_ALLOCATOR_H_
6 #define REMOTING_PROTOCOL_PORT_ALLOCATOR_BASE_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 "third_party/webrtc/p2p/client/basicportallocator.h" 13 #include "third_party/webrtc/p2p/client/basicportallocator.h"
13 14
14 namespace remoting { 15 namespace remoting {
15 namespace protocol { 16 namespace protocol {
16 17
17 class TransportContext; 18 class TransportContext;
18 19
19 class PortAllocatorBase : public cricket::BasicPortAllocator { 20 class PortAllocator : public cricket::BasicPortAllocator {
20 public: 21 public:
21 // The number of HTTP requests we should attempt before giving up. 22 PortAllocator(scoped_ptr<rtc::NetworkManager> network_manager,
22 static const int kNumRetries; 23 scoped_ptr<rtc::PacketSocketFactory> socket_factory,
23 24 scoped_refptr<TransportContext> transport_context);
24 PortAllocatorBase(scoped_ptr<rtc::NetworkManager> network_manager, 25 ~PortAllocator() override;
25 scoped_ptr<rtc::PacketSocketFactory> socket_factory,
26 scoped_refptr<TransportContext> transport_context);
27 ~PortAllocatorBase() override;
28 26
29 scoped_refptr<TransportContext> transport_context() { 27 scoped_refptr<TransportContext> transport_context() {
30 return transport_context_; 28 return transport_context_;
31 } 29 }
32 30
33 // CreateSession is defined in cricket::BasicPortAllocator but is
34 // redefined here as pure virtual.
35 cricket::PortAllocatorSession* CreateSessionInternal( 31 cricket::PortAllocatorSession* CreateSessionInternal(
36 const std::string& content_name, 32 const std::string& content_name,
37 int component, 33 int component,
38 const std::string& ice_ufrag, 34 const std::string& ice_ufrag,
39 const std::string& ice_pwd) override = 0; 35 const std::string& ice_pwd) override;
40 36
41 private: 37 private:
42 scoped_ptr<rtc::NetworkManager> network_manager_; 38 scoped_ptr<rtc::NetworkManager> network_manager_;
43 scoped_ptr<rtc::PacketSocketFactory> socket_factory_; 39 scoped_ptr<rtc::PacketSocketFactory> socket_factory_;
44 scoped_refptr<TransportContext> transport_context_; 40 scoped_refptr<TransportContext> transport_context_;
45 }; 41 };
46 42
47 class PortAllocatorSessionBase : public cricket::BasicPortAllocatorSession { 43 class PortAllocatorSession : public cricket::BasicPortAllocatorSession {
48 public: 44 public:
49 PortAllocatorSessionBase(PortAllocatorBase* allocator, 45 PortAllocatorSession(PortAllocator* allocator,
50 const std::string& content_name, 46 const std::string& content_name,
51 int component, 47 int component,
52 const std::string& ice_ufrag, 48 const std::string& ice_ufrag,
53 const std::string& ice_pwd); 49 const std::string& ice_pwd);
54 ~PortAllocatorSessionBase() override; 50 ~PortAllocatorSession() override;
55 51
56 virtual void SendSessionRequest(const std::string& host) = 0; 52 private:
57 void ReceiveSessionResponse(const std::string& response);
58
59 protected:
60 std::string GetSessionRequestUrl();
61
62 void GetPortConfigurations() override; 53 void GetPortConfigurations() override;
63 void OnJingleInfo(std::vector<rtc::SocketAddress> stun_hosts, 54 void OnJingleInfo(std::vector<rtc::SocketAddress> stun_hosts,
64 std::vector<std::string> relay_hosts, 55 std::vector<std::string> relay_hosts,
65 std::string relay_token); 56 std::string relay_token);
66 void TryCreateRelaySession(); 57 void TryCreateRelaySession();
58 void OnSessionRequestResult(const UrlRequest::Result& result);
67 59
68 const std::string& relay_token() const { return relay_token_; } 60 const std::string& relay_token() const { return relay_token_; }
69 61
70 private:
71 scoped_refptr<TransportContext> transport_context_; 62 scoped_refptr<TransportContext> transport_context_;
72 63
73 std::vector<rtc::SocketAddress> stun_hosts_; 64 std::vector<rtc::SocketAddress> stun_hosts_;
74 std::vector<std::string> relay_hosts_; 65 std::vector<std::string> relay_hosts_;
75 std::string relay_token_; 66 std::string relay_token_;
76 67
77 int attempts_ = 0; 68 int attempts_ = 0;
78 69
79 base::WeakPtrFactory<PortAllocatorSessionBase> weak_factory_; 70 std::set<scoped_ptr<UrlRequest>> url_requests_;
71
72 base::WeakPtrFactory<PortAllocatorSession> weak_factory_;
80 }; 73 };
81 74
82 } // namespace protocol 75 } // namespace protocol
83 } // namespace remoting 76 } // namespace remoting
84 77
85 #endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_BASE_H_ 78 #endif // REMOTING_PROTOCOL_PORT_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_unittest.cc ('k') | remoting/protocol/port_allocator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698