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_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 class MessageChannelFactory; |
25 | 26 |
26 class IceTransport : public Transport, | 27 class IceTransport : public Transport, |
27 public IceTransportChannel::Delegate, | 28 public IceTransportChannel::Delegate, |
28 public DatagramChannelFactory { | 29 public DatagramChannelFactory { |
29 public: | 30 public: |
30 class EventHandler { | 31 class EventHandler { |
31 public: | 32 public: |
32 // Called when transport route changes. | 33 // Called when transport route changes. |
33 virtual void OnIceTransportRouteChange(const std::string& channel_name, | 34 virtual void OnIceTransportRouteChange(const std::string& channel_name, |
34 const TransportRoute& route) = 0; | 35 const TransportRoute& route) = 0; |
35 | 36 |
36 // Called when there is an error connecting the session. | 37 // Called when there is an error connecting the session. |
37 virtual void OnIceTransportError(ErrorCode error) = 0; | 38 virtual void OnIceTransportError(ErrorCode error) = 0; |
38 }; | 39 }; |
39 | 40 |
40 // |transport_context| must outlive the session. | 41 // |transport_context| must outlive the session. |
41 IceTransport(scoped_refptr<TransportContext> transport_context, | 42 IceTransport(scoped_refptr<TransportContext> transport_context, |
42 EventHandler* event_handler); | 43 EventHandler* event_handler); |
43 ~IceTransport() override; | 44 ~IceTransport() override; |
44 | 45 |
45 StreamChannelFactory* GetStreamChannelFactory(); | 46 MessageChannelFactory* GetChannelFactory(); |
46 StreamChannelFactory* GetMultiplexedChannelFactory(); | 47 MessageChannelFactory* GetMultiplexedChannelFactory(); |
47 | 48 |
48 // Transport interface. | 49 // Transport interface. |
49 void Start(Authenticator* authenticator, | 50 void Start(Authenticator* authenticator, |
50 SendTransportInfoCallback send_transport_info_callback) override; | 51 SendTransportInfoCallback send_transport_info_callback) override; |
51 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; | 52 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; |
52 | 53 |
53 private: | 54 private: |
54 typedef std::map<std::string, IceTransportChannel*> ChannelsMap; | 55 typedef std::map<std::string, IceTransportChannel*> ChannelsMap; |
55 | 56 |
56 // DatagramChannelFactory interface. | 57 // DatagramChannelFactory interface. |
(...skipping 16 matching lines...) Expand all Loading... |
73 void OnChannelFailed(IceTransportChannel* transport) override; | 74 void OnChannelFailed(IceTransportChannel* transport) override; |
74 void OnChannelDeleted(IceTransportChannel* transport) override; | 75 void OnChannelDeleted(IceTransportChannel* transport) override; |
75 | 76 |
76 // Creates empty |pending_transport_info_message_| and schedules timer for | 77 // Creates empty |pending_transport_info_message_| and schedules timer for |
77 // SentTransportInfo() to sent the message later. | 78 // SentTransportInfo() to sent the message later. |
78 void EnsurePendingTransportInfoMessage(); | 79 void EnsurePendingTransportInfoMessage(); |
79 | 80 |
80 // Sends transport-info message with candidates from |pending_candidates_|. | 81 // Sends transport-info message with candidates from |pending_candidates_|. |
81 void SendTransportInfo(); | 82 void SendTransportInfo(); |
82 | 83 |
| 84 // Callback passed to StreamMessageChannelFactoryAdapter to handle read/write |
| 85 // errors on the data channels. |
| 86 void OnChannelError(int error); |
| 87 |
83 scoped_refptr<TransportContext> transport_context_; | 88 scoped_refptr<TransportContext> transport_context_; |
84 EventHandler* event_handler_; | 89 EventHandler* event_handler_; |
85 | 90 |
86 SendTransportInfoCallback send_transport_info_callback_; | 91 SendTransportInfoCallback send_transport_info_callback_; |
87 | 92 |
88 ChannelsMap channels_; | 93 ChannelsMap channels_; |
89 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; | 94 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; |
90 scoped_ptr<SecureChannelFactory> secure_channel_factory_; | 95 scoped_ptr<SecureChannelFactory> secure_channel_factory_; |
| 96 scoped_ptr<MessageChannelFactory> message_channel_factory_; |
| 97 |
91 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; | 98 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; |
| 99 scoped_ptr<MessageChannelFactory> mux_channel_factory_; |
92 | 100 |
93 // Pending remote transport info received before the local channels were | 101 // Pending remote transport info received before the local channels were |
94 // created. | 102 // created. |
95 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_; | 103 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_; |
96 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_; | 104 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_; |
97 | 105 |
98 scoped_ptr<IceTransportInfo> pending_transport_info_message_; | 106 scoped_ptr<IceTransportInfo> pending_transport_info_message_; |
99 base::OneShotTimer transport_info_timer_; | 107 base::OneShotTimer transport_info_timer_; |
100 | 108 |
101 base::WeakPtrFactory<IceTransport> weak_factory_; | 109 base::WeakPtrFactory<IceTransport> weak_factory_; |
102 | 110 |
103 DISALLOW_COPY_AND_ASSIGN(IceTransport); | 111 DISALLOW_COPY_AND_ASSIGN(IceTransport); |
104 }; | 112 }; |
105 | 113 |
106 } // namespace protocol | 114 } // namespace protocol |
107 } // namespace remoting | 115 } // namespace remoting |
108 | 116 |
109 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_ | 117 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_ |
110 | 118 |
OLD | NEW |