| 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/plugin/daemon_controller.h" | 5 #include "remoting/host/plugin/daemon_controller.h" |
| 6 | 6 |
| 7 #include <launch.h> | 7 #include <launch.h> |
| 8 #include <sys/types.h> | 8 #include <sys/types.h> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 done_callback.Run(RESULT_FAILED); | 129 done_callback.Run(RESULT_FAILED); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void DaemonControllerMac::Stop(const CompletionCallback& done_callback) { | 132 void DaemonControllerMac::Stop(const CompletionCallback& done_callback) { |
| 133 auth_thread_.message_loop_proxy()->PostTask( | 133 auth_thread_.message_loop_proxy()->PostTask( |
| 134 FROM_HERE, base::Bind( | 134 FROM_HERE, base::Bind( |
| 135 &DaemonControllerMac::DoStop, base::Unretained(this), done_callback)); | 135 &DaemonControllerMac::DoStop, base::Unretained(this), done_callback)); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) { | 138 void DaemonControllerMac::DoGetConfig(const GetConfigCallback& callback) { |
| 139 JsonHostConfig host_config(FilePath(kHostConfigFile), | 139 FilePath config_path(kHostConfigFile); |
| 140 base::MessageLoopProxy::current()); | 140 JsonHostConfig host_config(config_path); |
| 141 host_config.Read(); | 141 scoped_ptr<base::DictionaryValue> config; |
| 142 | 142 |
| 143 scoped_ptr<base::DictionaryValue> config(new base::DictionaryValue()); | 143 if (host_config.Read()) { |
| 144 | 144 config.reset(new base::DictionaryValue()); |
| 145 const char* key = "host_id"; | 145 std::string value; |
| 146 std::string value; | 146 if (host_config.GetString(kHostIdConfigPath, &value)) |
| 147 if (host_config.GetString(key, &value)) | 147 config.get()->SetString(kHostIdConfigPath, value); |
| 148 config.get()->SetString(key, value); | 148 if (host_config.GetString(kXmppLoginConfigPath, &value)) |
| 149 key = "xmpp_login"; | 149 config.get()->SetString(kXmppLoginConfigPath, value); |
| 150 if (host_config.GetString(key, &value)) | 150 } |
| 151 config.get()->SetString(key, value); | |
| 152 | 151 |
| 153 callback.Run(config.Pass()); | 152 callback.Run(config.Pass()); |
| 154 } | 153 } |
| 155 | 154 |
| 156 void DaemonControllerMac::DoSetConfigAndStart( | 155 void DaemonControllerMac::DoSetConfigAndStart( |
| 157 scoped_ptr<base::DictionaryValue> config, | 156 scoped_ptr<base::DictionaryValue> config, |
| 158 const CompletionCallback& done_callback) { | 157 const CompletionCallback& done_callback) { |
| 159 // JsonHostConfig doesn't provide a way to save on the current thread, wait | 158 // JsonHostConfig doesn't provide a way to save on the current thread, wait |
| 160 // for completion, and know whether the save succeeded. Instead, use | 159 // for completion, and know whether the save succeeded. Instead, use |
| 161 // base::JSONWriter directly. | 160 // base::JSONWriter directly. |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return true; | 247 return true; |
| 249 } | 248 } |
| 250 | 249 |
| 251 } // namespace | 250 } // namespace |
| 252 | 251 |
| 253 scoped_ptr<DaemonController> remoting::DaemonController::Create() { | 252 scoped_ptr<DaemonController> remoting::DaemonController::Create() { |
| 254 return scoped_ptr<DaemonController>(new DaemonControllerMac()); | 253 return scoped_ptr<DaemonController>(new DaemonControllerMac()); |
| 255 } | 254 } |
| 256 | 255 |
| 257 } // namespace remoting | 256 } // namespace remoting |
| OLD | NEW |