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

Side by Side Diff: cloud_print/service/win/chrome_launcher.cc

Issue 735053002: Prefix CommandLine usage with base namespace (Part 7: cloud_print/) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 (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 "cloud_print/service/win/chrome_launcher.h" 5 #include "cloud_print/service/win/chrome_launcher.h"
6 6
7 #include "base/base_switches.h" 7 #include "base/base_switches.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 // Close Chrome browser window. 61 // Close Chrome browser window.
62 void CloseChrome(HANDLE process, DWORD thread_id) { 62 void CloseChrome(HANDLE process, DWORD thread_id) {
63 CloseAllProcessWindows(process); 63 CloseAllProcessWindows(process);
64 if (WAIT_OBJECT_0 == ::WaitForSingleObject(process, kShutdownTimeoutMs)) { 64 if (WAIT_OBJECT_0 == ::WaitForSingleObject(process, kShutdownTimeoutMs)) {
65 return; 65 return;
66 } 66 }
67 ShutdownChrome(process, thread_id); 67 ShutdownChrome(process, thread_id);
68 } 68 }
69 69
70 bool LaunchProcess(const CommandLine& cmdline, 70 bool LaunchProcess(const base::CommandLine& cmdline,
71 base::win::ScopedHandle* process_handle, 71 base::win::ScopedHandle* process_handle,
72 DWORD* thread_id) { 72 DWORD* thread_id) {
73 STARTUPINFO startup_info = {}; 73 STARTUPINFO startup_info = {};
74 startup_info.cb = sizeof(startup_info); 74 startup_info.cb = sizeof(startup_info);
75 startup_info.dwFlags = STARTF_USESHOWWINDOW; 75 startup_info.dwFlags = STARTF_USESHOWWINDOW;
76 startup_info.wShowWindow = SW_SHOW; 76 startup_info.wShowWindow = SW_SHOW;
77 77
78 PROCESS_INFORMATION temp_process_info = {}; 78 PROCESS_INFORMATION temp_process_info = {};
79 base::FilePath::StringType writable_cmdline_str( 79 base::FilePath::StringType writable_cmdline_str(
80 cmdline.GetCommandLineString()); 80 cmdline.GetCommandLineString());
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 if (!key.Valid()) 142 if (!key.Valid())
143 return; 143 return;
144 std::vector<base::string16> to_delete; 144 std::vector<base::string16> to_delete;
145 145
146 base::FilePath abs_user_data_dir = base::MakeAbsoluteFilePath(user_data_dir); 146 base::FilePath abs_user_data_dir = base::MakeAbsoluteFilePath(user_data_dir);
147 147
148 { 148 {
149 base::win::RegistryValueIterator value(HKEY_CURRENT_USER, kAutoRunKeyPath); 149 base::win::RegistryValueIterator value(HKEY_CURRENT_USER, kAutoRunKeyPath);
150 for (; value.Valid(); ++value) { 150 for (; value.Valid(); ++value) {
151 if (value.Type() == REG_SZ && value.Value()) { 151 if (value.Type() == REG_SZ && value.Value()) {
152 CommandLine cmd = CommandLine::FromString(value.Value()); 152 base::CommandLine cmd = base::CommandLine::FromString(value.Value());
153 if (cmd.GetSwitchValueASCII(switches::kProcessType) == 153 if (cmd.GetSwitchValueASCII(switches::kProcessType) ==
154 switches::kServiceProcess && 154 switches::kServiceProcess &&
155 cmd.HasSwitch(switches::kUserDataDir)) { 155 cmd.HasSwitch(switches::kUserDataDir)) {
156 base::FilePath path_from_reg = base::MakeAbsoluteFilePath( 156 base::FilePath path_from_reg = base::MakeAbsoluteFilePath(
157 cmd.GetSwitchValuePath(switches::kUserDataDir)); 157 cmd.GetSwitchValuePath(switches::kUserDataDir));
158 if (path_from_reg == abs_user_data_dir) { 158 if (path_from_reg == abs_user_data_dir) {
159 to_delete.push_back(value.Name()); 159 to_delete.push_back(value.Name());
160 } 160 }
161 } 161 }
162 } 162 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 void ChromeLauncher::Run() { 195 void ChromeLauncher::Run() {
196 const base::TimeDelta default_time_out = base::TimeDelta::FromSeconds(1); 196 const base::TimeDelta default_time_out = base::TimeDelta::FromSeconds(1);
197 const base::TimeDelta max_time_out = base::TimeDelta::FromHours(1); 197 const base::TimeDelta max_time_out = base::TimeDelta::FromHours(1);
198 198
199 for (base::TimeDelta time_out = default_time_out;; 199 for (base::TimeDelta time_out = default_time_out;;
200 time_out = std::min(time_out * 2, max_time_out)) { 200 time_out = std::min(time_out * 2, max_time_out)) {
201 base::FilePath chrome_path = chrome_launcher_support::GetAnyChromePath(); 201 base::FilePath chrome_path = chrome_launcher_support::GetAnyChromePath();
202 202
203 if (!chrome_path.empty()) { 203 if (!chrome_path.empty()) {
204 CommandLine cmd(chrome_path); 204 base::CommandLine cmd(chrome_path);
205 CopyChromeSwitchesFromCurrentProcess(&cmd); 205 CopyChromeSwitchesFromCurrentProcess(&cmd);
206 206
207 // Required switches. 207 // Required switches.
208 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess); 208 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess);
209 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_); 209 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_);
210 cmd.AppendSwitch(switches::kNoServiceAutorun); 210 cmd.AppendSwitch(switches::kNoServiceAutorun);
211 211
212 // Optional. 212 // Optional.
213 cmd.AppendSwitch(switches::kAutoLaunchAtStartup); 213 cmd.AppendSwitch(switches::kAutoLaunchAtStartup);
214 cmd.AppendSwitch(switches::kDisableDefaultApps); 214 cmd.AppendSwitch(switches::kDisableDefaultApps);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 std::string printers_json; 271 std::string printers_json;
272 base::JSONWriter::Write(&printer_list, &printers_json); 272 base::JSONWriter::Write(&printer_list, &printers_json);
273 size_t written = base::WriteFile(printers_file, 273 size_t written = base::WriteFile(printers_file,
274 printers_json.c_str(), 274 printers_json.c_str(),
275 printers_json.size()); 275 printers_json.size());
276 if (written != printers_json.size()) { 276 if (written != printers_json.size()) {
277 LOG(ERROR) << "Can't write file."; 277 LOG(ERROR) << "Can't write file.";
278 return std::string(); 278 return std::string();
279 } 279 }
280 280
281 CommandLine cmd(chrome_path); 281 base::CommandLine cmd(chrome_path);
282 CopyChromeSwitchesFromCurrentProcess(&cmd); 282 CopyChromeSwitchesFromCurrentProcess(&cmd);
283 cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path()); 283 cmd.AppendSwitchPath(switches::kUserDataDir, temp_user_data.path());
284 cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file); 284 cmd.AppendSwitchPath(switches::kCloudPrintSetupProxy, printers_file);
285 cmd.AppendSwitch(switches::kNoServiceAutorun); 285 cmd.AppendSwitch(switches::kNoServiceAutorun);
286 286
287 // Optional. 287 // Optional.
288 cmd.AppendSwitch(switches::kDisableDefaultApps); 288 cmd.AppendSwitch(switches::kDisableDefaultApps);
289 cmd.AppendSwitch(switches::kDisableExtensions); 289 cmd.AppendSwitch(switches::kDisableExtensions);
290 cmd.AppendSwitch(switches::kDisableSync); 290 cmd.AppendSwitch(switches::kDisableSync);
291 cmd.AppendSwitch(switches::kNoDefaultBrowserCheck); 291 cmd.AppendSwitch(switches::kNoDefaultBrowserCheck);
(...skipping 21 matching lines...) Expand all
313 LOG(ERROR) << "Chrome launch failed."; 313 LOG(ERROR) << "Chrome launch failed.";
314 return std::string(); 314 return std::string();
315 } 315 }
316 if (!json.empty()) { 316 if (!json.empty()) {
317 // Close chrome because Service State is ready. 317 // Close chrome because Service State is ready.
318 CloseChrome(chrome_handle.Get(), thread_id); 318 CloseChrome(chrome_handle.Get(), thread_id);
319 return json; 319 return json;
320 } 320 }
321 } 321 }
322 } 322 }
OLDNEW
« no previous file with comments | « cloud_print/gcp20/prototype/privet_http_server.cc ('k') | cloud_print/service/win/cloud_print_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698