| 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/utils.h" | 12 #include "jingle/glue/utils.h" |
| 12 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 13 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" |
| 14 #include "remoting/protocol/channel_authenticator.h" | 15 #include "remoting/protocol/channel_authenticator.h" |
| 15 #include "remoting/protocol/transport_config.h" | 16 #include "remoting/protocol/transport_config.h" |
| 16 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h" | 17 #include "remoting/jingle_glue/chromium_socket_factory.h" |
| 17 #include "third_party/libjingle/source/talk/base/network.h" | 18 #include "third_party/libjingle/source/talk/base/network.h" |
| 18 #include "third_party/libjingle/source/talk/p2p/base/constants.h" | 19 #include "third_party/libjingle/source/talk/p2p/base/constants.h" |
| 19 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" | 20 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" |
| 20 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 21 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
| 21 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" | 22 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" |
| 22 | 23 |
| 23 namespace remoting { | 24 namespace remoting { |
| 24 namespace protocol { | 25 namespace protocol { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace | 307 } // namespace |
| 307 | 308 |
| 308 LibjingleTransportFactory::LibjingleTransportFactory( | 309 LibjingleTransportFactory::LibjingleTransportFactory( |
| 309 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, | 310 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, |
| 310 bool incoming_only) | 311 bool incoming_only) |
| 311 : http_port_allocator_(port_allocator.get()), | 312 : http_port_allocator_(port_allocator.get()), |
| 312 port_allocator_(port_allocator.Pass()), | 313 port_allocator_(port_allocator.Pass()), |
| 313 incoming_only_(incoming_only) { | 314 incoming_only_(incoming_only) { |
| 315 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); |
| 314 } | 316 } |
| 315 | 317 |
| 316 LibjingleTransportFactory::LibjingleTransportFactory() | 318 LibjingleTransportFactory::LibjingleTransportFactory() |
| 317 : network_manager_(new talk_base::BasicNetworkManager()), | 319 : network_manager_(new talk_base::BasicNetworkManager()), |
| 318 socket_factory_(new talk_base::BasicPacketSocketFactory()), | 320 socket_factory_(new remoting::ChromiumPacketSocketFactory()), |
| 319 http_port_allocator_(NULL), | 321 http_port_allocator_(NULL), |
| 320 port_allocator_(new cricket::BasicPortAllocator( | 322 port_allocator_(new cricket::BasicPortAllocator( |
| 321 network_manager_.get(), socket_factory_.get())), | 323 network_manager_.get(), socket_factory_.get())), |
| 322 incoming_only_(false) { | 324 incoming_only_(false) { |
| 325 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); |
| 323 } | 326 } |
| 324 | 327 |
| 325 LibjingleTransportFactory::~LibjingleTransportFactory() { | 328 LibjingleTransportFactory::~LibjingleTransportFactory() { |
| 326 // This method may be called in response to a libjingle signal, so | 329 // This method may be called in response to a libjingle signal, so |
| 327 // libjingle objects must be deleted asynchronously. | 330 // libjingle objects must be deleted asynchronously. |
| 328 scoped_refptr<base::SingleThreadTaskRunner> task_runner = | 331 scoped_refptr<base::SingleThreadTaskRunner> task_runner = |
| 329 base::ThreadTaskRunnerHandle::Get(); | 332 base::ThreadTaskRunnerHandle::Get(); |
| 330 task_runner->DeleteSoon(FROM_HERE, port_allocator_.release()); | 333 task_runner->DeleteSoon(FROM_HERE, port_allocator_.release()); |
| 331 task_runner->DeleteSoon(FROM_HERE, socket_factory_.release()); | 334 task_runner->DeleteSoon(FROM_HERE, socket_factory_.release()); |
| 332 task_runner->DeleteSoon(FROM_HERE, network_manager_.release()); | 335 task_runner->DeleteSoon(FROM_HERE, network_manager_.release()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 358 } | 361 } |
| 359 | 362 |
| 360 scoped_ptr<DatagramTransport> | 363 scoped_ptr<DatagramTransport> |
| 361 LibjingleTransportFactory::CreateDatagramTransport() { | 364 LibjingleTransportFactory::CreateDatagramTransport() { |
| 362 NOTIMPLEMENTED(); | 365 NOTIMPLEMENTED(); |
| 363 return scoped_ptr<DatagramTransport>(NULL); | 366 return scoped_ptr<DatagramTransport>(NULL); |
| 364 } | 367 } |
| 365 | 368 |
| 366 } // namespace protocol | 369 } // namespace protocol |
| 367 } // namespace remoting | 370 } // namespace remoting |
| OLD | NEW |