OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 // This file defines the interface for peer-to-peer transport. There | 5 // This file defines the interface for peer-to-peer transport. There |
6 // are two types of transport: StreamTransport and DatagramTransport. | 6 // are two types of transport: StreamTransport and DatagramTransport. |
7 // They must both be created using TransportFactory instances and they | 7 // They must both be created using TransportFactory instances and they |
8 // provide the same interface, except that one should be used for | 8 // provide the same interface, except that one should be used for |
9 // reliable stream connection and the other one for unreliable | 9 // reliable stream connection and the other one for unreliable |
10 // datagram connection. The Transport interface itself doesn't provide | 10 // datagram connection. The Transport interface itself doesn't provide |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 #ifndef REMOTING_PROTOCOL_TRANSPORT_H_ | 22 #ifndef REMOTING_PROTOCOL_TRANSPORT_H_ |
23 #define REMOTING_PROTOCOL_TRANSPORT_H_ | 23 #define REMOTING_PROTOCOL_TRANSPORT_H_ |
24 | 24 |
25 #include <string> | 25 #include <string> |
26 | 26 |
27 #include "base/basictypes.h" | 27 #include "base/basictypes.h" |
28 #include "base/callback_forward.h" | 28 #include "base/callback_forward.h" |
29 #include "base/memory/scoped_ptr.h" | 29 #include "base/memory/scoped_ptr.h" |
30 #include "base/threading/non_thread_safe.h" | 30 #include "base/threading/non_thread_safe.h" |
| 31 #include "net/base/ip_endpoint.h" |
31 | 32 |
32 namespace cricket { | 33 namespace cricket { |
33 class Candidate; | 34 class Candidate; |
34 } // namespace cricket | 35 } // namespace cricket |
35 | 36 |
36 namespace net { | 37 namespace net { |
37 class Socket; | 38 class Socket; |
38 class StreamSocket; | 39 class StreamSocket; |
39 } // namespace net | 40 } // namespace net |
40 | 41 |
41 namespace remoting { | 42 namespace remoting { |
42 namespace protocol { | 43 namespace protocol { |
43 | 44 |
44 class ChannelAuthenticator; | 45 class ChannelAuthenticator; |
45 struct TransportConfig; | 46 struct TransportConfig; |
46 | 47 |
| 48 struct TransportRoute { |
| 49 enum RouteType { |
| 50 DIRECT, |
| 51 STUN, |
| 52 RELAY, |
| 53 }; |
| 54 |
| 55 RouteType type; |
| 56 net::IPEndPoint remote_address; |
| 57 net::IPEndPoint local_address; |
| 58 }; |
| 59 |
47 class Transport : public base::NonThreadSafe { | 60 class Transport : public base::NonThreadSafe { |
48 public: | 61 public: |
49 class EventHandler { | 62 class EventHandler { |
50 public: | 63 public: |
51 EventHandler() {}; | 64 EventHandler() {}; |
52 virtual ~EventHandler() {}; | 65 virtual ~EventHandler() {}; |
53 | 66 |
54 // Called when the transport generates a new candidate that needs | 67 // Called when the transport generates a new candidate that needs |
55 // to be passed to the AddRemoteCandidate() method on the remote | 68 // to be passed to the AddRemoteCandidate() method on the remote |
56 // end of the connection. | 69 // end of the connection. |
57 virtual void OnTransportCandidate(Transport* transport, | 70 virtual void OnTransportCandidate(Transport* transport, |
58 const cricket::Candidate& candidate) = 0; | 71 const cricket::Candidate& candidate) = 0; |
59 | 72 |
| 73 // Called when transport route changes. Can be called even before |
| 74 // the transport is connected. |
| 75 virtual void OnTransportRouteChange(Transport* transport, |
| 76 const TransportRoute& route) = 0; |
| 77 |
60 // Called when the transport is about to be deleted. | 78 // Called when the transport is about to be deleted. |
61 virtual void OnTransportDeleted(Transport* transport) = 0; | 79 virtual void OnTransportDeleted(Transport* transport) = 0; |
62 }; | 80 }; |
63 | 81 |
64 Transport() {} | 82 Transport() {} |
65 virtual ~Transport() {} | 83 virtual ~Transport() {} |
66 | 84 |
67 // Intialize the transport with the specified parameters. | 85 // Intialize the transport with the specified parameters. |
68 // |authenticator| is used to secure and authenticate the connection. | 86 // |authenticator| is used to secure and authenticate the connection. |
69 virtual void Initialize(const std::string& name, | 87 virtual void Initialize(const std::string& name, |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0; | 139 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0; |
122 | 140 |
123 private: | 141 private: |
124 DISALLOW_COPY_AND_ASSIGN(TransportFactory); | 142 DISALLOW_COPY_AND_ASSIGN(TransportFactory); |
125 }; | 143 }; |
126 | 144 |
127 } // namespace protocol | 145 } // namespace protocol |
128 } // namespace remoting | 146 } // namespace remoting |
129 | 147 |
130 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ | 148 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ |
OLD | NEW |