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

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

Issue 11231060: [Chromoting] The desktop process now creates a pre-connected pipe and passes (with some help of the… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixup Created 8 years, 1 month 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 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 "remoting/host/desktop_process.h"
9
10 #include "base/at_exit.h" 8 #include "base/at_exit.h"
11 #include "base/command_line.h" 9 #include "base/command_line.h"
12 #include "base/file_path.h" 10 #include "base/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/message_loop.h"
15 #include "base/run_loop.h"
16 #include "base/scoped_native_library.h" 11 #include "base/scoped_native_library.h"
17 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
18 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
19 #include "base/win/windows_version.h" 14 #include "base/win/windows_version.h"
20 #include "ipc/ipc_channel_proxy.h" 15 #include "remoting/host/desktop_process.h"
21 #include "remoting/base/auto_thread.h"
22 #include "remoting/base/auto_thread_task_runner.h"
23 #include "remoting/host/host_exit_codes.h" 16 #include "remoting/host/host_exit_codes.h"
24 #include "remoting/host/logging.h" 17 #include "remoting/host/logging.h"
25 #include "remoting/host/usage_stats_consent.h" 18 #include "remoting/host/usage_stats_consent.h"
26 19
27 #if defined(OS_MACOSX) 20 #if defined(OS_MACOSX)
28 #include "base/mac/scoped_nsautorelease_pool.h" 21 #include "base/mac/scoped_nsautorelease_pool.h"
29 #endif // defined(OS_MACOSX) 22 #endif // defined(OS_MACOSX)
30 23
31 #if defined(OS_WIN) 24 #if defined(OS_WIN)
32 #include <commctrl.h> 25 #include <commctrl.h>
33 #endif // defined(OS_WIN) 26 #endif // defined(OS_WIN)
34 27
35 namespace { 28 namespace {
36 29
37 // The command line switch specifying the name of the daemon IPC endpoint. 30 // The command line switch specifying the name of the daemon IPC endpoint.
38 const char kDaemonIpcSwitchName[] = "daemon-pipe"; 31 const char kDaemonIpcSwitchName[] = "daemon-pipe";
39 32
40 const char kIoThreadName[] = "I/O thread";
41
42 // "--help" or "--?" prints the usage message. 33 // "--help" or "--?" prints the usage message.
43 const char kHelpSwitchName[] = "help"; 34 const char kHelpSwitchName[] = "help";
44 const char kQuestionSwitchName[] = "?"; 35 const char kQuestionSwitchName[] = "?";
45 36
46 const wchar_t kUsageMessage[] = 37 const char kUsageMessage[] =
47 L"\n" 38 "\n"
48 L"Usage: %ls [options]\n" 39 "Usage: %s [options]\n"
49 L"\n" 40 "\n"
50 L"Options:\n" 41 "Options:\n"
51 L" --help, --? - Print this message.\n"; 42 " --help, --? - Print this message.\n";
52 43
53 void usage(const FilePath& program_name) { 44 void usage(const FilePath& program_name) {
Sergey Ulanov 2012/10/24 20:12:01 nit: Usage()
alexeypa (please no reviews) 2012/10/24 21:41:51 Done.
45 #if defined(OS_POSIX)
46 LOG(INFO) << StringPrintf(kUsageMessage, program_name.value().c_str());
Sergey Ulanov 2012/10/24 20:12:01 AsUTF8Unsafe() instead of value() and you won't ne
alexeypa (please no reviews) 2012/10/24 21:41:51 Done.
47 #elif defined(OS_WIN)
54 LOG(INFO) << StringPrintf(kUsageMessage, 48 LOG(INFO) << StringPrintf(kUsageMessage,
55 UTF16ToWide(program_name.value()).c_str()); 49 UTF16ToUTF8(program_name.value()).c_str());
50 #endif // OS_WIN
56 } 51 }
57 52
58 } // namespace 53 } // namespace
59 54
60 namespace remoting {
61
62 DesktopProcess::DesktopProcess(const std::string& daemon_channel_name)
63 : daemon_channel_name_(daemon_channel_name) {
64 }
65
66 DesktopProcess::~DesktopProcess() {
67 }
68
69 bool DesktopProcess::OnMessageReceived(const IPC::Message& message) {
70 return false;
71 }
72
73 void DesktopProcess::OnChannelConnected(int32 peer_pid) {
74 NOTIMPLEMENTED();
75 }
76
77 void DesktopProcess::OnChannelError() {
78 LOG(ERROR) << "Failed to connect to '" << daemon_channel_name_ << "'";
79 daemon_channel_.reset();
80 }
81
82 int DesktopProcess::Run() {
83 // Create the UI message loop.
84 MessageLoop message_loop(MessageLoop::TYPE_UI);
85
86 {
87 scoped_refptr<AutoThreadTaskRunner> ui_task_runner =
88 new remoting::AutoThreadTaskRunner(message_loop.message_loop_proxy(),
89 MessageLoop::QuitClosure());
90
91 // Launch the I/O thread.
92 scoped_refptr<AutoThreadTaskRunner> io_task_runner =
93 AutoThread::CreateWithType(kIoThreadName, ui_task_runner,
94 MessageLoop::TYPE_IO);
95
96 // Connect to the daemon.
97 daemon_channel_.reset(new IPC::ChannelProxy(daemon_channel_name_,
98 IPC::Channel::MODE_CLIENT,
99 this,
100 io_task_runner));
101 }
102
103 // Run the UI message loop.
104 base::RunLoop run_loop;
105 run_loop.Run();
106 return 0;
107 }
108
109 } // namespace remoting
110
111 int main(int argc, char** argv) { 55 int main(int argc, char** argv) {
112 #if defined(OS_MACOSX) 56 #if defined(OS_MACOSX)
113 // Needed so we don't leak objects when threads are created. 57 // Needed so we don't leak objects when threads are created.
114 base::mac::ScopedNSAutoreleasePool pool; 58 base::mac::ScopedNSAutoreleasePool pool;
115 #endif 59 #endif
116 60
117 CommandLine::Init(argc, argv); 61 CommandLine::Init(argc, argv);
118 62
119 // This object instance is required by Chrome code (for example, 63 // This object instance is required by Chrome code (for example,
120 // LazyInstance, MessageLoop). 64 // LazyInstance, MessageLoop).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 user32.GetFunctionPointer("SetProcessDPIAware")); 116 user32.GetFunctionPointer("SetProcessDPIAware"));
173 set_process_dpi_aware(); 117 set_process_dpi_aware();
174 } 118 }
175 119
176 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting 120 // CommandLine::Init() ignores the passed |argc| and |argv| on Windows getting
177 // the command line from GetCommandLineW(), so we can safely pass NULL here. 121 // the command line from GetCommandLineW(), so we can safely pass NULL here.
178 return main(0, NULL); 122 return main(0, NULL);
179 } 123 }
180 124
181 #endif // defined(OS_WIN) 125 #endif // defined(OS_WIN)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698