Chromium Code Reviews| Index: remoting/host/plugin/daemon_controller_linux.cc |
| diff --git a/remoting/host/plugin/daemon_controller_linux.cc b/remoting/host/plugin/daemon_controller_linux.cc |
| index 71857cd74bd2d2a3a229cac89b836c27678b763f..092cb74cec5298221e0f34fc7aafef9f2664a4e7 100644 |
| --- a/remoting/host/plugin/daemon_controller_linux.cc |
| +++ b/remoting/host/plugin/daemon_controller_linux.cc |
| @@ -76,6 +76,7 @@ class DaemonControllerLinux : public remoting::DaemonController { |
| void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, |
| const CompletionCallback& done_callback); |
| void DoStop(const CompletionCallback& done_callback); |
| + void DoGetVersion(const GetVersionCallback& done_callback); |
| base::Thread file_io_thread_; |
| @@ -194,9 +195,9 @@ void DaemonControllerLinux::SetWindow(void* window_handle) { |
| void DaemonControllerLinux::GetVersion( |
| const GetVersionCallback& done_callback) { |
| - // TODO(sergeyu): Implement this method. |
| - NOTIMPLEMENTED(); |
| - done_callback.Run(""); |
| + file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind( |
| + &DaemonControllerLinux::DoGetVersion, base::Unretained(this), |
| + done_callback)); |
| } |
| FilePath DaemonControllerLinux::GetConfigPath() { |
| @@ -302,6 +303,36 @@ void DaemonControllerLinux::DoStop(const CompletionCallback& done_callback) { |
| done_callback.Run(result); |
| } |
| +void DaemonControllerLinux::DoGetVersion( |
| + const GetVersionCallback& done_callback) { |
| + FilePath script_path; |
| + if (!GetScriptPath(&script_path)) { |
| + done_callback.Run(""); |
| + return; |
| + } |
| + CommandLine command_line(script_path); |
| + command_line.AppendArg("--host-version"); |
| + |
| + std::string output; |
|
Jamie
2012/09/06 01:29:50
TrimWhitespaceASCII states that it's safe to use t
Sergey Ulanov
2012/09/06 19:31:58
Done.
|
| + int exit_code; |
| + int result = |
| + base::GetAppOutputWithExitCode(command_line, &output, &exit_code); |
| + if (!result) { |
|
Jamie
2012/09/06 01:29:50
LOG(ERROR) here?
Sergey Ulanov
2012/09/06 19:31:58
Done.
|
| + done_callback.Run(""); |
| + return; |
| + } |
| + |
|
Jamie
2012/09/06 01:29:50
Perhaps add a test for exit_code being zero?
Sergey Ulanov
2012/09/06 19:31:58
Done.
|
| + std::string version; |
| + TrimWhitespaceASCII(output, TRIM_ALL, &version); |
| + if (!ContainsOnlyChars(version, "0123456789.")) { |
| + LOG(ERROR) << "Received invalid host version number: " << version; |
| + done_callback.Run(""); |
| + return; |
| + } |
| + |
| + done_callback.Run(version); |
| +} |
| + |
| } // namespace |
| scoped_ptr<DaemonController> remoting::DaemonController::Create() { |