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

Side by Side Diff: remoting/host/chromoting_host.cc

Issue 10160013: Implement HostPortAllocator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_host_context.h » ('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/host/chromoting_host.h" 5 #include "remoting/host/chromoting_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "remoting/base/constants.h" 12 #include "remoting/base/constants.h"
13 #include "remoting/base/encoder.h" 13 #include "remoting/base/encoder.h"
14 #include "remoting/base/encoder_row_based.h" 14 #include "remoting/base/encoder_row_based.h"
15 #include "remoting/base/encoder_vp8.h" 15 #include "remoting/base/encoder_vp8.h"
16 #include "remoting/host/chromoting_host_context.h" 16 #include "remoting/host/chromoting_host_context.h"
17 #include "remoting/host/desktop_environment.h" 17 #include "remoting/host/desktop_environment.h"
18 #include "remoting/host/event_executor.h" 18 #include "remoting/host/event_executor.h"
19 #include "remoting/host/host_config.h" 19 #include "remoting/host/host_config.h"
20 #include "remoting/host/host_port_allocator.h"
20 #include "remoting/host/screen_recorder.h" 21 #include "remoting/host/screen_recorder.h"
21 #include "remoting/protocol/connection_to_client.h" 22 #include "remoting/protocol/connection_to_client.h"
22 #include "remoting/protocol/client_stub.h" 23 #include "remoting/protocol/client_stub.h"
23 #include "remoting/protocol/host_stub.h" 24 #include "remoting/protocol/host_stub.h"
24 #include "remoting/protocol/input_stub.h" 25 #include "remoting/protocol/input_stub.h"
25 #include "remoting/protocol/jingle_session_manager.h" 26 #include "remoting/protocol/jingle_session_manager.h"
26 #include "remoting/protocol/libjingle_transport_factory.h" 27 #include "remoting/protocol/libjingle_transport_factory.h"
27 #include "remoting/protocol/session_config.h" 28 #include "remoting/protocol/session_config.h"
28 #include "third_party/libjingle/source/talk/base/basicpacketsocketfactory.h"
29 #include "third_party/libjingle/source/talk/base/network.h"
30 #include "third_party/libjingle/source/talk/p2p/client/httpportallocator.h"
31 29
32 using remoting::protocol::ConnectionToClient; 30 using remoting::protocol::ConnectionToClient;
33 using remoting::protocol::InputStub; 31 using remoting::protocol::InputStub;
34 32
35 namespace remoting { 33 namespace remoting {
36 34
37 namespace { 35 namespace {
38 36
39 const net::BackoffEntry::Policy kDefaultBackoffPolicy = { 37 const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
40 // Number of initial errors (in sequence) to ignore before applying 38 // Number of initial errors (in sequence) to ignore before applying
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 void ChromotingHost::Start() { 91 void ChromotingHost::Start() {
94 DCHECK(context_->network_message_loop()->BelongsToCurrentThread()); 92 DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
95 93
96 LOG(INFO) << "Starting host"; 94 LOG(INFO) << "Starting host";
97 95
98 // Make sure this object is not started. 96 // Make sure this object is not started.
99 if (state_ != kInitial) 97 if (state_ != kInitial)
100 return; 98 return;
101 state_ = kStarted; 99 state_ = kStarted;
102 100
103 // Create port allocator. 101 // Create port allocator and transport factory.
104 // TODO(sergeyu): Replace the code below with HostPortAllocator when 102 scoped_ptr<HostPortAllocator> port_allocator(
105 // it is implemented. 103 HostPortAllocator::Create(context_->url_request_context_getter(),
106 scoped_ptr<talk_base::NetworkManager> network_manager( 104 network_settings_));
107 new talk_base::BasicNetworkManager());
108 scoped_ptr<talk_base::PacketSocketFactory> socket_factory(
109 new talk_base::BasicPacketSocketFactory());
110 scoped_ptr<cricket::HttpPortAllocatorBase> port_allocator(
111 new cricket::HttpPortAllocator(
112 network_manager.get(), socket_factory.get(), ""));
113
114
115 // We always use PseudoTcp to provide a reliable channel. It
116 // provides poor performance when combined with TCP-based transport,
117 // so we have to disable TCP ports.
118 int port_allocator_flags = cricket::PORTALLOCATOR_DISABLE_TCP;
119 if (network_settings_.nat_traversal_mode !=
120 NetworkSettings::NAT_TRAVERSAL_ENABLED) {
121 port_allocator_flags |= cricket::PORTALLOCATOR_DISABLE_STUN |
122 cricket::PORTALLOCATOR_DISABLE_RELAY;
123 }
124 port_allocator->set_flags(port_allocator_flags);
125 port_allocator->SetPortRange(network_settings_.min_port,
126 network_settings_.max_port);
127 105
128 bool incoming_only = network_settings_.nat_traversal_mode == 106 bool incoming_only = network_settings_.nat_traversal_mode ==
129 NetworkSettings::NAT_TRAVERSAL_DISABLED; 107 NetworkSettings::NAT_TRAVERSAL_DISABLED;
130 108
131 scoped_ptr<protocol::TransportFactory> transport_factory( 109 scoped_ptr<protocol::TransportFactory> transport_factory(
132 new protocol::LibjingleTransportFactory( 110 new protocol::LibjingleTransportFactory(
133 network_manager.Pass(), socket_factory.Pass(), 111 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(),
134 port_allocator.Pass(), incoming_only)); 112 incoming_only));
135 113
136 // Create and start session manager. 114 // Create and start session manager.
137 bool fetch_stun_relay_info = network_settings_.nat_traversal_mode == 115 bool fetch_stun_relay_info = network_settings_.nat_traversal_mode ==
138 NetworkSettings::NAT_TRAVERSAL_ENABLED; 116 NetworkSettings::NAT_TRAVERSAL_ENABLED;
139 session_manager_.reset(new protocol::JingleSessionManager( 117 session_manager_.reset(new protocol::JingleSessionManager(
140 transport_factory.Pass(), fetch_stun_relay_info)); 118 transport_factory.Pass(), fetch_stun_relay_info));
141 session_manager_->Init(signal_strategy_, this); 119 session_manager_->Init(signal_strategy_, this);
142 } 120 }
143 121
144 // This method is called when we need to destroy the host process. 122 // This method is called when we need to destroy the host process.
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 OnShutdown()); 426 OnShutdown());
449 427
450 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin(); 428 for (std::vector<base::Closure>::iterator it = shutdown_tasks_.begin();
451 it != shutdown_tasks_.end(); ++it) { 429 it != shutdown_tasks_.end(); ++it) {
452 it->Run(); 430 it->Run();
453 } 431 }
454 shutdown_tasks_.clear(); 432 shutdown_tasks_.clear();
455 } 433 }
456 434
457 } // namespace remoting 435 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/chromoting_host_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698