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

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

Issue 10233021: Move PortAllocator creation out of LibjingleTransportFactory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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
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 // This is an application of a minimal host process in a Chromoting 5 // This is an application of a minimal host process in a Chromoting
6 // system. It serves the purpose of gluing different pieces together 6 // system. It serves the purpose of gluing different pieces together
7 // to make a functional host process for testing. 7 // to make a functional host process for testing.
8 // 8 //
9 // It peforms the following functionality: 9 // It peforms the following functionality:
10 // 1. Connect to the GTalk network and register the machine as a host. 10 // 1. Connect to the GTalk network and register the machine as a host.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 #elif defined(OS_MACOSX) 55 #elif defined(OS_MACOSX)
56 #include "base/mac/scoped_nsautorelease_pool.h" 56 #include "base/mac/scoped_nsautorelease_pool.h"
57 #elif defined(OS_WIN) 57 #elif defined(OS_WIN)
58 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we 58 // TODO(garykac) Make simple host into a proper GUI app on Windows so that we
59 // have an hModule for the dialog resource. 59 // have an hModule for the dialog resource.
60 HMODULE g_hModule = NULL; 60 HMODULE g_hModule = NULL;
61 #endif 61 #endif
62 62
63 using remoting::protocol::CandidateSessionConfig; 63 using remoting::protocol::CandidateSessionConfig;
64 using remoting::protocol::ChannelConfig; 64 using remoting::protocol::ChannelConfig;
65 using remoting::protocol::NetworkSettings;
66 65
67 namespace { 66 namespace {
68 67
69 const FilePath::CharType kDefaultConfigPath[] = 68 const FilePath::CharType kDefaultConfigPath[] =
70 FILE_PATH_LITERAL(".ChromotingConfig.json"); 69 FILE_PATH_LITERAL(".ChromotingConfig.json");
71 70
72 const char kHomeDrive[] = "HOMEDRIVE"; 71 const char kHomeDrive[] = "HOMEDRIVE";
73 const char kHomePath[] = "HOMEPATH"; 72 const char kHomePath[] = "HOMEPATH";
74 73
75 const char kFakeSwitchName[] = "fake"; 74 const char kFakeSwitchName[] = "fake";
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 LOG(ERROR) << "Unknown video codec: " << video_codec; 345 LOG(ERROR) << "Unknown video codec: " << video_codec;
347 return 1; 346 return 1;
348 } 347 }
349 config->mutable_video_configs()->push_back(ChannelConfig( 348 config->mutable_video_configs()->push_back(ChannelConfig(
350 transport, remoting::protocol::kDefaultStreamVersion, codec)); 349 transport, remoting::protocol::kDefaultStreamVersion, codec));
351 simple_host.set_protocol_config(config.release()); 350 simple_host.set_protocol_config(config.release());
352 } 351 }
353 352
354 simple_host.network_settings()->nat_traversal_mode = 353 simple_host.network_settings()->nat_traversal_mode =
355 cmd_line->HasSwitch(kDisableNatTraversalSwitchName) ? 354 cmd_line->HasSwitch(kDisableNatTraversalSwitchName) ?
356 remoting::protocol::TransportConfig::NAT_TRAVERSAL_DISABLED : 355 remoting::NetworkSettings::NAT_TRAVERSAL_DISABLED :
357 remoting::protocol::TransportConfig::NAT_TRAVERSAL_ENABLED; 356 remoting::NetworkSettings::NAT_TRAVERSAL_ENABLED;
358 357
359 if (cmd_line->HasSwitch(kMinPortSwitchName)) { 358 if (cmd_line->HasSwitch(kMinPortSwitchName)) {
360 std::string min_port_str = 359 std::string min_port_str =
361 cmd_line->GetSwitchValueASCII(kMinPortSwitchName); 360 cmd_line->GetSwitchValueASCII(kMinPortSwitchName);
362 int min_port = 0; 361 int min_port = 0;
363 if (!base::StringToInt(min_port_str, &min_port) || 362 if (!base::StringToInt(min_port_str, &min_port) ||
364 min_port < 0 || min_port > 65535) { 363 min_port < 0 || min_port > 65535) {
365 LOG(ERROR) << "Invalid min-port value: " << min_port 364 LOG(ERROR) << "Invalid min-port value: " << min_port
366 << ". Expected integer in range [0, 65535]."; 365 << ". Expected integer in range [0, 65535].";
367 return 1; 366 return 1;
368 } 367 }
369 simple_host.network_settings()->min_port = min_port; 368 simple_host.network_settings()->min_port = min_port;
370 } 369 }
371 370
372 if (cmd_line->HasSwitch(kMaxPortSwitchName)) { 371 if (cmd_line->HasSwitch(kMaxPortSwitchName)) {
373 std::string max_port_str = 372 std::string max_port_str =
374 cmd_line->GetSwitchValueASCII(kMaxPortSwitchName); 373 cmd_line->GetSwitchValueASCII(kMaxPortSwitchName);
375 int max_port = 0; 374 int max_port = 0;
376 if (!base::StringToInt(max_port_str, &max_port) || 375 if (!base::StringToInt(max_port_str, &max_port) ||
377 max_port < 0 || max_port > 65535) { 376 max_port < 0 || max_port > 65535) {
378 LOG(ERROR) << "Invalid max-port value: " << max_port 377 LOG(ERROR) << "Invalid max-port value: " << max_port
379 << ". Expected integer in range [0, 65535]."; 378 << ". Expected integer in range [0, 65535].";
380 return 1; 379 return 1;
381 } 380 }
382 simple_host.network_settings()->max_port = max_port; 381 simple_host.network_settings()->max_port = max_port;
383 } 382 }
384 383
385 return simple_host.Run(); 384 return simple_host.Run();
386 } 385 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698