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

Unified 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, 2 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/ice_transport_channel.h
diff --git a/remoting/protocol/ice_transport_channel.h b/remoting/protocol/ice_transport_channel.h
new file mode 100644
index 0000000000000000000000000000000000000000..ccaf106f6bad41149457b3da4b4825e9b5ae205a
--- /dev/null
+++ b/remoting/protocol/ice_transport_channel.h
@@ -0,0 +1,138 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_PROTOCOL_ICE_TRANSPORT_CHANNEL_H_
+#define REMOTING_PROTOCOL_ICE_TRANSPORT_CHANNEL_H_
+
+#include <string>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+#include "base/threading/thread_checker.h"
+#include "base/timer/timer.h"
+#include "remoting/protocol/network_settings.h"
+#include "remoting/protocol/transport.h"
+#include "third_party/webrtc/base/sigslot.h"
+
+namespace cricket {
+class Candidate;
+class P2PTransportChannel;
+class PortAllocator;
+class TransportChannel;
+class TransportChannelImpl;
+} // namespace cricket
+
+namespace remoting {
+namespace protocol {
+
+class IceTransportChannel : public sigslot::has_slots<> {
+ public:
+ class Delegate {
+ public:
+ Delegate() {};
+ virtual ~Delegate() {};
+
+ // Called to pass ICE credentials to the session. Used only for STANDARD
+ // version of ICE, see SetIceVersion().
+ virtual void OnTransportIceCredentials(IceTransportChannel* transport,
+ const std::string& ufrag,
+ const std::string& password) = 0;
+
+ // Called when the transport generates a new candidate that needs
+ // to be passed to the AddRemoteCandidate() method on the remote
+ // end of the connection.
+ virtual void OnTransportCandidate(IceTransportChannel* transport,
+ const cricket::Candidate& candidate) = 0;
+
+ // Called when transport route changes. Can be called even before
+ // the transport is connected.
+ virtual void OnTransportRouteChange(IceTransportChannel* transport,
+ const TransportRoute& route) = 0;
+
+ // Called when when the transport has failed to connect or reconnect.
+ virtual void OnTransportFailed(IceTransportChannel* transport) = 0;
+
+ // Called when the transport is about to be deleted.
+ virtual void OnTransportDeleted(IceTransportChannel* transport) = 0;
+ };
+
+ typedef base::Callback<void(scoped_ptr<P2PDatagramSocket>)> ConnectedCallback;
+
+ IceTransportChannel(cricket::PortAllocator* port_allocator,
+ const NetworkSettings& network_settings,
+ TransportRole role);
+ ~IceTransportChannel() override;
+
+ // Called by IceTransportSession when it has fresh Jingle info.
+ void OnCanStart();
+
+ // Connects the channel and calls the |callback| after that.
+ void Connect(const std::string& name,
+ Delegate* delegate,
+ const ConnectedCallback& callback);
+
+ // Sets remote ICE credentials.
+ void SetRemoteCredentials(const std::string& ufrag,
+ const std::string& password);
+
+ // Adds |candidate| received from the peer.
+ void AddRemoteCandidate(const cricket::Candidate& candidate);
+
+ // Name of the channel. Used to identify the channel and disambiguate
+ // candidates it generates from candidates generated by parallel connections.
+ const std::string& name() const;
+
+ // Returns true if the channel is already connected.
+ bool is_connected() const;
+
+ private:
+ void DoStart();
+ void NotifyConnected();
+
+ // Signal handlers for cricket::TransportChannel.
+ void OnCandidateGathered(cricket::TransportChannelImpl* channel,
+ const cricket::Candidate& candidate);
+ void OnRouteChange(cricket::TransportChannel* channel,
+ const cricket::Candidate& candidate);
+ void OnReceivingState(cricket::TransportChannel* channel);
+ void OnWritableState(cricket::TransportChannel* channel);
+
+ // Callback for TransportChannelSocketAdapter to notify when the socket is
+ // destroyed.
+ void OnChannelDestroyed();
+
+ void NotifyRouteChanged();
+
+ // Tries to connect by restarting ICE. Called by |reconnect_timer_|.
+ void TryReconnect();
+
+ cricket::PortAllocator* port_allocator_;
+ NetworkSettings network_settings_;
+ TransportRole role_;
+
+ std::string name_;
+ Delegate* delegate_;
+ ConnectedCallback callback_;
+ std::string ice_username_fragment_;
+
+ bool can_start_;
+
+ std::string remote_ice_username_fragment_;
+ std::string remote_ice_password_;
+ std::list<cricket::Candidate> pending_candidates_;
+ scoped_ptr<cricket::P2PTransportChannel> channel_;
+ int connect_attempts_left_;
+ base::RepeatingTimer reconnect_timer_;
+
+ base::ThreadChecker thread_checker_;
+
+ base::WeakPtrFactory<IceTransportChannel> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(IceTransportChannel);
+};
+
+} // namespace protocol
+} // namespace remoting
+
+#endif // REMOTING_PROTOCOL_ICE_TRANSPORT_CHANNEL_H_
« 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