transport.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2012 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. #ifndef REMOTING_PROTOCOL_TRANSPORT_H_
  5. #define REMOTING_PROTOCOL_TRANSPORT_H_
  6. #include <memory>
  7. #include <string>
  8. #include "base/callback_forward.h"
  9. #include "net/base/ip_endpoint.h"
  10. #include "remoting/protocol/errors.h"
  11. namespace jingle_xmpp {
  12. class XmlElement;
  13. } // namespace jingle_xmpp
  14. namespace remoting {
  15. namespace protocol {
  16. class Authenticator;
  17. enum class TransportRole {
  18. SERVER,
  19. CLIENT,
  20. };
  21. struct TransportRoute {
  22. enum RouteType {
  23. DIRECT,
  24. STUN,
  25. RELAY,
  26. ROUTE_TYPE_MAX = RELAY,
  27. };
  28. // Helper method to get string representation of the type.
  29. static std::string GetTypeString(RouteType type);
  30. TransportRoute();
  31. ~TransportRoute();
  32. RouteType type;
  33. net::IPEndPoint remote_address;
  34. net::IPEndPoint local_address;
  35. };
  36. // Transport represents a P2P connection that consists of one or more channels.
  37. // This interface is used just to send and receive transport-info messages.
  38. // Implementations should provide other methods to send and receive data.
  39. class Transport {
  40. public:
  41. typedef base::RepeatingCallback<void(
  42. std::unique_ptr<jingle_xmpp::XmlElement> transport_info)>
  43. SendTransportInfoCallback;
  44. virtual ~Transport() {}
  45. // Sets the object responsible for delivering outgoing transport-info messages
  46. // to the peer.
  47. virtual void Start(
  48. Authenticator* authenticator,
  49. SendTransportInfoCallback send_transport_info_callback) = 0;
  50. virtual bool ProcessTransportInfo(jingle_xmpp::XmlElement* transport_info) = 0;
  51. };
  52. } // namespace protocol
  53. } // namespace remoting
  54. #endif // REMOTING_PROTOCOL_TRANSPORT_H_