Compute can_use_lcd_text using property trees.
[chromium-blink-merge.git] / remoting / host / desktop_process_main.cc
blob7384228184013724b5435e7d51137c1a21625484
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
3 // found in the LICENSE file.
4 //
5 // This file implements the Windows service controlling Me2Me host processes
6 // running within user sessions.
8 #include "base/bind.h"
9 #include "base/bind_helpers.h"
10 #include "base/command_line.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h"
14 #include "remoting/base/auto_thread.h"
15 #include "remoting/base/auto_thread_task_runner.h"
16 #include "remoting/host/desktop_process.h"
17 #include "remoting/host/host_exit_codes.h"
18 #include "remoting/host/host_main.h"
19 #include "remoting/host/ipc_constants.h"
20 #include "remoting/host/me2me_desktop_environment.h"
21 #include "remoting/host/win/session_desktop_environment.h"
23 namespace remoting {
25 int DesktopProcessMain() {
26 const base::CommandLine* command_line =
27 base::CommandLine::ForCurrentProcess();
28 std::string channel_name =
29 command_line->GetSwitchValueASCII(kDaemonPipeSwitchName);
31 if (channel_name.empty())
32 return kUsageExitCode;
34 base::MessageLoopForUI message_loop;
35 base::RunLoop run_loop;
36 scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
37 new AutoThreadTaskRunner(message_loop.task_runner(),
38 run_loop.QuitClosure());
40 // Launch the input thread.
41 scoped_refptr<AutoThreadTaskRunner> input_task_runner =
42 AutoThread::CreateWithType(
43 "Input thread", ui_task_runner, base::MessageLoop::TYPE_IO);
45 DesktopProcess desktop_process(ui_task_runner,
46 input_task_runner,
47 channel_name);
49 // Create a platform-dependent environment factory.
50 scoped_ptr<DesktopEnvironmentFactory> desktop_environment_factory;
51 #if defined(OS_WIN)
52 desktop_environment_factory.reset(
53 new SessionDesktopEnvironmentFactory(
54 ui_task_runner,
55 input_task_runner,
56 ui_task_runner,
57 base::Bind(&DesktopProcess::InjectSas,
58 desktop_process.AsWeakPtr())));
59 #else // !defined(OS_WIN)
60 desktop_environment_factory.reset(new Me2MeDesktopEnvironmentFactory(
61 ui_task_runner,
62 input_task_runner,
63 ui_task_runner));
64 #endif // !defined(OS_WIN)
66 if (!desktop_process.Start(desktop_environment_factory.Pass()))
67 return kInitializationFailed;
69 // Run the UI message loop.
70 ui_task_runner = nullptr;
71 run_loop.Run();
73 return kSuccessExitCode;
76 } // namespace remoting
78 #if !defined(OS_WIN)
79 int main(int argc, char** argv) {
80 return remoting::HostMain(argc, argv);
82 #endif // !defined(OS_WIN)