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

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

Issue 1521883006: Add TransportContext class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_
6 #define REMOTING_PROTOCOL_TRANSPORT_CONTEXT_H_
7
8 #include <list>
9 #include <string>
10 #include <vector>
11
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "remoting/protocol/network_settings.h"
16 #include "remoting/protocol/transport.h"
17 #include "remoting/signaling/jingle_info_request.h"
18
19 namespace cricket {
20 class PortAllocator;
21 } // namespace cricket
22
23 namespace remoting {
24
25 class SignalStrategy;
26
27 namespace protocol {
28
29 class PortAllocatorFactory;
30
31 // TransportContext is responsible for storing all parameters required for
32 // P2P transport initialization. It's also responsible for making JingleInfo
33 // request and creation of PortAllocators configured according to the JingleInfo
34 // result.
35 class TransportContext : public base::RefCountedThreadSafe<TransportContext> {
36 public:
37 typedef base::Callback<void(scoped_ptr<cricket::PortAllocator>
38 port_allocator)> CreatePortAllocatorCallback;
39
40 TransportContext(
41 SignalStrategy* signal_strategy,
42 scoped_ptr<PortAllocatorFactory> port_allocator_factory,
43 const NetworkSettings& network_settings,
44 TransportRole role);
45
46 // Prepares to create new PortAllocator instances. It may be called while
47 // connection is being negotiated to minimize the chance that the following
48 // CreatePortAllocator() will be blocking.
49 void Prepare();
50
51 // Creates new PortAllocator making sure that it has correct STUN and TURN
52 // information.
53 void CreatePortAllocator(const CreatePortAllocatorCallback& callback);
54
55 const NetworkSettings& network_settings() { return network_settings_; }
56 TransportRole role() { return role_; }
57
58 private:
59 friend class base::RefCountedThreadSafe<TransportContext>;
60
61 ~TransportContext();
62
63 void EnsureFreshJingleInfo();
64 void OnJingleInfo(const std::string& relay_token,
65 const std::vector<std::string>& relay_hosts,
66 const std::vector<rtc::SocketAddress>& stun_hosts);
67
68 scoped_ptr<cricket::PortAllocator> CreatePortAllocatorInternal();
69
70 SignalStrategy* signal_strategy_;
71 scoped_ptr<PortAllocatorFactory> port_allocator_factory_;
72 NetworkSettings network_settings_;
73 TransportRole role_;
74
75 base::TimeTicks last_jingle_info_update_time_;
76 scoped_ptr<JingleInfoRequest> jingle_info_request_;
77
78 std::string relay_token_;
79 std::vector<std::string> relay_hosts_;
80 std::vector<rtc::SocketAddress> stun_hosts_;
81
82 // When there is an active |jingle_info_request_| stores list of callbacks to
83 // be called once the |jingle_info_request_| is finished.
84 std::list<CreatePortAllocatorCallback> pending_port_allocator_requests_;
85
86 DISALLOW_COPY_AND_ASSIGN(TransportContext);
87 };
88
89 } // namespace protocol
90 } // namespace remoting
91
92 #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