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

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

Issue 290173011: Cleanup: Use base::CommandLine in remoting/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 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/plugin/host_plugin.cc ('k') | remoting/host/service_urls.cc » ('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 // This file implements a standalone host process for Me2Me. 5 // This file implements a standalone host process for Me2Me.
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 #if defined(OS_POSIX) 202 #if defined(OS_POSIX)
203 // Callback passed to RegisterSignalHandler() to handle SIGTERM events. 203 // Callback passed to RegisterSignalHandler() to handle SIGTERM events.
204 void SigTermHandler(int signal_number); 204 void SigTermHandler(int signal_number);
205 #endif 205 #endif
206 206
207 // Called to initialize resources on the UI thread. 207 // Called to initialize resources on the UI thread.
208 void StartOnUiThread(); 208 void StartOnUiThread();
209 209
210 // Initializes IPC control channel and config file path from |cmd_line|. 210 // Initializes IPC control channel and config file path from |cmd_line|.
211 // Called on the UI thread. 211 // Called on the UI thread.
212 bool InitWithCommandLine(const CommandLine* cmd_line); 212 bool InitWithCommandLine(const base::CommandLine* cmd_line);
213 213
214 // Called on the UI thread to start monitoring the configuration file. 214 // Called on the UI thread to start monitoring the configuration file.
215 void StartWatchingConfigChanges(); 215 void StartWatchingConfigChanges();
216 216
217 // Called on the network thread to set the host's Authenticator factory. 217 // Called on the network thread to set the host's Authenticator factory.
218 void CreateAuthenticatorFactory(); 218 void CreateAuthenticatorFactory();
219 219
220 // Tear down resources that run on the UI thread. 220 // Tear down resources that run on the UI thread.
221 void ShutdownOnUiThread(); 221 void ShutdownOnUiThread();
222 222
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 // We might be getting deleted on one of the threads the |host_context| owns, 354 // We might be getting deleted on one of the threads the |host_context| owns,
355 // so we need to post it back to the caller thread to safely join & delete the 355 // so we need to post it back to the caller thread to safely join & delete the
356 // threads it contains. This will go away when we move to AutoThread. 356 // threads it contains. This will go away when we move to AutoThread.
357 // |context_release()| will null |context_| before the method is invoked, so 357 // |context_release()| will null |context_| before the method is invoked, so
358 // we need to pull out the task-runner on which to call DeleteSoon first. 358 // we need to pull out the task-runner on which to call DeleteSoon first.
359 scoped_refptr<base::SingleThreadTaskRunner> task_runner = 359 scoped_refptr<base::SingleThreadTaskRunner> task_runner =
360 context_->ui_task_runner(); 360 context_->ui_task_runner();
361 task_runner->DeleteSoon(FROM_HERE, context_.release()); 361 task_runner->DeleteSoon(FROM_HERE, context_.release());
362 } 362 }
363 363
364 bool HostProcess::InitWithCommandLine(const CommandLine* cmd_line) { 364 bool HostProcess::InitWithCommandLine(const base::CommandLine* cmd_line) {
365 #if defined(REMOTING_MULTI_PROCESS) 365 #if defined(REMOTING_MULTI_PROCESS)
366 // Parse the handle value and convert it to a handle/file descriptor. 366 // Parse the handle value and convert it to a handle/file descriptor.
367 std::string channel_name = 367 std::string channel_name =
368 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName); 368 cmd_line->GetSwitchValueASCII(kDaemonPipeSwitchName);
369 369
370 int pipe_handle = 0; 370 int pipe_handle = 0;
371 if (channel_name.empty() || 371 if (channel_name.empty() ||
372 !base::StringToInt(channel_name, &pipe_handle)) { 372 !base::StringToInt(channel_name, &pipe_handle)) {
373 LOG(ERROR) << "Invalid '" << kDaemonPipeSwitchName 373 LOG(ERROR) << "Invalid '" << kDaemonPipeSwitchName
374 << "' value: " << channel_name; 374 << "' value: " << channel_name;
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 624
625 // Shutdown the host if the daemon process disconnects the IPC channel. 625 // Shutdown the host if the daemon process disconnects the IPC channel.
626 context_->network_task_runner()->PostTask( 626 context_->network_task_runner()->PostTask(
627 FROM_HERE, 627 FROM_HERE,
628 base::Bind(&HostProcess::ShutdownHost, this, kSuccessExitCode)); 628 base::Bind(&HostProcess::ShutdownHost, this, kSuccessExitCode));
629 } 629 }
630 630
631 void HostProcess::StartOnUiThread() { 631 void HostProcess::StartOnUiThread() {
632 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread()); 632 DCHECK(context_->ui_task_runner()->BelongsToCurrentThread());
633 633
634 if (!InitWithCommandLine(CommandLine::ForCurrentProcess())) { 634 if (!InitWithCommandLine(base::CommandLine::ForCurrentProcess())) {
635 // Shutdown the host if the command line is invalid. 635 // Shutdown the host if the command line is invalid.
636 context_->network_task_runner()->PostTask( 636 context_->network_task_runner()->PostTask(
637 FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this, 637 FROM_HERE, base::Bind(&HostProcess::ShutdownHost, this,
638 kUsageExitCode)); 638 kUsageExitCode));
639 return; 639 return;
640 } 640 }
641 641
642 #if defined(OS_LINUX) 642 #if defined(OS_LINUX)
643 // If an audio pipe is specific on the command-line then initialize 643 // If an audio pipe is specific on the command-line then initialize
644 // AudioCapturerLinux to capture from it. 644 // AudioCapturerLinux to capture from it.
645 base::FilePath audio_pipe_name = CommandLine::ForCurrentProcess()-> 645 base::FilePath audio_pipe_name = base::CommandLine::ForCurrentProcess()->
646 GetSwitchValuePath(kAudioPipeSwitchName); 646 GetSwitchValuePath(kAudioPipeSwitchName);
647 if (!audio_pipe_name.empty()) { 647 if (!audio_pipe_name.empty()) {
648 remoting::AudioCapturerLinux::InitializePipeReader( 648 remoting::AudioCapturerLinux::InitializePipeReader(
649 context_->audio_task_runner(), audio_pipe_name); 649 context_->audio_task_runner(), audio_pipe_name);
650 } 650 }
651 651
652 base::FilePath gnubby_socket_name = CommandLine::ForCurrentProcess()-> 652 base::FilePath gnubby_socket_name = base::CommandLine::ForCurrentProcess()->
653 GetSwitchValuePath(kAuthSocknameSwitchName); 653 GetSwitchValuePath(kAuthSocknameSwitchName);
654 if (!gnubby_socket_name.empty()) 654 if (!gnubby_socket_name.empty())
655 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name); 655 remoting::GnubbyAuthHandler::SetGnubbySocketName(gnubby_socket_name);
656 #endif // defined(OS_LINUX) 656 #endif // defined(OS_LINUX)
657 657
658 // Create a desktop environment factory appropriate to the build type & 658 // Create a desktop environment factory appropriate to the build type &
659 // platform. 659 // platform.
660 #if defined(OS_WIN) 660 #if defined(OS_WIN)
661 IpcDesktopEnvironmentFactory* desktop_environment_factory = 661 IpcDesktopEnvironmentFactory* desktop_environment_factory =
662 new IpcDesktopEnvironmentFactory( 662 new IpcDesktopEnvironmentFactory(
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 return exit_code; 1354 return exit_code;
1355 } 1355 }
1356 1356
1357 } // namespace remoting 1357 } // namespace remoting
1358 1358
1359 #if !defined(OS_WIN) 1359 #if !defined(OS_WIN)
1360 int main(int argc, char** argv) { 1360 int main(int argc, char** argv) {
1361 return remoting::HostMain(argc, argv); 1361 return remoting::HostMain(argc, argv);
1362 } 1362 }
1363 #endif // !defined(OS_WIN) 1363 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « remoting/host/plugin/host_plugin.cc ('k') | remoting/host/service_urls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698