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