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

Side by Side Diff: remoting/host/plugin/daemon_controller_linux.cc

Issue 10909090: Implement DaemonController::GetVersion() method on Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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/host/remoting_me2me_host.cc » ('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 #include "remoting/host/plugin/daemon_controller.h" 5 #include "remoting/host/plugin/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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 private: 70 private:
71 FilePath GetConfigPath(); 71 FilePath GetConfigPath();
72 72
73 void DoGetConfig(const GetConfigCallback& callback); 73 void DoGetConfig(const GetConfigCallback& callback);
74 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config, 74 void DoSetConfigAndStart(scoped_ptr<base::DictionaryValue> config,
75 const CompletionCallback& done); 75 const CompletionCallback& done);
76 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config, 76 void DoUpdateConfig(scoped_ptr<base::DictionaryValue> config,
77 const CompletionCallback& done_callback); 77 const CompletionCallback& done_callback);
78 void DoStop(const CompletionCallback& done_callback); 78 void DoStop(const CompletionCallback& done_callback);
79 void DoGetVersion(const GetVersionCallback& done_callback);
79 80
80 base::Thread file_io_thread_; 81 base::Thread file_io_thread_;
81 82
82 DISALLOW_COPY_AND_ASSIGN(DaemonControllerLinux); 83 DISALLOW_COPY_AND_ASSIGN(DaemonControllerLinux);
83 }; 84 };
84 85
85 DaemonControllerLinux::DaemonControllerLinux() 86 DaemonControllerLinux::DaemonControllerLinux()
86 : file_io_thread_("DaemonControllerFileIO") { 87 : file_io_thread_("DaemonControllerFileIO") {
87 file_io_thread_.Start(); 88 file_io_thread_.Start();
88 } 89 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 &DaemonControllerLinux::DoStop, base::Unretained(this), 188 &DaemonControllerLinux::DoStop, base::Unretained(this),
188 done_callback)); 189 done_callback));
189 } 190 }
190 191
191 void DaemonControllerLinux::SetWindow(void* window_handle) { 192 void DaemonControllerLinux::SetWindow(void* window_handle) {
192 // noop 193 // noop
193 } 194 }
194 195
195 void DaemonControllerLinux::GetVersion( 196 void DaemonControllerLinux::GetVersion(
196 const GetVersionCallback& done_callback) { 197 const GetVersionCallback& done_callback) {
197 // TODO(sergeyu): Implement this method. 198 file_io_thread_.message_loop()->PostTask(FROM_HERE, base::Bind(
198 NOTIMPLEMENTED(); 199 &DaemonControllerLinux::DoGetVersion, base::Unretained(this),
199 done_callback.Run(""); 200 done_callback));
200 } 201 }
201 202
202 FilePath DaemonControllerLinux::GetConfigPath() { 203 FilePath DaemonControllerLinux::GetConfigPath() {
203 std::string filename = "host#" + GetMd5(net::GetHostName()) + ".json"; 204 std::string filename = "host#" + GetMd5(net::GetHostName()) + ".json";
204 return file_util::GetHomeDir(). 205 return file_util::GetHomeDir().
205 Append(".config/chrome-remote-desktop").Append(filename); 206 Append(".config/chrome-remote-desktop").Append(filename);
206 } 207 }
207 208
208 void DaemonControllerLinux::DoGetConfig(const GetConfigCallback& callback) { 209 void DaemonControllerLinux::DoGetConfig(const GetConfigCallback& callback) {
209 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 210 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue());
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 int exit_code = 0; 296 int exit_code = 0;
296 AsyncResult result; 297 AsyncResult result;
297 if (RunHostScript(args, &exit_code)) { 298 if (RunHostScript(args, &exit_code)) {
298 result = (exit_code == 0) ? RESULT_OK : RESULT_FAILED; 299 result = (exit_code == 0) ? RESULT_OK : RESULT_FAILED;
299 } else { 300 } else {
300 result = RESULT_FAILED; 301 result = RESULT_FAILED;
301 } 302 }
302 done_callback.Run(result); 303 done_callback.Run(result);
303 } 304 }
304 305
306 void DaemonControllerLinux::DoGetVersion(
307 const GetVersionCallback& done_callback) {
308 FilePath script_path;
309 if (!GetScriptPath(&script_path)) {
310 done_callback.Run("");
311 return;
312 }
313 CommandLine command_line(script_path);
314 command_line.AppendArg("--host-version");
315
316 std::string version;
317 int exit_code = 0;
318 int result =
319 base::GetAppOutputWithExitCode(command_line, &version, &exit_code);
320 if (!result || exit_code != 0) {
321 LOG(ERROR) << "Failed to run \"" << command_line.GetCommandLineString()
322 << "\". Exit code: " << exit_code;
323 done_callback.Run("");
324 return;
325 }
326
327 TrimWhitespaceASCII(version, TRIM_ALL, &version);
328 if (!ContainsOnlyChars(version, "0123456789.")) {
329 LOG(ERROR) << "Received invalid host version number: " << version;
330 done_callback.Run("");
331 return;
332 }
333
334 done_callback.Run(version);
335 }
336
305 } // namespace 337 } // namespace
306 338
307 scoped_ptr<DaemonController> remoting::DaemonController::Create() { 339 scoped_ptr<DaemonController> remoting::DaemonController::Create() {
308 return scoped_ptr<DaemonController>(new DaemonControllerLinux()); 340 return scoped_ptr<DaemonController>(new DaemonControllerLinux());
309 } 341 }
310 342
311 } // namespace remoting 343 } // namespace remoting
OLDNEW
« no previous file with comments | « no previous file | remoting/host/remoting_me2me_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698