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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace net { | 37 namespace net { |
38 class Socket; | 38 class Socket; |
39 class StreamSocket; | 39 class StreamSocket; |
40 } // namespace net | 40 } // namespace net |
41 | 41 |
42 namespace remoting { | 42 namespace remoting { |
43 namespace protocol { | 43 namespace protocol { |
44 | 44 |
45 class ChannelAuthenticator; | 45 class ChannelAuthenticator; |
46 struct TransportConfig; | |
47 | 46 |
48 struct TransportRoute { | 47 struct TransportRoute { |
49 enum RouteType { | 48 enum RouteType { |
50 DIRECT, | 49 DIRECT, |
51 STUN, | 50 STUN, |
52 RELAY, | 51 RELAY, |
53 }; | 52 }; |
54 | 53 |
55 // Helper method to get string representation of the type. | 54 // Helper method to get string representation of the type. |
56 static std::string GetTypeString(RouteType type); | 55 static std::string GetTypeString(RouteType type); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 143 |
145 private: | 144 private: |
146 DISALLOW_COPY_AND_ASSIGN(DatagramTransport); | 145 DISALLOW_COPY_AND_ASSIGN(DatagramTransport); |
147 }; | 146 }; |
148 | 147 |
149 class TransportFactory { | 148 class TransportFactory { |
150 public: | 149 public: |
151 TransportFactory() { } | 150 TransportFactory() { } |
152 virtual ~TransportFactory() { } | 151 virtual ~TransportFactory() { } |
153 | 152 |
154 // Sets configuration for the transports created by this factory. | 153 // Called to notify transport factory that a new transport might be created |
155 virtual void SetTransportConfig(const TransportConfig& config) = 0; | 154 // soon, e.g. when a new session is being created. Implementation may use it |
| 155 // to start asynchronous preparation, e.g. fetch a new relay token if |
| 156 // necessary while the session is being authenticated. |
| 157 virtual void PrepareTokens() = 0; |
156 | 158 |
157 virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0; | 159 virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0; |
158 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0; | 160 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0; |
159 | 161 |
160 private: | 162 private: |
161 DISALLOW_COPY_AND_ASSIGN(TransportFactory); | 163 DISALLOW_COPY_AND_ASSIGN(TransportFactory); |
162 }; | 164 }; |
163 | 165 |
164 } // namespace protocol | 166 } // namespace protocol |
165 } // namespace remoting | 167 } // namespace remoting |
166 | 168 |
167 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ | 169 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ |
OLD | NEW |