| 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 #include "remoting/host/setup/daemon_controller.h" | 5 #include "remoting/host/setup/daemon_controller.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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } else { | 311 } else { |
| 312 result = RESULT_FAILED; | 312 result = RESULT_FAILED; |
| 313 } | 313 } |
| 314 done_callback.Run(result); | 314 done_callback.Run(result); |
| 315 } | 315 } |
| 316 | 316 |
| 317 void DaemonControllerLinux::DoGetVersion( | 317 void DaemonControllerLinux::DoGetVersion( |
| 318 const GetVersionCallback& done_callback) { | 318 const GetVersionCallback& done_callback) { |
| 319 base::FilePath script_path; | 319 base::FilePath script_path; |
| 320 if (!GetScriptPath(&script_path)) { | 320 if (!GetScriptPath(&script_path)) { |
| 321 done_callback.Run(""); | 321 done_callback.Run(std::string()); |
| 322 return; | 322 return; |
| 323 } | 323 } |
| 324 CommandLine command_line(script_path); | 324 CommandLine command_line(script_path); |
| 325 command_line.AppendArg("--host-version"); | 325 command_line.AppendArg("--host-version"); |
| 326 | 326 |
| 327 std::string version; | 327 std::string version; |
| 328 int exit_code = 0; | 328 int exit_code = 0; |
| 329 int result = | 329 int result = |
| 330 base::GetAppOutputWithExitCode(command_line, &version, &exit_code); | 330 base::GetAppOutputWithExitCode(command_line, &version, &exit_code); |
| 331 if (!result || exit_code != 0) { | 331 if (!result || exit_code != 0) { |
| 332 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString() | 332 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString() |
| 333 << "\". Exit code: " << exit_code; | 333 << "\". Exit code: " << exit_code; |
| 334 done_callback.Run(""); | 334 done_callback.Run(std::string()); |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 | 337 |
| 338 TrimWhitespaceASCII(version, TRIM_ALL, &version); | 338 TrimWhitespaceASCII(version, TRIM_ALL, &version); |
| 339 if (!ContainsOnlyChars(version, "0123456789.")) { | 339 if (!ContainsOnlyChars(version, "0123456789.")) { |
| 340 LOG(ERROR) << "Received invalid host version number: " << version; | 340 LOG(ERROR) << "Received invalid host version number: " << version; |
| 341 done_callback.Run(""); | 341 done_callback.Run(std::string()); |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 | 344 |
| 345 done_callback.Run(version); | 345 done_callback.Run(version); |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace | 348 } // namespace |
| 349 | 349 |
| 350 scoped_ptr<DaemonController> remoting::DaemonController::Create() { | 350 scoped_ptr<DaemonController> remoting::DaemonController::Create() { |
| 351 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); | 351 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); |
| 352 } | 352 } |
| 353 | 353 |
| 354 } // namespace remoting | 354 } // namespace remoting |
| OLD | NEW |