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

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: Moved it back and added LibjingleTransportFactory::Create 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
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 "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
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 {
Sergey Ulanov 2013/06/21 00:48:13 this bracket goes to the previous line.
327 // Use Chrome's network stack to allocate ports for peer-to-peer channels.
328 scoped_ptr<ChromiumPortAllocator> port_allocator(
329 ChromiumPortAllocator::Create(url_request_context_getter,
330 network_settings));
331
332 bool incoming_only = network_settings.nat_traversal_mode ==
333 NetworkSettings::NAT_TRAVERSAL_DISABLED;
334
335 // Use libjingle for negotiation of peer-to-peer channels over
336 // NativePortAllocator allocated ports.
337 scoped_ptr<LibjingleTransportFactory> transport_factory(
338 new LibjingleTransportFactory(
339 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
340 incoming_only));
341 return transport_factory.Pass();
342 }
343
320 LibjingleTransportFactory::LibjingleTransportFactory( 344 LibjingleTransportFactory::LibjingleTransportFactory(
321 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator, 345 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator,
322 bool incoming_only) 346 bool incoming_only)
323 : http_port_allocator_(port_allocator.get()), 347 : http_port_allocator_(port_allocator.get()),
324 port_allocator_(port_allocator.Pass()), 348 port_allocator_(port_allocator.Pass()),
325 incoming_only_(incoming_only) { 349 incoming_only_(incoming_only) {
326 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 350 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
327 } 351 }
328 352
329 LibjingleTransportFactory::LibjingleTransportFactory() 353 LibjingleTransportFactory::LibjingleTransportFactory()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 401 }
378 402
379 scoped_ptr<DatagramTransport> 403 scoped_ptr<DatagramTransport>
380 LibjingleTransportFactory::CreateDatagramTransport() { 404 LibjingleTransportFactory::CreateDatagramTransport() {
381 NOTIMPLEMENTED(); 405 NOTIMPLEMENTED();
382 return scoped_ptr<DatagramTransport>(); 406 return scoped_ptr<DatagramTransport>();
383 } 407 }
384 408
385 } // namespace protocol 409 } // namespace protocol
386 } // namespace remoting 410 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698