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

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

Issue 1545743002: Move ownership of Transport out of Session. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_not_pass_client
Patch Set: Created 4 years, 12 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/ice_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 class EventHandler {
31 public:
32 // Called when transport route changes.
33 virtual void OnIceTransportRouteChange(const std::string& channel_name,
34 const TransportRoute& route) = 0;
35
36 // Called when there is an error connecting the session.
37 virtual void OnIceTransportError(ErrorCode error) = 0;
38 };
39
30 // |transport_context| must outlive the session. 40 // |transport_context| must outlive the session.
31 explicit IceTransport(scoped_refptr<TransportContext> transport_context); 41 IceTransport(scoped_refptr<TransportContext> transport_context,
42 EventHandler* event_handler);
32 ~IceTransport() override; 43 ~IceTransport() override;
33 44
45 StreamChannelFactory* GetStreamChannelFactory();
46 StreamChannelFactory* GetMultiplexedChannelFactory();
47
34 // Transport interface. 48 // Transport interface.
35 void Start(EventHandler* event_handler, 49 void Start(Authenticator* authenticator,
36 Authenticator* authenticator) override; 50 SendTransportInfoCallback send_transport_info_callback) override;
37 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override; 51 bool ProcessTransportInfo(buzz::XmlElement* transport_info) override;
38 StreamChannelFactory* GetStreamChannelFactory() override;
39 StreamChannelFactory* GetMultiplexedChannelFactory() override;
40 52
41 private: 53 private:
42 typedef std::map<std::string, IceTransportChannel*> ChannelsMap; 54 typedef std::map<std::string, IceTransportChannel*> ChannelsMap;
43 55
44 // DatagramChannelFactory interface. 56 // DatagramChannelFactory interface.
45 void CreateChannel(const std::string& name, 57 void CreateChannel(const std::string& name,
46 const ChannelCreatedCallback& callback) override; 58 const ChannelCreatedCallback& callback) override;
47 void CancelChannelCreation(const std::string& name) override; 59 void CancelChannelCreation(const std::string& name) override;
48 60
49 // Passes transport info to a new |channel| in case it was received before the 61 // Passes transport info to a new |channel| in case it was received before the
50 // channel was created. 62 // channel was created.
51 void AddPendingRemoteTransportInfo(IceTransportChannel* channel); 63 void AddPendingRemoteTransportInfo(IceTransportChannel* channel);
52 64
53 // IceTransportChannel::Delegate interface. 65 // IceTransportChannel::Delegate interface.
54 void OnTransportIceCredentials(IceTransportChannel* transport, 66 void OnChannelIceCredentials(IceTransportChannel* transport,
55 const std::string& ufrag, 67 const std::string& ufrag,
56 const std::string& password) override; 68 const std::string& password) override;
57 void OnTransportCandidate(IceTransportChannel* transport, 69 void OnChannelCandidate(IceTransportChannel* transport,
58 const cricket::Candidate& candidate) override; 70 const cricket::Candidate& candidate) override;
59 void OnTransportRouteChange(IceTransportChannel* transport, 71 void OnChannelRouteChange(IceTransportChannel* transport,
60 const TransportRoute& route) override; 72 const TransportRoute& route) override;
61 void OnTransportFailed(IceTransportChannel* transport) override; 73 void OnChannelFailed(IceTransportChannel* transport) override;
62 void OnTransportDeleted(IceTransportChannel* transport) override; 74 void OnChannelDeleted(IceTransportChannel* transport) override;
63 75
64 // Creates empty |pending_transport_info_message_| and schedules timer for 76 // Creates empty |pending_transport_info_message_| and schedules timer for
65 // SentTransportInfo() to sent the message later. 77 // SentTransportInfo() to sent the message later.
66 void EnsurePendingTransportInfoMessage(); 78 void EnsurePendingTransportInfoMessage();
67 79
68 // Sends transport-info message with candidates from |pending_candidates_|. 80 // Sends transport-info message with candidates from |pending_candidates_|.
69 void SendTransportInfo(); 81 void SendTransportInfo();
70 82
71 scoped_refptr<TransportContext> transport_context_; 83 scoped_refptr<TransportContext> transport_context_;
84 EventHandler* event_handler_;
72 85
73 Transport::EventHandler* event_handler_ = nullptr; 86 SendTransportInfoCallback send_transport_info_callback_;
74 87
75 ChannelsMap channels_; 88 ChannelsMap channels_;
76 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_; 89 scoped_ptr<PseudoTcpChannelFactory> pseudotcp_channel_factory_;
77 scoped_ptr<SecureChannelFactory> secure_channel_factory_; 90 scoped_ptr<SecureChannelFactory> secure_channel_factory_;
78 scoped_ptr<ChannelMultiplexer> channel_multiplexer_; 91 scoped_ptr<ChannelMultiplexer> channel_multiplexer_;
79 92
80 // Pending remote transport info received before the local channels were 93 // Pending remote transport info received before the local channels were
81 // created. 94 // created.
82 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_; 95 std::list<IceTransportInfo::IceCredentials> pending_remote_ice_credentials_;
83 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_; 96 std::list<IceTransportInfo::NamedCandidate> pending_remote_candidates_;
84 97
85 scoped_ptr<IceTransportInfo> pending_transport_info_message_; 98 scoped_ptr<IceTransportInfo> pending_transport_info_message_;
86 base::OneShotTimer transport_info_timer_; 99 base::OneShotTimer transport_info_timer_;
87 100
88 base::WeakPtrFactory<IceTransport> weak_factory_; 101 base::WeakPtrFactory<IceTransport> weak_factory_;
89 102
90 DISALLOW_COPY_AND_ASSIGN(IceTransport); 103 DISALLOW_COPY_AND_ASSIGN(IceTransport);
91 }; 104 };
92 105
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
107 } // namespace protocol 106 } // namespace protocol
108 } // namespace remoting 107 } // namespace remoting
109 108
110 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_ 109 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_H_
111 110
OLDNEW
« no previous file with comments | « remoting/protocol/ice_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