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

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

Issue 685103004: Refactor chrome_launcher_support::GetAnyChromePath. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix app_installer compile. Created 5 years, 11 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 (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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 thread_->Join(); 191 thread_->Join();
192 thread_.reset(); 192 thread_.reset();
193 } 193 }
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 =
202 chrome_launcher_support::GetAnyChromePath(false /* is_sxs */);
202 203
203 if (!chrome_path.empty()) { 204 if (!chrome_path.empty()) {
204 base::CommandLine cmd(chrome_path); 205 base::CommandLine cmd(chrome_path);
205 CopyChromeSwitchesFromCurrentProcess(&cmd); 206 CopyChromeSwitchesFromCurrentProcess(&cmd);
206 207
207 // Required switches. 208 // Required switches.
208 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess); 209 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess);
209 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_); 210 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_);
210 cmd.AppendSwitch(switches::kNoServiceAutorun); 211 cmd.AppendSwitch(switches::kNoServiceAutorun);
211 212
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 252
252 std::string ChromeLauncher::CreateServiceStateFile( 253 std::string ChromeLauncher::CreateServiceStateFile(
253 const std::string& proxy_id, 254 const std::string& proxy_id,
254 const std::vector<std::string>& printers) { 255 const std::vector<std::string>& printers) {
255 base::ScopedTempDir temp_user_data; 256 base::ScopedTempDir temp_user_data;
256 if (!temp_user_data.CreateUniqueTempDir()) { 257 if (!temp_user_data.CreateUniqueTempDir()) {
257 LOG(ERROR) << "Can't create temp dir."; 258 LOG(ERROR) << "Can't create temp dir.";
258 return std::string(); 259 return std::string();
259 } 260 }
260 261
261 base::FilePath chrome_path = chrome_launcher_support::GetAnyChromePath(); 262 base::FilePath chrome_path =
263 chrome_launcher_support::GetAnyChromePath(false /* is_sxs */);
262 if (chrome_path.empty()) { 264 if (chrome_path.empty()) {
263 LOG(ERROR) << "Can't find Chrome."; 265 LOG(ERROR) << "Can't find Chrome.";
264 return std::string(); 266 return std::string();
265 } 267 }
266 268
267 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json"); 269 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json");
268 270
269 base::ListValue printer_list; 271 base::ListValue printer_list;
270 printer_list.AppendStrings(printers); 272 printer_list.AppendStrings(printers);
271 std::string printers_json; 273 std::string printers_json;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 LOG(ERROR) << "Chrome launch failed."; 315 LOG(ERROR) << "Chrome launch failed.";
314 return std::string(); 316 return std::string();
315 } 317 }
316 if (!json.empty()) { 318 if (!json.empty()) {
317 // Close chrome because Service State is ready. 319 // Close chrome because Service State is ready.
318 CloseChrome(chrome_handle.Get(), thread_id); 320 CloseChrome(chrome_handle.Get(), thread_id);
319 return json; 321 return json;
320 } 322 }
321 } 323 }
322 } 324 }
OLDNEW
« no previous file with comments | « chrome/installer/launcher_support/chrome_launcher_support.cc ('k') | cloud_print/service/win/service_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698