| 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 #include "remoting/protocol/libjingle_transport_factory.h" | 5 #include "remoting/protocol/libjingle_transport_factory.h" |
| 6 | 6 |
| 7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "jingle/glue/channel_socket_adapter.h" | 9 #include "jingle/glue/channel_socket_adapter.h" |
| 10 #include "jingle/glue/pseudotcp_adapter.h" | 10 #include "jingle/glue/pseudotcp_adapter.h" |
| 11 #include "jingle/glue/thread_wrapper.h" | 11 #include "jingle/glue/thread_wrapper.h" |
| 12 #include "jingle/glue/utils.h" | 12 #include "jingle/glue/utils.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" |
| 15 #include "remoting/jingle_glue/chromium_port_allocator.h" |
| 16 #include "remoting/jingle_glue/chromium_socket_factory.h" |
| 17 #include "remoting/jingle_glue/network_settings.h" |
| 15 #include "remoting/protocol/channel_authenticator.h" | 18 #include "remoting/protocol/channel_authenticator.h" |
| 16 #include "remoting/protocol/transport_config.h" | 19 #include "remoting/protocol/transport_config.h" |
| 17 #include "remoting/jingle_glue/chromium_socket_factory.h" | |
| 18 #include "third_party/libjingle/source/talk/base/network.h" | 20 #include "third_party/libjingle/source/talk/base/network.h" |
| 19 #include "third_party/libjingle/source/talk/p2p/base/constants.h" | 21 #include "third_party/libjingle/source/talk/p2p/base/constants.h" |
| 20 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" | 22 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" |
| 21 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 23 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
| 22 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" | 24 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" |
| 23 | 25 |
| 24 namespace remoting { | 26 namespace remoting { |
| 25 namespace protocol { | 27 namespace protocol { |
| 26 | 28 |
| 27 namespace { | 29 namespace { |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 FROM_HERE, channel_.release()); | 312 FROM_HERE, channel_.release()); |
| 311 } | 313 } |
| 312 | 314 |
| 313 authenticator_.reset(); | 315 authenticator_.reset(); |
| 314 | 316 |
| 315 NotifyConnected(scoped_ptr<net::StreamSocket>()); | 317 NotifyConnected(scoped_ptr<net::StreamSocket>()); |
| 316 } | 318 } |
| 317 | 319 |
| 318 } // namespace | 320 } // namespace |
| 319 | 321 |
| 322 scoped_ptr<LibjingleTransportFactory> LibjingleTransportFactory::Create( |
| 323 const NetworkSettings& network_settings, |
| 324 const scoped_refptr<net::URLRequestContextGetter>& |
| 325 url_request_context_getter) { |
| 326 // Use Chrome's network stack to allocate ports for peer-to-peer channels. |
| 327 scoped_ptr<ChromiumPortAllocator> port_allocator( |
| 328 ChromiumPortAllocator::Create(url_request_context_getter, |
| 329 network_settings)); |
| 330 |
| 331 bool incoming_only = network_settings.nat_traversal_mode == |
| 332 NetworkSettings::NAT_TRAVERSAL_DISABLED; |
| 333 |
| 334 // Use libjingle for negotiation of peer-to-peer channels over |
| 335 // NativePortAllocator allocated ports. |
| 336 scoped_ptr<LibjingleTransportFactory> transport_factory( |
| 337 new LibjingleTransportFactory( |
| 338 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(), |
| 339 incoming_only)); |
| 340 return transport_factory.Pass(); |
| 341 } |
| 342 |
| 320 LibjingleTransportFactory::LibjingleTransportFactory( | 343 LibjingleTransportFactory::LibjingleTransportFactory( |
| 321 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, | 344 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, |
| 322 bool incoming_only) | 345 bool incoming_only) |
| 323 : http_port_allocator_(port_allocator.get()), | 346 : http_port_allocator_(port_allocator.get()), |
| 324 port_allocator_(port_allocator.Pass()), | 347 port_allocator_(port_allocator.Pass()), |
| 325 incoming_only_(incoming_only) { | 348 incoming_only_(incoming_only) { |
| 326 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 349 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 327 } | 350 } |
| 328 | 351 |
| 329 LibjingleTransportFactory::LibjingleTransportFactory() | 352 LibjingleTransportFactory::LibjingleTransportFactory() |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 } | 400 } |
| 378 | 401 |
| 379 scoped_ptr<DatagramTransport> | 402 scoped_ptr<DatagramTransport> |
| 380 LibjingleTransportFactory::CreateDatagramTransport() { | 403 LibjingleTransportFactory::CreateDatagramTransport() { |
| 381 NOTIMPLEMENTED(); | 404 NOTIMPLEMENTED(); |
| 382 return scoped_ptr<DatagramTransport>(); | 405 return scoped_ptr<DatagramTransport>(); |
| 383 } | 406 } |
| 384 | 407 |
| 385 } // namespace protocol | 408 } // namespace protocol |
| 386 } // namespace remoting | 409 } // namespace remoting |
| OLD | NEW |