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

Side by Side Diff: remoting/host/setup/daemon_controller_delegate_linux.cc

Issue 1864213002: Convert //remoting to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mac IWYU Created 4 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_delegate_linux.h" 5 #include "remoting/host/setup/daemon_controller_delegate_linux.h"
6 6
7 #include <unistd.h> 7 #include <unistd.h>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/environment.h" 13 #include "base/environment.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/json/json_writer.h" 16 #include "base/json/json_writer.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/md5.h" 18 #include "base/md5.h"
19 #include "base/memory/ptr_util.h"
19 #include "base/path_service.h" 20 #include "base/path_service.h"
20 #include "base/process/launch.h" 21 #include "base/process/launch.h"
21 #include "base/process/process.h" 22 #include "base/process/process.h"
22 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/string_split.h" 24 #include "base/strings/string_split.h"
24 #include "base/strings/string_util.h" 25 #include "base/strings/string_util.h"
25 #include "base/thread_task_runner_handle.h" 26 #include "base/thread_task_runner_handle.h"
26 #include "base/values.h" 27 #include "base/values.h"
27 #include "build/build_config.h" 28 #include "build/build_config.h"
28 #include "net/base/network_interfaces.h" 29 #include "net/base/network_interfaces.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // Distro. 119 // Distro.
119 return DaemonController::STATE_NOT_IMPLEMENTED; 120 return DaemonController::STATE_NOT_IMPLEMENTED;
120 } else { 121 } else {
121 LOG(ERROR) << "Unknown status string returned from \"" 122 LOG(ERROR) << "Unknown status string returned from \""
122 << command_line.GetCommandLineString() 123 << command_line.GetCommandLineString()
123 << "\": " << status; 124 << "\": " << status;
124 return DaemonController::STATE_UNKNOWN; 125 return DaemonController::STATE_UNKNOWN;
125 } 126 }
126 } 127 }
127 128
128 scoped_ptr<base::DictionaryValue> DaemonControllerDelegateLinux::GetConfig() { 129 std::unique_ptr<base::DictionaryValue>
129 scoped_ptr<base::DictionaryValue> config( 130 DaemonControllerDelegateLinux::GetConfig() {
131 std::unique_ptr<base::DictionaryValue> config(
130 HostConfigFromJsonFile(GetConfigPath())); 132 HostConfigFromJsonFile(GetConfigPath()));
131 if (!config) 133 if (!config)
132 return nullptr; 134 return nullptr;
133 135
134 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 136 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
135 std::string value; 137 std::string value;
136 if (config->GetString(kHostIdConfigPath, &value)) { 138 if (config->GetString(kHostIdConfigPath, &value)) {
137 result->SetString(kHostIdConfigPath, value); 139 result->SetString(kHostIdConfigPath, value);
138 } 140 }
139 if (config->GetString(kXmppLoginConfigPath, &value)) { 141 if (config->GetString(kXmppLoginConfigPath, &value)) {
140 result->SetString(kXmppLoginConfigPath, value); 142 result->SetString(kXmppLoginConfigPath, value);
141 } 143 }
142 return result; 144 return result;
143 } 145 }
144 146
145 void DaemonControllerDelegateLinux::SetConfigAndStart( 147 void DaemonControllerDelegateLinux::SetConfigAndStart(
146 scoped_ptr<base::DictionaryValue> config, 148 std::unique_ptr<base::DictionaryValue> config,
147 bool consent, 149 bool consent,
148 const DaemonController::CompletionCallback& done) { 150 const DaemonController::CompletionCallback& done) {
149 // Add the user to chrome-remote-desktop group first. 151 // Add the user to chrome-remote-desktop group first.
150 std::vector<std::string> args; 152 std::vector<std::string> args;
151 args.push_back("--add-user"); 153 args.push_back("--add-user");
152 if (!RunHostScript(args)) { 154 if (!RunHostScript(args)) {
153 LOG(ERROR) << "Failed to add user to chrome-remote-desktop group."; 155 LOG(ERROR) << "Failed to add user to chrome-remote-desktop group.";
154 done.Run(DaemonController::RESULT_FAILED); 156 done.Run(DaemonController::RESULT_FAILED);
155 return; 157 return;
156 } 158 }
(...skipping 21 matching lines...) Expand all
178 args.clear(); 180 args.clear();
179 args.push_back("--start"); 181 args.push_back("--start");
180 DaemonController::AsyncResult result = DaemonController::RESULT_FAILED; 182 DaemonController::AsyncResult result = DaemonController::RESULT_FAILED;
181 if (RunHostScript(args)) 183 if (RunHostScript(args))
182 result = DaemonController::RESULT_OK; 184 result = DaemonController::RESULT_OK;
183 185
184 done.Run(result); 186 done.Run(result);
185 } 187 }
186 188
187 void DaemonControllerDelegateLinux::UpdateConfig( 189 void DaemonControllerDelegateLinux::UpdateConfig(
188 scoped_ptr<base::DictionaryValue> config, 190 std::unique_ptr<base::DictionaryValue> config,
189 const DaemonController::CompletionCallback& done) { 191 const DaemonController::CompletionCallback& done) {
190 scoped_ptr<base::DictionaryValue> new_config( 192 std::unique_ptr<base::DictionaryValue> new_config(
191 HostConfigFromJsonFile(GetConfigPath())); 193 HostConfigFromJsonFile(GetConfigPath()));
192 if (new_config) 194 if (new_config)
193 new_config->MergeDictionary(config.get()); 195 new_config->MergeDictionary(config.get());
194 if (!new_config || !HostConfigToJsonFile(*new_config, GetConfigPath())) { 196 if (!new_config || !HostConfigToJsonFile(*new_config, GetConfigPath())) {
195 LOG(ERROR) << "Failed to update config file."; 197 LOG(ERROR) << "Failed to update config file.";
196 done.Run(DaemonController::RESULT_FAILED); 198 done.Run(DaemonController::RESULT_FAILED);
197 return; 199 return;
198 } 200 }
199 201
200 std::vector<std::string> args; 202 std::vector<std::string> args;
(...skipping 22 matching lines...) Expand all
223 // http://crbug.com/130678. 225 // http://crbug.com/130678.
224 DaemonController::UsageStatsConsent consent; 226 DaemonController::UsageStatsConsent consent;
225 consent.supported = false; 227 consent.supported = false;
226 consent.allowed = false; 228 consent.allowed = false;
227 consent.set_by_policy = false; 229 consent.set_by_policy = false;
228 return consent; 230 return consent;
229 } 231 }
230 232
231 scoped_refptr<DaemonController> DaemonController::Create() { 233 scoped_refptr<DaemonController> DaemonController::Create() {
232 return new DaemonController( 234 return new DaemonController(
233 make_scoped_ptr(new DaemonControllerDelegateLinux())); 235 base::WrapUnique(new DaemonControllerDelegateLinux()));
234 } 236 }
235 237
236 } // namespace remoting 238 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/setup/daemon_controller_delegate_linux.h ('k') | remoting/host/setup/daemon_controller_delegate_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698