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

Side by Side Diff: remoting/host/setup/daemon_controller_delegate_linux.cc

Issue 159753008: Disable Me2Me host controls on unsupported Linux systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | « no previous file | remoting/tools/me2me_virtual_host.py » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "remoting/host/setup/daemon_controller_delegate_linux.h" 5 #include "remoting/host/setup/daemon_controller_delegate_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 if (!base::WaitForExitCodeWithTimeout(process_handle, exit_code, timeout)) { 107 if (!base::WaitForExitCodeWithTimeout(process_handle, exit_code, timeout)) {
108 base::KillProcess(process_handle, 0, false); 108 base::KillProcess(process_handle, 0, false);
109 LOG(ERROR) << "Timeout exceeded for command: " 109 LOG(ERROR) << "Timeout exceeded for command: "
110 << command_line.GetCommandLineString(); 110 << command_line.GetCommandLineString();
111 return false; 111 return false;
112 } 112 }
113 113
114 return true; 114 return true;
115 } 115 }
116 116
117 bool RunHostScript(const std::vector<std::string>& args, 117 bool RunHostScript(const std::vector<std::string>& args, int* exit_code) {
118 int* exit_code) {
119 return RunHostScriptWithTimeout( 118 return RunHostScriptWithTimeout(
120 args, base::TimeDelta::FromMilliseconds(kDaemonTimeoutMs), exit_code); 119 args, base::TimeDelta::FromMilliseconds(kDaemonTimeoutMs), exit_code);
121 } 120 }
122 121
123 } // namespace 122 } // namespace
124 123
125 DaemonControllerDelegateLinux::DaemonControllerDelegateLinux() { 124 DaemonControllerDelegateLinux::DaemonControllerDelegateLinux() {
126 } 125 }
127 126
128 DaemonControllerDelegateLinux::~DaemonControllerDelegateLinux() { 127 DaemonControllerDelegateLinux::~DaemonControllerDelegateLinux() {
129 } 128 }
130 129
131 DaemonController::State DaemonControllerDelegateLinux::GetState() { 130 DaemonController::State DaemonControllerDelegateLinux::GetState() {
132 std::vector<std::string> args; 131 base::FilePath script_path;
133 args.push_back("--check-running"); 132 if (!GetScriptPath(&script_path)) {
133 return DaemonController::STATE_NOT_IMPLEMENTED;
134 }
135 CommandLine command_line(script_path);
136 command_line.AppendArg("--get-status");
137
138 std::string status;
134 int exit_code = 0; 139 int exit_code = 0;
135 if (!RunHostScript(args, &exit_code)) { 140 bool result =
141 base::GetAppOutputWithExitCode(command_line, &status, &exit_code);
142 if (!result) {
136 // TODO(jamiewalch): When we have a good story for installing, return 143 // TODO(jamiewalch): When we have a good story for installing, return
137 // NOT_INSTALLED rather than NOT_IMPLEMENTED (the former suppresses 144 // NOT_INSTALLED rather than NOT_IMPLEMENTED (the former suppresses
138 // the relevant UI in the web-app). 145 // the relevant UI in the web-app).
139 return DaemonController::STATE_NOT_IMPLEMENTED; 146 return DaemonController::STATE_NOT_IMPLEMENTED;
140 } 147 }
141 148
142 if (exit_code == 0) { 149 if (exit_code != 0) {
150 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString()
151 << "\". Exit code: " << exit_code;
152 return DaemonController::STATE_UNKNOWN;
153 }
154
155 TrimWhitespaceASCII(status, TRIM_ALL, &status);
156
157 if (status == "STARTED") {
143 return DaemonController::STATE_STARTED; 158 return DaemonController::STATE_STARTED;
159 } else if (status == "STOPPED") {
160 return DaemonController::STATE_STOPPED;
161 } else if (status == "NOT_IMPLEMENTED") {
162 return DaemonController::STATE_NOT_IMPLEMENTED;
144 } else { 163 } else {
145 return DaemonController::STATE_STOPPED; 164 LOG(ERROR) << "Unknown status string returned from \""
165 << command_line.GetCommandLineString()
166 << "\": " << status;
167 return DaemonController::STATE_UNKNOWN;
146 } 168 }
147 } 169 }
148 170
149 scoped_ptr<base::DictionaryValue> DaemonControllerDelegateLinux::GetConfig() { 171 scoped_ptr<base::DictionaryValue> DaemonControllerDelegateLinux::GetConfig() {
150 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 172 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
151 173
152 if (GetState() != DaemonController::STATE_NOT_IMPLEMENTED) { 174 if (GetState() != DaemonController::STATE_NOT_IMPLEMENTED) {
153 JsonHostConfig config(GetConfigPath()); 175 JsonHostConfig config(GetConfigPath());
154 if (config.Read()) { 176 if (config.Read()) {
155 std::string value; 177 std::string value;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return consent; 310 return consent;
289 } 311 }
290 312
291 scoped_refptr<DaemonController> DaemonController::Create() { 313 scoped_refptr<DaemonController> DaemonController::Create() {
292 scoped_ptr<DaemonController::Delegate> delegate( 314 scoped_ptr<DaemonController::Delegate> delegate(
293 new DaemonControllerDelegateLinux()); 315 new DaemonControllerDelegateLinux());
294 return new DaemonController(delegate.Pass()); 316 return new DaemonController(delegate.Pass());
295 } 317 }
296 318
297 } // namespace remoting 319 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/tools/me2me_virtual_host.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698