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

Unified Diff: remoting/host/plugin/daemon_controller_linux.cc

Issue 10824286: Fix DaemonControllerLinux::SetConfigAndStart() to reload config automatically. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/in_memory_host_config.cc ('k') | remoting/host/plugin/daemon_controller_mac.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a7698653bce9842627cf4d8a7bb92f924c85c163..133992bbd796246627ceb0e5607ba82afec8f7e9 100644
--- a/remoting/host/plugin/daemon_controller_linux.cc
+++ b/remoting/host/plugin/daemon_controller_linux.cc
@@ -43,15 +43,6 @@ std::string GetMd5(const std::string& value) {
return StringToLowerASCII(base::HexEncode(digest.a, sizeof(digest.a)));
}
-// TODO(sergeyu): This is a very hacky implementation of
-// DaemonController interface for linux. Current version works, but
-// there are sevaral problems with it:
-// * All calls are executed synchronously, even though this API is
-// supposed to be asynchronous.
-// * The host is configured by passing configuration data as CL
-// argument - this is obviously not secure.
-// Rewrite this code to solve these two problems.
-// http://crbug.com/120950 .
class DaemonControllerLinux : public remoting::DaemonController {
public:
DaemonControllerLinux();
@@ -235,19 +226,9 @@ void DaemonControllerLinux::DoSetConfigAndStart(
scoped_ptr<base::DictionaryValue> config,
const CompletionCallback& done_callback) {
JsonHostConfig config_file(GetConfigPath());
- for (DictionaryValue::key_iterator key(config->begin_keys());
- key != config->end_keys(); ++key) {
- std::string value;
- if (!config->GetString(*key, &value)) {
- LOG(ERROR) << *key << " is not a string.";
- done_callback.Run(RESULT_FAILED);
- return;
- }
- config_file.SetString(*key, value);
- }
-
- bool success = config_file.Save();
- if (!success) {
+ if (!config_file.CopyFrom(config.get()) ||
+ !config_file.Save()) {
+ LOG(ERROR) << "Failed to update config file.";
done_callback.Run(RESULT_FAILED);
return;
}
@@ -268,23 +249,25 @@ void DaemonControllerLinux::DoUpdateConfig(
scoped_ptr<base::DictionaryValue> config,
const CompletionCallback& done_callback) {
JsonHostConfig config_file(GetConfigPath());
- if (!config_file.Read()) {
+ if (!config_file.Read() ||
+ !config_file.CopyFrom(config.get()) ||
+ !config_file.Save()) {
+ LOG(ERROR) << "Failed to update config file.";
done_callback.Run(RESULT_FAILED);
+ return;
}
- for (DictionaryValue::key_iterator key(config->begin_keys());
- key != config->end_keys(); ++key) {
- std::string value;
- if (!config->GetString(*key, &value)) {
- LOG(ERROR) << *key << " is not a string.";
- done_callback.Run(RESULT_FAILED);
- return;
- }
- config_file.SetString(*key, value);
+ std::vector<std::string> args;
+ args.push_back("--reload");
+ AsyncResult result;
+ int exit_code;
+ if (RunScript(args, &exit_code)) {
+ result = (exit_code == 0) ? RESULT_OK : RESULT_FAILED;
+ } else {
+ result = RESULT_FAILED;
}
- bool success = config_file.Save();
- done_callback.Run(success ? RESULT_OK : RESULT_FAILED);
- // TODO(sergeyu): Send signal to the daemon to restart the host.
+
+ done_callback.Run(result);
}
void DaemonControllerLinux::DoStop(const CompletionCallback& done_callback) {
« no previous file with comments | « remoting/host/in_memory_host_config.cc ('k') | remoting/host/plugin/daemon_controller_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698