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

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

Issue 570463002: Revert of 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
« no previous file with comments | « remoting/protocol/stream_channel_factory.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
92 Transport() {} 90 Transport() {}
93 virtual ~Transport() {} 91 virtual ~Transport() {}
94 92
95 // Connects the transport and calls the |callback| after that. 93 // Intialize the transport with the specified parameters.
96 virtual void Connect(const std::string& name, 94 // |authenticator| is used to secure and authenticate the connection.
97 Transport::EventHandler* event_handler, 95 virtual void Initialize(const std::string& name,
98 const ConnectedCallback& callback) = 0; 96 Transport::EventHandler* event_handler,
97 scoped_ptr<ChannelAuthenticator> authenticator) = 0;
99 98
100 // Adds |candidate| received from the peer. 99 // Adds |candidate| received from the peer.
101 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0; 100 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) = 0;
102 101
103 // Name of the channel. It is used to identify the channel and 102 // Name of the channel. It is used to identify the channel and
104 // disambiguate candidates it generates from candidates generated by 103 // disambiguate candidates it generates from candidates generated by
105 // parallel connections. 104 // parallel connections.
106 virtual const std::string& name() const = 0; 105 virtual const std::string& name() const = 0;
107 106
108 // Returns true if the channel is already connected. 107 // Returns true if the channel is already connected.
109 virtual bool is_connected() const = 0; 108 virtual bool is_connected() const = 0;
110 109
111 private: 110 private:
112 DISALLOW_COPY_AND_ASSIGN(Transport); 111 DISALLOW_COPY_AND_ASSIGN(Transport);
113 }; 112 };
114 113
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
115 class TransportFactory { 140 class TransportFactory {
116 public: 141 public:
117 TransportFactory() { } 142 TransportFactory() { }
118 virtual ~TransportFactory() { } 143 virtual ~TransportFactory() { }
119 144
120 // Called to notify transport factory that a new transport might be created 145 // Called to notify transport factory that a new transport might be created
121 // soon, e.g. when a new session is being created. Implementation may use it 146 // soon, e.g. when a new session is being created. Implementation may use it
122 // to start asynchronous preparation, e.g. fetch a new relay token if 147 // to start asynchronous preparation, e.g. fetch a new relay token if
123 // necessary while the session is being authenticated. 148 // necessary while the session is being authenticated.
124 virtual void PrepareTokens() = 0; 149 virtual void PrepareTokens() = 0;
125 150
126 virtual scoped_ptr<Transport> CreateTransport() = 0; 151 virtual scoped_ptr<StreamTransport> CreateStreamTransport() = 0;
152 virtual scoped_ptr<DatagramTransport> CreateDatagramTransport() = 0;
127 153
128 private: 154 private:
129 DISALLOW_COPY_AND_ASSIGN(TransportFactory); 155 DISALLOW_COPY_AND_ASSIGN(TransportFactory);
130 }; 156 };
131 157
132 } // namespace protocol 158 } // namespace protocol
133 } // namespace remoting 159 } // namespace remoting
134 160
135 #endif // REMOTING_PROTOCOL_TRANSPORT_H_ 161 #endif // REMOTING_PROTOCOL_TRANSPORT_H_
OLDNEW
« no previous file with comments | « remoting/protocol/stream_channel_factory.h ('k') | remoting/remoting_srcs.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698