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