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

Unified 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: Fixed style violations 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/libjingle_transport_factory.cc
diff --git a/remoting/protocol/libjingle_transport_factory.cc b/remoting/protocol/libjingle_transport_factory.cc
index 78b30bb54f3127bbd3c6e5aeb574a39441d97659..4614d170a0666e48b7f2cda03802d148283d0c21 100644
--- a/remoting/protocol/libjingle_transport_factory.cc
+++ b/remoting/protocol/libjingle_transport_factory.cc
@@ -12,9 +12,11 @@
#include "jingle/glue/utils.h"
#include "net/base/net_errors.h"
#include "remoting/base/constants.h"
+#include "remoting/jingle_glue/chromium_port_allocator.h"
+#include "remoting/jingle_glue/chromium_socket_factory.h"
+#include "remoting/jingle_glue/network_settings.h"
#include "remoting/protocol/channel_authenticator.h"
#include "remoting/protocol/transport_config.h"
-#include "remoting/jingle_glue/chromium_socket_factory.h"
#include "third_party/libjingle/source/talk/base/network.h"
#include "third_party/libjingle/source/talk/p2p/base/constants.h"
#include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h"
@@ -317,6 +319,27 @@ void LibjingleStreamTransport::NotifyConnectFailed() {
} // namespace
+scoped_ptr<LibjingleTransportFactory> LibjingleTransportFactory::Create(
+ const NetworkSettings& network_settings,
+ const scoped_refptr<net::URLRequestContextGetter>&
+ url_request_context_getter) {
+ // Use Chrome's network stack to allocate ports for peer-to-peer channels.
+ scoped_ptr<ChromiumPortAllocator> port_allocator(
+ ChromiumPortAllocator::Create(url_request_context_getter,
+ network_settings));
+
+ bool incoming_only = network_settings.nat_traversal_mode ==
+ NetworkSettings::NAT_TRAVERSAL_DISABLED;
+
+ // Use libjingle for negotiation of peer-to-peer channels over
+ // NativePortAllocator allocated ports.
+ scoped_ptr<LibjingleTransportFactory> transport_factory(
+ new LibjingleTransportFactory(
+ port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
+ incoming_only));
+ return transport_factory.Pass();
+}
+
LibjingleTransportFactory::LibjingleTransportFactory(
scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator,
bool incoming_only)

Powered by Google App Engine
This is Rietveld 408576698