| OLD | NEW |
| 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 the Windows service controlling Me2Me host processes | 5 // This file implements the Windows service controlling Me2Me host processes |
| 6 // running within user sessions. | 6 // running within user sessions. |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 14 #include "remoting/base/auto_thread.h" | 14 #include "remoting/base/auto_thread.h" |
| 15 #include "remoting/base/auto_thread_task_runner.h" | 15 #include "remoting/base/auto_thread_task_runner.h" |
| 16 #include "remoting/host/desktop_process.h" | 16 #include "remoting/host/desktop_process.h" |
| 17 #include "remoting/host/host_exit_codes.h" | 17 #include "remoting/host/host_exit_codes.h" |
| 18 #include "remoting/host/host_main.h" | 18 #include "remoting/host/host_main.h" |
| 19 #include "remoting/host/ipc_constants.h" | 19 #include "remoting/host/ipc_constants.h" |
| 20 #include "remoting/host/me2me_desktop_environment.h" | 20 #include "remoting/host/me2me_desktop_environment.h" |
| 21 #include "remoting/host/ui_strings.h" | |
| 22 #include "remoting/host/win/session_desktop_environment.h" | 21 #include "remoting/host/win/session_desktop_environment.h" |
| 23 | 22 |
| 24 namespace remoting { | 23 namespace remoting { |
| 25 | 24 |
| 26 int DesktopProcessMain() { | 25 int DesktopProcessMain() { |
| 27 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 26 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 28 std::string channel_name = | 27 std::string channel_name = |
| 29 command_line->GetSwitchValueASCII(kDaemonPipeSwitchName); | 28 command_line->GetSwitchValueASCII(kDaemonPipeSwitchName); |
| 30 | 29 |
| 31 if (channel_name.empty()) | 30 if (channel_name.empty()) |
| 32 return kUsageExitCode; | 31 return kUsageExitCode; |
| 33 | 32 |
| 34 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); | 33 base::MessageLoop message_loop(base::MessageLoop::TYPE_UI); |
| 35 base::RunLoop run_loop; | 34 base::RunLoop run_loop; |
| 36 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = | 35 scoped_refptr<AutoThreadTaskRunner> ui_task_runner = |
| 37 new AutoThreadTaskRunner(message_loop.message_loop_proxy(), | 36 new AutoThreadTaskRunner(message_loop.message_loop_proxy(), |
| 38 run_loop.QuitClosure()); | 37 run_loop.QuitClosure()); |
| 39 | 38 |
| 40 // Launch the input thread. | 39 // Launch the input thread. |
| 41 scoped_refptr<AutoThreadTaskRunner> input_task_runner = | 40 scoped_refptr<AutoThreadTaskRunner> input_task_runner = |
| 42 AutoThread::CreateWithType( | 41 AutoThread::CreateWithType( |
| 43 "Input thread", ui_task_runner, base::MessageLoop::TYPE_IO); | 42 "Input thread", ui_task_runner, base::MessageLoop::TYPE_IO); |
| 44 | 43 |
| 45 DesktopProcess desktop_process(ui_task_runner, | 44 DesktopProcess desktop_process(ui_task_runner, |
| 46 input_task_runner, | 45 input_task_runner, |
| 47 channel_name); | 46 channel_name); |
| 48 | 47 |
| 49 // TODO(alexeypa): Localize the UI strings. See http://crbug.com/155204. | |
| 50 UiStrings ui_string; | |
| 51 | |
| 52 // Create a platform-dependent environment factory. | 48 // Create a platform-dependent environment factory. |
| 53 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory; | 49 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory; |
| 54 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
| 55 desktop_environment_factory.reset( | 51 desktop_environment_factory.reset( |
| 56 new SessionDesktopEnvironmentFactory( | 52 new SessionDesktopEnvironmentFactory( |
| 57 ui_task_runner, | 53 ui_task_runner, |
| 58 input_task_runner, | 54 input_task_runner, |
| 59 ui_task_runner, | 55 ui_task_runner, |
| 60 ui_string, | |
| 61 base::Bind(&DesktopProcess::InjectSas, | 56 base::Bind(&DesktopProcess::InjectSas, |
| 62 desktop_process.AsWeakPtr()))); | 57 desktop_process.AsWeakPtr()))); |
| 63 #else // !defined(OS_WIN) | 58 #else // !defined(OS_WIN) |
| 64 desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory( | 59 desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory( |
| 65 ui_task_runner, | 60 ui_task_runner, |
| 66 input_task_runner, | 61 input_task_runner, |
| 67 ui_task_runner, | 62 ui_task_runner)); |
| 68 ui_string)); | |
| 69 #endif // !defined(OS_WIN) | 63 #endif // !defined(OS_WIN) |
| 70 | 64 |
| 71 if (!desktop_process.Start(desktop_environment_factory.Pass())) | 65 if (!desktop_process.Start(desktop_environment_factory.Pass())) |
| 72 return kInitializationFailed; | 66 return kInitializationFailed; |
| 73 | 67 |
| 74 // Run the UI message loop. | 68 // Run the UI message loop. |
| 75 ui_task_runner = NULL; | 69 ui_task_runner = NULL; |
| 76 run_loop.Run(); | 70 run_loop.Run(); |
| 77 | 71 |
| 78 return kSuccessExitCode; | 72 return kSuccessExitCode; |
| 79 } | 73 } |
| 80 | 74 |
| 81 } // namespace remoting | 75 } // namespace remoting |
| 82 | 76 |
| 83 #if !defined(OS_WIN) | 77 #if !defined(OS_WIN) |
| 84 int main(int argc, char** argv) { | 78 int main(int argc, char** argv) { |
| 85 return remoting::HostMain(argc, argv); | 79 return remoting::HostMain(argc, argv); |
| 86 } | 80 } |
| 87 #endif // !defined(OS_WIN) | 81 #endif // !defined(OS_WIN) |
| OLD | NEW |