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

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

Issue 17101034: Add static Create method to LibjingleTransportFactory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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/libjingle_transport_factory.h ('k') | remoting/remoting.gyp » ('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 "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 "base/timer.h" 9 #include "base/timer.h"
10 #include "jingle/glue/channel_socket_adapter.h" 10 #include "jingle/glue/channel_socket_adapter.h"
11 #include "jingle/glue/pseudotcp_adapter.h" 11 #include "jingle/glue/pseudotcp_adapter.h"
12 #include "jingle/glue/thread_wrapper.h" 12 #include "jingle/glue/thread_wrapper.h"
13 #include "jingle/glue/utils.h" 13 #include "jingle/glue/utils.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "remoting/base/constants.h" 15 #include "remoting/base/constants.h"
16 #include "remoting/jingle_glue/chromium_port_allocator.h"
17 #include "remoting/jingle_glue/chromium_socket_factory.h"
18 #include "remoting/jingle_glue/network_settings.h"
16 #include "remoting/protocol/channel_authenticator.h" 19 #include "remoting/protocol/channel_authenticator.h"
17 #include "remoting/protocol/transport_config.h" 20 #include "remoting/protocol/transport_config.h"
18 #include "remoting/jingle_glue/chromium_socket_factory.h"
19 #include "third_party/libjingle/source/talk/base/network.h" 21 #include "third_party/libjingle/source/talk/base/network.h"
20 #include "third_party/libjingle/source/talk/p2p/base/constants.h" 22 #include "third_party/libjingle/source/talk/p2p/base/constants.h"
21 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" 23 #include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
22 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" 24 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
23 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h" 25 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
24 26
25 namespace remoting { 27 namespace remoting {
26 namespace protocol { 28 namespace protocol {
27 29
28 namespace { 30 namespace {
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 FROM_HERE, channel_.release()); 356 FROM_HERE, channel_.release());
355 } 357 }
356 358
357 authenticator_.reset(); 359 authenticator_.reset();
358 360
359 NotifyConnected(scoped_ptr<net::StreamSocket>()); 361 NotifyConnected(scoped_ptr<net::StreamSocket>());
360 } 362 }
361 363
362 } // namespace 364 } // namespace
363 365
366 scoped_ptr<LibjingleTransportFactory> LibjingleTransportFactory::Create(
367 const NetworkSettings& network_settings,
368 const scoped_refptr<net::URLRequestContextGetter>&
369 url_request_context_getter) {
370 // Use Chrome's network stack to allocate ports for peer-to-peer channels.
371 scoped_ptr<ChromiumPortAllocator> port_allocator(
372 ChromiumPortAllocator::Create(url_request_context_getter,
373 network_settings));
374
375 bool incoming_only = network_settings.nat_traversal_mode ==
376 NetworkSettings::NAT_TRAVERSAL_DISABLED;
377
378 // Use libjingle for negotiation of peer-to-peer channels over
379 // NativePortAllocator allocated ports.
380 scoped_ptr<LibjingleTransportFactory> transport_factory(
381 new LibjingleTransportFactory(
382 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
383 incoming_only));
384 return transport_factory.Pass();
385 }
386
364 LibjingleTransportFactory::LibjingleTransportFactory( 387 LibjingleTransportFactory::LibjingleTransportFactory(
365 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, 388 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator,
366 bool incoming_only) 389 bool incoming_only)
367 : http_port_allocator_(port_allocator.get()), 390 : http_port_allocator_(port_allocator.get()),
368 port_allocator_(port_allocator.Pass()), 391 port_allocator_(port_allocator.Pass()),
369 incoming_only_(incoming_only) { 392 incoming_only_(incoming_only) {
370 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 393 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
371 } 394 }
372 395
373 LibjingleTransportFactory::LibjingleTransportFactory() 396 LibjingleTransportFactory::LibjingleTransportFactory()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 444 }
422 445
423 scoped_ptr<DatagramTransport> 446 scoped_ptr<DatagramTransport>
424 LibjingleTransportFactory::CreateDatagramTransport() { 447 LibjingleTransportFactory::CreateDatagramTransport() {
425 NOTIMPLEMENTED(); 448 NOTIMPLEMENTED();
426 return scoped_ptr<DatagramTransport>(); 449 return scoped_ptr<DatagramTransport>();
427 } 450 }
428 451
429 } // namespace protocol 452 } // namespace protocol
430 } // namespace remoting 453 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/libjingle_transport_factory.h ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698