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

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

Issue 551173004: Move PseudoTCP and channel auth out of LibjingleTransportFactory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@clean_dgrams
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 virtual void OnTransportRouteChange(Transport* transport, 80 virtual void OnTransportRouteChange(Transport* transport,
81 const TransportRoute& route) = 0; 81 const TransportRoute& route) = 0;
82 82
83 // Called when when the transport has failed to connect or reconnect. 83 // Called when when the transport has failed to connect or reconnect.
84 virtual void OnTransportFailed(Transport* transport) = 0; 84 virtual void OnTransportFailed(Transport* transport) = 0;
85 85
86 // Called when the transport is about to be deleted. 86 // Called when the transport is about to be deleted.
87 virtual void OnTransportDeleted(Transport* transport) = 0; 87 virtual void OnTransportDeleted(Transport* transport) = 0;
88 }; 88 };
89 89
90 typedef base::Callback<void(scoped_ptr<net::Socket>)> ConnectedCallback;
91
90 Transport() {} 92 Transport() {}
91 virtual ~Transport() {} 93 virtual ~Transport() {}
92 94
93 // Intialize the transport with the specified parameters. 95 // Intialize the transport with the specified parameters.
94 // |authenticator| is used to secure and authenticate the connection.
95 virtual void Initialize(const std::string& name, 96 virtual void Initialize(const std::string& name,
96 Transport::EventHandler* event_handler, 97 Transport::EventHandler* event_handler) = 0;
97 scoped_ptr<ChannelAuthenticator> authenticator) = 0; 98
99 virtual void Connect(const ConnectedCallback& callback) = 0;
Wez 2014/09/10 02:29:27 nit: Add a comment to clarify where the difference
Sergey Ulanov 2014/09/10 21:50:59 Actually we no longer need them separate. Removed
98 100
99 // Adds |candidate| received from the peer. 101 // Adds |candidate| received from the peer.
100 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0; 102 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0;
101 103
102 // Name of the channel. It is used to identify the channel and 104 // Name of the channel. It is used to identify the channel and
103 // disambiguate candidates it generates from candidates generated by 105 // disambiguate candidates it generates from candidates generated by
104 // parallel connections. 106 // parallel connections.
105 virtual const std::string& name() const = 0; 107 virtual const std::string& name() const = 0;
106 108
107 // Returns true if the channel is already connected. 109 // Returns true if the channel is already connected.
108 virtual bool is_connected() const = 0; 110 virtual bool is_connected() const = 0;
109 111
110 private: 112 private:
111 DISALLOW_COPY_AND_ASSIGN(Transport); 113 DISALLOW_COPY_AND_ASSIGN(Transport);
112 }; 114 };
113 115
114 class StreamTransport : public Transport {
115 public:
116 typedef base::Callback<void(scoped_ptr<net::StreamSocket>)> ConnectedCallback;
117
118 StreamTransport() { }
119 virtual ~StreamTransport() { }
120
121 virtual void Connect(const ConnectedCallback& callback) = 0;
122
123 private:
124 DISALLOW_COPY_AND_ASSIGN(StreamTransport);
125 };
126
127 class DatagramTransport : public Transport {
128 public:
129 typedef base::Callback<void(scoped_ptr<net::Socket>)> ConnectedCallback;
130
131 DatagramTransport() { }
132 virtual ~DatagramTransport() { }
133
134 virtual void Connect(const ConnectedCallback& callback) = 0;
135
136 private:
137 DISALLOW_COPY_AND_ASSIGN(DatagramTransport);
138 };
139
140 class TransportFactory { 116 class TransportFactory {
141 public: 117 public:
142 TransportFactory() { } 118 TransportFactory() { }
143 virtual ~TransportFactory() { } 119 virtual ~TransportFactory() { }
144 120
145 // Called to notify transport factory that a new transport might be created 121 // Called to notify transport factory that a new transport might be created
146 // soon, e.g. when a new session is being created. Implementation may use it 122 // soon, e.g. when a new session is being created. Implementation may use it
147 // to start asynchronous preparation, e.g. fetch a new relay token if 123 // to start asynchronous preparation, e.g. fetch a new relay token if
148 // necessary while the session is being authenticated. 124 // necessary while the session is being authenticated.
149 virtual void PrepareTokens() = 0; 125 virtual void PrepareTokens() = 0;
150 126
151 virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0; 127 virtual scoped_ptr<Transport> CreateTransport() = 0;
152 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0;
153 128
154 private: 129 private:
155 DISALLOW_COPY_AND_ASSIGN(TransportFactory); 130 DISALLOW_COPY_AND_ASSIGN(TransportFactory);
156 }; 131 };
157 132
158 } // namespace protocol 133 } // namespace protocol
159 } // namespace remoting 134 } // namespace remoting
160 135
161 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ 136 #endif // REMOTING_PROTOCOL_TRANSPORT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698