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

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

Issue 1412313006: Remove remoting::protocol::Transport interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@transport_session.h
Patch Set: Created 5 years, 1 month 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/channel_socket_adapter.h ('k') | remoting/protocol/ice_transport_channel.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_ICE_TRANSPORT_CHANNEL_H_
6 #define REMOTING_PROTOCOL_ICE_TRANSPORT_CHANNEL_H_
7
8 #include <string>
9
10 #include "base/callback_forward.h"
11 #include "base/macros.h"
12 #include "base/threading/thread_checker.h"
13 #include "base/timer/timer.h"
14 #include "remoting/protocol/network_settings.h"
15 #include "remoting/protocol/transport.h"
16 #include "third_party/webrtc/base/sigslot.h"
17
18 namespace cricket {
19 class Candidate;
20 class P2PTransportChannel;
21 class PortAllocator;
22 class TransportChannel;
23 class TransportChannelImpl;
24 } // namespace cricket
25
26 namespace remoting {
27 namespace protocol {
28
29 class IceTransportChannel : public sigslot::has_slots<> {
30 public:
31 class Delegate {
32 public:
33 Delegate() {};
34 virtual ~Delegate() {};
35
36 // Called to pass ICE credentials to the session. Used only for STANDARD
37 // version of ICE, see SetIceVersion().
38 virtual void OnTransportIceCredentials(IceTransportChannel* transport,
39 const std::string& ufrag,
40 const std::string& password) = 0;
41
42 // Called when the transport generates a new candidate that needs
43 // to be passed to the AddRemoteCandidate() method on the remote
44 // end of the connection.
45 virtual void OnTransportCandidate(IceTransportChannel* transport,
46 const cricket::Candidate& candidate) = 0;
47
48 // Called when transport route changes. Can be called even before
49 // the transport is connected.
50 virtual void OnTransportRouteChange(IceTransportChannel* transport,
51 const TransportRoute& route) = 0;
52
53 // Called when when the transport has failed to connect or reconnect.
54 virtual void OnTransportFailed(IceTransportChannel* transport) = 0;
55
56 // Called when the transport is about to be deleted.
57 virtual void OnTransportDeleted(IceTransportChannel* transport) = 0;
58 };
59
60 typedef base::Callback<void(scoped_ptr<P2PDatagramSocket>)> ConnectedCallback;
61
62 IceTransportChannel(cricket::PortAllocator* port_allocator,
63 const NetworkSettings& network_settings,
64 TransportRole role);
65 ~IceTransportChannel() override;
66
67 // Called by IceTransportSession when it has fresh Jingle info.
68 void OnCanStart();
69
70 // Connects the channel and calls the |callback| after that.
71 void Connect(const std::string& name,
72 Delegate* delegate,
73 const ConnectedCallback& callback);
74
75 // Sets remote ICE credentials.
76 void SetRemoteCredentials(const std::string& ufrag,
77 const std::string& password);
78
79 // Adds |candidate| received from the peer.
80 void AddRemoteCandidate(const cricket::Candidate& candidate);
81
82 // Name of the channel. Used to identify the channel and disambiguate
83 // candidates it generates from candidates generated by parallel connections.
84 const std::string& name() const;
85
86 // Returns true if the channel is already connected.
87 bool is_connected() const;
88
89 private:
90 void DoStart();
91 void NotifyConnected();
92
93 // Signal handlers for cricket::TransportChannel.
94 void OnCandidateGathered(cricket::TransportChannelImpl* channel,
95 const cricket::Candidate& candidate);
96 void OnRouteChange(cricket::TransportChannel* channel,
97 const cricket::Candidate& candidate);
98 void OnReceivingState(cricket::TransportChannel* channel);
99 void OnWritableState(cricket::TransportChannel* channel);
100
101 // Callback for TransportChannelSocketAdapter to notify when the socket is
102 // destroyed.
103 void OnChannelDestroyed();
104
105 void NotifyRouteChanged();
106
107 // Tries to connect by restarting ICE. Called by |reconnect_timer_|.
108 void TryReconnect();
109
110 cricket::PortAllocator* port_allocator_;
111 NetworkSettings network_settings_;
112 TransportRole role_;
113
114 std::string name_;
115 Delegate* delegate_;
116 ConnectedCallback callback_;
117 std::string ice_username_fragment_;
118
119 bool can_start_;
120
121 std::string remote_ice_username_fragment_;
122 std::string remote_ice_password_;
123 std::list<cricket::Candidate> pending_candidates_;
124 scoped_ptr<cricket::P2PTransportChannel> channel_;
125 int connect_attempts_left_;
126 base::RepeatingTimer reconnect_timer_;
127
128 base::ThreadChecker thread_checker_;
129
130 base::WeakPtrFactory<IceTransportChannel> weak_factory_;
131
132 DISALLOW_COPY_AND_ASSIGN(IceTransportChannel);
133 };
134
135 } // namespace protocol
136 } // namespace remoting
137
138 #endif // REMOTING_PROTOCOL_ICE_TRANSPORT_CHANNEL_H_
OLDNEW
« no previous file with comments | « remoting/protocol/channel_socket_adapter.h ('k') | remoting/protocol/ice_transport_channel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698