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

Side by Side Diff: remoting/protocol/transport_context.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/port_allocator_factory.h ('k') | remoting/protocol/transport_context.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_TRANSPORT_CONTEXT_H_ 5 #ifndef REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_
6 #define REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ 6 #define REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "remoting/protocol/network_settings.h" 15 #include "remoting/protocol/network_settings.h"
16 #include "remoting/protocol/transport.h" 16 #include "remoting/protocol/transport.h"
17 #include "remoting/signaling/jingle_info_request.h" 17 #include "remoting/signaling/jingle_info_request.h"
18 18
19 namespace cricket {
20 class PortAllocator;
21 } // namespace cricket
22 19
23 namespace remoting { 20 namespace remoting {
24 21
25 class SignalStrategy; 22 class SignalStrategy;
23 class UrlRequestFactory;
26 24
27 namespace protocol { 25 namespace protocol {
28 26
29 class PortAllocatorFactory; 27 class PortAllocatorFactory;
30 28
31 // TransportContext is responsible for storing all parameters required for 29 // TransportContext is responsible for storing all parameters required for
32 // P2P transport initialization. It's also responsible for making JingleInfo 30 // P2P transport initialization. It's also responsible for making JingleInfo
33 // request. 31 // request.
34 class TransportContext : public base::RefCountedThreadSafe<TransportContext> { 32 class TransportContext : public base::RefCountedThreadSafe<TransportContext> {
35 public: 33 public:
36 typedef base::Callback<void(std::vector<rtc::SocketAddress> stun_hosts, 34 typedef base::Callback<void(std::vector<rtc::SocketAddress> stun_hosts,
37 std::vector<std::string> relay_hosts, 35 std::vector<std::string> relay_hosts,
38 std::string relay_token)> GetJingleInfoCallback; 36 std::string relay_token)> GetJingleInfoCallback;
39 37
40 static scoped_refptr<TransportContext> ForTests(TransportRole role); 38 static scoped_refptr<TransportContext> ForTests(TransportRole role);
41 39
42 TransportContext(SignalStrategy* signal_strategy, 40 TransportContext(SignalStrategy* signal_strategy,
43 scoped_ptr<PortAllocatorFactory> port_allocator_factory, 41 scoped_ptr<PortAllocatorFactory> port_allocator_factory,
42 scoped_ptr<UrlRequestFactory> url_request_factory,
44 const NetworkSettings& network_settings, 43 const NetworkSettings& network_settings,
45 TransportRole role); 44 TransportRole role);
46 45
47 // Prepares fresh JingleInfo. It may be called while connection is being 46 // Prepares fresh JingleInfo. It may be called while connection is being
48 // negotiated to minimize the chance that the following GetJingleInfo() will 47 // negotiated to minimize the chance that the following GetJingleInfo() will
49 // be blocking. 48 // be blocking.
50 void Prepare(); 49 void Prepare();
51 50
52 // Requests fresh STUN and TURN information. 51 // Requests fresh STUN and TURN information.
53 void GetJingleInfo(const GetJingleInfoCallback& callback); 52 void GetJingleInfo(const GetJingleInfoCallback& callback);
54 53
55 PortAllocatorFactory* port_allocator_factory() { 54 PortAllocatorFactory* port_allocator_factory() {
56 return port_allocator_factory_.get(); 55 return port_allocator_factory_.get();
57 } 56 }
57 UrlRequestFactory* url_request_factory() {
58 return url_request_factory_.get();
59 }
58 const NetworkSettings& network_settings() const { return network_settings_; } 60 const NetworkSettings& network_settings() const { return network_settings_; }
59 TransportRole role() const { return role_; } 61 TransportRole role() const { return role_; }
60 62
61 private: 63 private:
62 friend class base::RefCountedThreadSafe<TransportContext>; 64 friend class base::RefCountedThreadSafe<TransportContext>;
63 65
64 ~TransportContext(); 66 ~TransportContext();
65 67
66 void EnsureFreshJingleInfo(); 68 void EnsureFreshJingleInfo();
67 void OnJingleInfo(const std::string& relay_token, 69 void OnJingleInfo(const std::string& relay_token,
68 const std::vector<std::string>& relay_hosts, 70 const std::vector<std::string>& relay_hosts,
69 const std::vector<rtc::SocketAddress>& stun_hosts); 71 const std::vector<rtc::SocketAddress>& stun_hosts);
70 72
71 SignalStrategy* signal_strategy_; 73 SignalStrategy* signal_strategy_;
72 scoped_ptr<PortAllocatorFactory> port_allocator_factory_; 74 scoped_ptr<PortAllocatorFactory> port_allocator_factory_;
75 scoped_ptr<UrlRequestFactory> url_request_factory_;
73 NetworkSettings network_settings_; 76 NetworkSettings network_settings_;
74 TransportRole role_; 77 TransportRole role_;
75 78
76 base::TimeTicks last_jingle_info_update_time_; 79 base::TimeTicks last_jingle_info_update_time_;
77 scoped_ptr<JingleInfoRequest> jingle_info_request_; 80 scoped_ptr<JingleInfoRequest> jingle_info_request_;
78 81
79 std::vector<rtc::SocketAddress> stun_hosts_; 82 std::vector<rtc::SocketAddress> stun_hosts_;
80 std::vector<std::string> relay_hosts_; 83 std::vector<std::string> relay_hosts_;
81 std::string relay_token_; 84 std::string relay_token_;
82 85
83 // When there is an active |jingle_info_request_| stores list of callbacks to 86 // When there is an active |jingle_info_request_| stores list of callbacks to
84 // be called once the request is finished. 87 // be called once the request is finished.
85 std::list<GetJingleInfoCallback> pending_jingle_info_callbacks_; 88 std::list<GetJingleInfoCallback> pending_jingle_info_callbacks_;
86 89
87 DISALLOW_COPY_AND_ASSIGN(TransportContext); 90 DISALLOW_COPY_AND_ASSIGN(TransportContext);
88 }; 91 };
89 92
90 } // namespace protocol 93 } // namespace protocol
91 } // namespace remoting 94 } // namespace remoting
92 95
93 #endif // REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_ 96 #endif // REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_
OLDNEW
« no previous file with comments | « remoting/protocol/port_allocator_factory.h ('k') | remoting/protocol/transport_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698