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

Side by Side Diff: remoting/protocol/ice_transport.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/fake_connection_to_host.cc ('k') | remoting/protocol/ice_transport.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_ICE_TRANSPORT_H_ 5 #ifndef REMOTING_PROTOCOL_ICE_TRANSPORT_H_
6 #define REMOTING_PROTOCOL_ICE_TRANSPORT_H_ 6 #define REMOTING_PROTOCOL_ICE_TRANSPORT_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h" 13 #include "base/timer/timer.h"
14 #include "remoting/protocol/datagram_channel_factory.h" 14 #include "remoting/protocol/datagram_channel_factory.h"
15 #include "remoting/protocol/ice_transport_channel.h" 15 #include "remoting/protocol/ice_transport_channel.h"
16 #include "remoting/protocol/jingle_messages.h" 16 #include "remoting/protocol/jingle_messages.h"
17 #include "remoting/protocol/transport.h" 17 #include "remoting/protocol/transport.h"
18 18
19 namespace remoting { 19 namespace remoting {
20 namespace protocol { 20 namespace protocol {
21 21
22 class ChannelMultiplexer; 22 class ChannelMultiplexer;
23 class PseudoTcpChannelFactory; 23 class PseudoTcpChannelFactory;
24 class SecureChannelFactory; 24 class SecureChannelFactory;
25 25
26 class IceTransport : public Transport, 26 class IceTransport : public Transport,
27 public IceTransportChannel::Delegate, 27 public IceTransportChannel::Delegate,
28 public DatagramChannelFactory { 28 public DatagramChannelFactory {
29 public: 29 public:
30 // |port_allocator| must outlive the session. 30 // |transport_context| must outlive the session.
31 IceTransport(cricket::PortAllocator* port_allocator, 31 explicit IceTransport(scoped_refptr<TransportContext> transport_context);
32 const NetworkSettings& network_settings,
33 TransportRole role);
34 ~IceTransport() override; 32 ~IceTransport() override;
35 33
36 // Returns a closure that must be called before transport channels start
37 // connecting .
38 base::Closure GetCanStartClosure();
39
40 // Transport interface. 34 // Transport interface.
41 void Start(EventHandler* event_handler, 35 void Start(EventHandler* event_handler,
42 Authenticator* authenticator) override; 36 Authenticator* authenticator) override;
43 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; 37 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
44 StreamChannelFactory* GetStreamChannelFactory() override; 38 StreamChannelFactory* GetStreamChannelFactory() override;
45 StreamChannelFactory* GetMultiplexedChannelFactory() override; 39 StreamChannelFactory* GetMultiplexedChannelFactory() override;
46 40
47 private: 41 private:
48 typedef std::map<std::string, IceTransportChannel*> ChannelsMap; 42 typedef std::map<std::string, IceTransportChannel*> ChannelsMap;
49 43
50 void OnCanStart();
51
52 // DatagramChannelFactory interface. 44 // DatagramChannelFactory interface.
53 void CreateChannel(const std::string& name, 45 void CreateChannel(const std::string& name,
54 const ChannelCreatedCallback& callback) override; 46 const ChannelCreatedCallback& callback) override;
55 void CancelChannelCreation(const std::string& name) override; 47 void CancelChannelCreation(const std::string& name) override;
56 48
57 // Passes transport info to a new |channel| in case it was received before the 49 // Passes transport info to a new |channel| in case it was received before the
58 // channel was created. 50 // channel was created.
59 void AddPendingRemoteTransportInfo(IceTransportChannel* channel); 51 void AddPendingRemoteTransportInfo(IceTransportChannel* channel);
60 52
61 // IceTransportChannel::Delegate interface. 53 // IceTransportChannel::Delegate interface.
62 void OnTransportIceCredentials(IceTransportChannel* transport, 54 void OnTransportIceCredentials(IceTransportChannel* transport,
63 const std::string& ufrag, 55 const std::string& ufrag,
64 const std::string& password) override; 56 const std::string& password) override;
65 void OnTransportCandidate(IceTransportChannel* transport, 57 void OnTransportCandidate(IceTransportChannel* transport,
66 const cricket::Candidate& candidate) override; 58 const cricket::Candidate& candidate) override;
67 void OnTransportRouteChange(IceTransportChannel* transport, 59 void OnTransportRouteChange(IceTransportChannel* transport,
68 const TransportRoute& route) override; 60 const TransportRoute& route) override;
69 void OnTransportFailed(IceTransportChannel* transport) override; 61 void OnTransportFailed(IceTransportChannel* transport) override;
70 void OnTransportDeleted(IceTransportChannel* transport) override; 62 void OnTransportDeleted(IceTransportChannel* transport) override;
71 63
72 // Creates empty |pending_transport_info_message_| and schedules timer for 64 // Creates empty |pending_transport_info_message_| and schedules timer for
73 // SentTransportInfo() to sent the message later. 65 // SentTransportInfo() to sent the message later.
74 void EnsurePendingTransportInfoMessage(); 66 void EnsurePendingTransportInfoMessage();
75 67
76 // Sends transport-info message with candidates from |pending_candidates_|. 68 // Sends transport-info message with candidates from |pending_candidates_|.
77 void SendTransportInfo(); 69 void SendTransportInfo();
78 70
79 cricket::PortAllocator* port_allocator_; 71 scoped_refptr<TransportContext> transport_context_;
80 NetworkSettings network_settings_;
81 TransportRole role_;
82
83 bool can_start_ = false;
84 72
85 Transport::EventHandler* event_handler_ = nullptr; 73 Transport::EventHandler* event_handler_ = nullptr;
86 74
87 ChannelsMap channels_; 75 ChannelsMap channels_;
88 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; 76 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_;
89 scoped_ptr<SecureChannelFactory> secure_channel_factory_; 77 scoped_ptr<SecureChannelFactory> secure_channel_factory_;
90 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; 78 scoped_ptr<ChannelMultiplexer> channel_multiplexer_;
91 79
92 // Pending remote transport info received before the local channels were 80 // Pending remote transport info received before the local channels were
93 // created. 81 // created.
94 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_; 82 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_;
95 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_; 83 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_;
96 84
97 scoped_ptr<IceTransportInfo> pending_transport_info_message_; 85 scoped_ptr<IceTransportInfo> pending_transport_info_message_;
98 base::OneShotTimer transport_info_timer_; 86 base::OneShotTimer transport_info_timer_;
99 87
100 base::WeakPtrFactory<IceTransport> weak_factory_; 88 base::WeakPtrFactory<IceTransport> weak_factory_;
101 89
102 DISALLOW_COPY_AND_ASSIGN(IceTransport); 90 DISALLOW_COPY_AND_ASSIGN(IceTransport);
103 }; 91 };
104 92
93 class IceTransportFactory : public TransportFactory {
94 public:
95 IceTransportFactory(scoped_refptr<TransportContext> transport_context);
96 ~IceTransportFactory() override;
97
98 // TransportFactory interface.
99 scoped_ptr<Transport> CreateTransport() override;
100
101 private:
102 scoped_refptr<TransportContext> transport_context_;
103
104 DISALLOW_COPY_AND_ASSIGN(IceTransportFactory);
105 };
106
105 } // namespace protocol 107 } // namespace protocol
106 } // namespace remoting 108 } // namespace remoting
107 109
108 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_ 110 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_
109 111
OLDNEW
« no previous file with comments | « remoting/protocol/fake_connection_to_host.cc ('k') | remoting/protocol/ice_transport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698