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

Side by Side Diff: remoting/protocol/libjingle_transport_factory.cc

Issue 9366001: Implement support for route change notifications in the Transport interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | remoting/protocol/pepper_session.h » ('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 #include "remoting/protocol/libjingle_transport_factory.h" 5 #include "remoting/protocol/libjingle_transport_factory.h"
6 6
7 #include "jingle/glue/channel_socket_adapter.h" 7 #include "jingle/glue/channel_socket_adapter.h"
8 #include "jingle/glue/pseudotcp_adapter.h" 8 #include "jingle/glue/pseudotcp_adapter.h"
9 #include "jingle/glue/utils.h"
9 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
10 #include "remoting/protocol/channel_authenticator.h" 11 #include "remoting/protocol/channel_authenticator.h"
11 #include "remoting/protocol/transport_config.h" 12 #include "remoting/protocol/transport_config.h"
12 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" 13 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
13 #include "third_party/libjingle/source/talk/base/network.h" 14 #include "third_party/libjingle/source/talk/base/network.h"
14 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" 15 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
15 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" 16 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
16 17
17 namespace remoting { 18 namespace remoting {
18 namespace protocol { 19 namespace protocol {
(...skipping 25 matching lines...) Expand all
44 virtual void Connect( 45 virtual void Connect(
45 const StreamTransport::ConnectedCallback& callback) OVERRIDE; 46 const StreamTransport::ConnectedCallback& callback) OVERRIDE;
46 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) OVERRIDE; 47 virtual void AddRemoteCandidate(const cricket::Candidate& candidate) OVERRIDE;
47 virtual const std::string& name() const OVERRIDE; 48 virtual const std::string& name() const OVERRIDE;
48 virtual bool is_connected() const OVERRIDE; 49 virtual bool is_connected() const OVERRIDE;
49 50
50 private: 51 private:
51 void OnRequestSignaling(); 52 void OnRequestSignaling();
52 void OnCandidateReady(cricket::TransportChannelImpl* channel, 53 void OnCandidateReady(cricket::TransportChannelImpl* channel,
53 const cricket::Candidate& candidate); 54 const cricket::Candidate& candidate);
55 void OnRouteChange(cricket::TransportChannel* channel,
56 const cricket::Candidate& candidate);
54 57
55 void OnTcpConnected(int result); 58 void OnTcpConnected(int result);
56 void OnAuthenticationDone(net::Error error, 59 void OnAuthenticationDone(net::Error error,
57 scoped_ptr<net::StreamSocket> socket); 60 scoped_ptr<net::StreamSocket> socket);
58 61
59 void OnChannelDestroyed(); 62 void OnChannelDestroyed();
60 63
61 void NotifyConnected(scoped_ptr<net::StreamSocket> socket); 64 void NotifyConnected(scoped_ptr<net::StreamSocket> socket);
62 void NotifyConnectFailed(); 65 void NotifyConnectFailed();
63 66
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 port_allocator_->SetPortRange(config_.min_port, config_.max_port); 152 port_allocator_->SetPortRange(config_.min_port, config_.max_port);
150 153
151 // Create P2PTransportChannel. 154 // Create P2PTransportChannel.
152 DCHECK(!channel_.get()); 155 DCHECK(!channel_.get());
153 channel_.reset(new cricket::P2PTransportChannel( 156 channel_.reset(new cricket::P2PTransportChannel(
154 name_, "", NULL, port_allocator_.get())); 157 name_, "", NULL, port_allocator_.get()));
155 channel_->SignalRequestSignaling.connect( 158 channel_->SignalRequestSignaling.connect(
156 this, &LibjingleStreamTransport::OnRequestSignaling); 159 this, &LibjingleStreamTransport::OnRequestSignaling);
157 channel_->SignalCandidateReady.connect( 160 channel_->SignalCandidateReady.connect(
158 this, &LibjingleStreamTransport::OnCandidateReady); 161 this, &LibjingleStreamTransport::OnCandidateReady);
162 channel_->SignalRouteChange.connect(
163 this, &LibjingleStreamTransport::OnRouteChange);
159 164
160 channel_->Connect(); 165 channel_->Connect();
161 166
162 scoped_ptr<jingle_glue::TransportChannelSocketAdapter> channel_adapter( 167 scoped_ptr<jingle_glue::TransportChannelSocketAdapter> channel_adapter(
163 new jingle_glue::TransportChannelSocketAdapter(channel_.get())); 168 new jingle_glue::TransportChannelSocketAdapter(channel_.get()));
164 channel_adapter->SetOnDestroyedCallback(base::Bind( 169 channel_adapter->SetOnDestroyedCallback(base::Bind(
165 &LibjingleStreamTransport::OnChannelDestroyed, base::Unretained(this))); 170 &LibjingleStreamTransport::OnChannelDestroyed, base::Unretained(this)));
166 171
167 // Setup PseudoTCP adapter. 172 // Setup PseudoTCP adapter.
168 owned_socket_.reset( 173 owned_socket_.reset(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 channel_->OnSignalingReady(); 205 channel_->OnSignalingReady();
201 } 206 }
202 207
203 void LibjingleStreamTransport::OnCandidateReady( 208 void LibjingleStreamTransport::OnCandidateReady(
204 cricket::TransportChannelImpl* channel, 209 cricket::TransportChannelImpl* channel,
205 const cricket::Candidate& candidate) { 210 const cricket::Candidate& candidate) {
206 DCHECK(CalledOnValidThread()); 211 DCHECK(CalledOnValidThread());
207 event_handler_->OnTransportCandidate(this, candidate); 212 event_handler_->OnTransportCandidate(this, candidate);
208 } 213 }
209 214
215 void LibjingleStreamTransport::OnRouteChange(
216 cricket::TransportChannel* channel,
217 const cricket::Candidate& candidate) {
218 TransportRoute route;
219
220 if (candidate.type() == "local") {
221 route.type = TransportRoute::DIRECT;
222 } else if (candidate.type() == "stun") {
223 route.type = TransportRoute::STUN;
224 } else if (candidate.type() == "relay") {
225 route.type = TransportRoute::RELAY;
226 } else {
227 NOTREACHED();
Wez 2012/02/21 18:42:34 Is NOTREACHED() appropriate here? It'll mean that
Sergey Ulanov 2012/02/21 19:47:19 Good point. Changed this to LOG(FATAL) that would
228 }
229
230 if (!jingle_glue::SocketAddressToIPEndPoint(
231 candidate.address(), &route.remote_address)) {
232 NOTREACHED();
Wez 2012/02/21 18:42:34 Similarly here; since these notifications end up b
Sergey Ulanov 2012/02/21 19:47:19 Changed it to LOG(FATAL) too.
233 return;
234 }
235
236 DCHECK(channel->GetP2PChannel());
237 DCHECK(channel->GetP2PChannel()->best_connection());
238 const cricket::Candidate& local_candidate =
239 channel->GetP2PChannel()->best_connection()->local_candidate();
240 if (!jingle_glue::SocketAddressToIPEndPoint(
241 local_candidate.address(), &route.local_address)) {
242 NOTREACHED();
243 return;
244 }
245
246 event_handler_->OnTransportRouteChange(this, route);
247 }
248
210 void LibjingleStreamTransport::OnTcpConnected(int result) { 249 void LibjingleStreamTransport::OnTcpConnected(int result) {
211 DCHECK(CalledOnValidThread()); 250 DCHECK(CalledOnValidThread());
212 251
213 if (result != net::OK) { 252 if (result != net::OK) {
214 NotifyConnectFailed(); 253 NotifyConnectFailed();
215 return; 254 return;
216 } 255 }
217 256
218 authenticator_->SecureAndAuthenticate( 257 authenticator_->SecureAndAuthenticate(
219 owned_socket_.PassAs<net::StreamSocket>(), 258 owned_socket_.PassAs<net::StreamSocket>(),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 313
275 scoped_ptr<DatagramTransport> 314 scoped_ptr<DatagramTransport>
276 LibjingleTransportFactory::CreateDatagramTransport() { 315 LibjingleTransportFactory::CreateDatagramTransport() {
277 NOTIMPLEMENTED(); 316 NOTIMPLEMENTED();
278 return scoped_ptr<DatagramTransport>(NULL); 317 return scoped_ptr<DatagramTransport>(NULL);
279 } 318 }
280 319
281 320
282 } // namespace protocol 321 } // namespace protocol
283 } // namespace remoting 322 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | remoting/protocol/pepper_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698