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

Side by Side Diff: remoting/host/win/host_service.cc

Issue 10832054: Removing --host-binary parameter in preparation to the coming me2me host refactoring. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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/win/host_service.h ('k') | remoting/host/win/wts_session_process_launcher.h » ('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 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/win/host_service.h" 8 #include "remoting/host/win/host_service.h"
9 9
10 #include <windows.h> 10 #include <windows.h>
11 #include <wtsapi32.h> 11 #include <wtsapi32.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include "base/at_exit.h" 14 #include "base/at_exit.h"
15 #include "base/base_paths.h" 15 #include "base/base_paths.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/command_line.h" 17 #include "base/command_line.h"
18 #include "base/file_util.h" 18 #include "base/file_path.h"
19 #include "base/logging.h" 19 #include "base/logging.h"
20 #include "base/message_loop.h" 20 #include "base/message_loop.h"
21 #include "base/path_service.h"
22 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
23 #include "base/stringprintf.h" 22 #include "base/stringprintf.h"
24 #include "base/threading/thread.h" 23 #include "base/threading/thread.h"
25 #include "base/utf_string_conversions.h" 24 #include "base/utf_string_conversions.h"
26 #include "base/win/wrapped_window_proc.h" 25 #include "base/win/wrapped_window_proc.h"
27 #include "remoting/base/breakpad.h" 26 #include "remoting/base/breakpad.h"
28 #include "remoting/base/scoped_sc_handle_win.h" 27 #include "remoting/base/scoped_sc_handle_win.h"
29 #include "remoting/base/stoppable.h" 28 #include "remoting/base/stoppable.h"
30 #include "remoting/host/branding.h" 29 #include "remoting/host/branding.h"
31 #include "remoting/host/usage_stats_consent.h" 30 #include "remoting/host/usage_stats_consent.h"
(...skipping 11 matching lines...) Expand all
43 const wchar_t kSessionNotificationWindowClass[] = 42 const wchar_t kSessionNotificationWindowClass[] =
44 L"Chromoting_SessionNotificationWindow"; 43 L"Chromoting_SessionNotificationWindow";
45 44
46 // Command line actions and switches: 45 // Command line actions and switches:
47 // "run" sumply runs the service as usual. 46 // "run" sumply runs the service as usual.
48 const wchar_t kRunActionName[] = L"run"; 47 const wchar_t kRunActionName[] = L"run";
49 48
50 // "--console" runs the service interactively for debugging purposes. 49 // "--console" runs the service interactively for debugging purposes.
51 const char kConsoleSwitchName[] = "console"; 50 const char kConsoleSwitchName[] = "console";
52 51
53 // "--host-binary" specifies the host binary to run in console session.
54 const char kHostBinarySwitchName[] = "host-binary";
55
56 // "--help" or "--?" prints the usage message. 52 // "--help" or "--?" prints the usage message.
57 const char kHelpSwitchName[] = "help"; 53 const char kHelpSwitchName[] = "help";
58 const char kQuestionSwitchName[] = "?"; 54 const char kQuestionSwitchName[] = "?";
59 55
60 const char kUsageMessage[] = 56 const char kUsageMessage[] =
61 "\n" 57 "\n"
62 "Usage: %s [action] [options]\n" 58 "Usage: %s [action] [options]\n"
63 "\n" 59 "\n"
64 "Actions:\n" 60 "Actions:\n"
65 " run - Run the service (default if no action was specified).\n" 61 " run - Run the service (default if no action was specified).\n"
66 "\n" 62 "\n"
67 "Options:\n" 63 "Options:\n"
68 " --console - Run the service interactively for debugging purposes.\n" 64 " --console - Run the service interactively for debugging purposes.\n"
69 " --host-binary - Specifies the host binary to run.\n"
70 " --help, --? - Print this message.\n"; 65 " --help, --? - Print this message.\n";
71 66
72 // Exit codes: 67 // Exit codes:
73 const int kSuccessExitCode = 0; 68 const int kSuccessExitCode = 0;
74 const int kUsageExitCode = 1; 69 const int kUsageExitCode = 1;
75 const int kErrorExitCode = 2; 70 const int kErrorExitCode = 2;
76 71
77 void usage(const char* program_name) { 72 void usage(const char* program_name) {
78 fprintf(stderr, kUsageMessage, program_name); 73 fprintf(stderr, kUsageMessage, program_name);
79 } 74 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 LOG(ERROR) << "Invalid command line: more than one action requested."; 161 LOG(ERROR) << "Invalid command line: more than one action requested.";
167 return false; 162 return false;
168 } 163 }
169 if (args[0] != kRunActionName) { 164 if (args[0] != kRunActionName) {
170 LOG(ERROR) << "Invalid command line: invalid action specified: " 165 LOG(ERROR) << "Invalid command line: invalid action specified: "
171 << args[0]; 166 << args[0];
172 return false; 167 return false;
173 } 168 }
174 } 169 }
175 170
176 if (command_line->HasSwitch(kHostBinarySwitchName)) {
177 host_binary_ = command_line->GetSwitchValuePath(kHostBinarySwitchName);
178 } else {
179 LOG(ERROR) << "Invalid command line: --" << kHostBinarySwitchName
180 << " is required.";
181 return false;
182 }
183
184 // Run interactively if needed. 171 // Run interactively if needed.
185 if (run_routine_ == &HostService::RunAsService && 172 if (run_routine_ == &HostService::RunAsService &&
186 command_line->HasSwitch(kConsoleSwitchName)) { 173 command_line->HasSwitch(kConsoleSwitchName)) {
187 run_routine_ = &HostService::RunInConsole; 174 run_routine_ = &HostService::RunInConsole;
188 } 175 }
189 176
190 return true; 177 return true;
191 } 178 }
192 179
193 int HostService::Run() { 180 int HostService::Run() {
194 return (this->*run_routine_)(); 181 return (this->*run_routine_)();
195 } 182 }
196 183
197 void HostService::RunMessageLoop(MessageLoop* message_loop) { 184 void HostService::RunMessageLoop(MessageLoop* message_loop) {
198 // Launch the I/O thread. 185 // Launch the I/O thread.
199 base::Thread io_thread(kIoThreadName); 186 base::Thread io_thread(kIoThreadName);
200 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0); 187 base::Thread::Options io_thread_options(MessageLoop::TYPE_IO, 0);
201 if (!io_thread.StartWithOptions(io_thread_options)) { 188 if (!io_thread.StartWithOptions(io_thread_options)) {
202 LOG(FATAL) << "Failed to start the I/O thread"; 189 LOG(FATAL) << "Failed to start the I/O thread";
203 stopped_event_.Signal(); 190 stopped_event_.Signal();
204 return; 191 return;
205 } 192 }
206 193
207 // Create the session process launcher. 194 // Create the session process launcher.
208 launcher_.reset(new WtsSessionProcessLauncher( 195 launcher_.reset(new WtsSessionProcessLauncher(
209 base::Bind(&HostService::OnLauncherShutdown, base::Unretained(this)), 196 base::Bind(&HostService::OnLauncherShutdown, base::Unretained(this)),
210 this, 197 this,
211 host_binary_,
212 main_task_runner_, 198 main_task_runner_,
213 io_thread.message_loop_proxy())); 199 io_thread.message_loop_proxy()));
214 200
215 // Run the service. 201 // Run the service.
216 message_loop->Run(); 202 message_loop->Run();
217 203
218 // Release the control handler. 204 // Release the control handler.
219 stopped_event_.Signal(); 205 stopped_event_.Signal();
220 } 206 }
221 207
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } 421 }
436 422
437 remoting::HostService* service = remoting::HostService::GetInstance(); 423 remoting::HostService* service = remoting::HostService::GetInstance();
438 if (!service->InitWithCommandLine(command_line)) { 424 if (!service->InitWithCommandLine(command_line)) {
439 usage(argv[0]); 425 usage(argv[0]);
440 return kUsageExitCode; 426 return kUsageExitCode;
441 } 427 }
442 428
443 return service->Run(); 429 return service->Run();
444 } 430 }
OLDNEW
« no previous file with comments | « remoting/host/win/host_service.h ('k') | remoting/host/win/wts_session_process_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698