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

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

Issue 1558633002: Cleanup: Remove double semicolons. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Convert CP code to a while loop, fix nit Created 4 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/json/json_reader.h" 13 #include "base/json/json_reader.h"
14 #include "base/json/json_writer.h" 14 #include "base/json/json_writer.h"
15 #include "base/process/process.h" 15 #include "base/process/process.h"
16 #include "base/process/process.h"
17 #include "base/values.h" 16 #include "base/values.h"
18 #include "base/win/registry.h" 17 #include "base/win/registry.h"
19 #include "base/win/scoped_handle.h" 18 #include "base/win/scoped_handle.h"
20 #include "base/win/scoped_process_information.h" 19 #include "base/win/scoped_process_information.h"
21 #include "chrome/common/chrome_constants.h" 20 #include "chrome/common/chrome_constants.h"
22 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
24 #include "chrome/installer/launcher_support/chrome_launcher_support.h" 23 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
25 #include "cloud_print/common/win/cloud_print_utils.h" 24 #include "cloud_print/common/win/cloud_print_utils.h"
26 #include "cloud_print/service/service_constants.h" 25 #include "cloud_print/service/service_constants.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void ChromeLauncher::Stop() { 193 void ChromeLauncher::Stop() {
195 stop_event_.Signal(); 194 stop_event_.Signal();
196 thread_->Join(); 195 thread_->Join();
197 thread_.reset(); 196 thread_.reset();
198 } 197 }
199 198
200 void ChromeLauncher::Run() { 199 void ChromeLauncher::Run() {
201 const base::TimeDelta default_time_out = base::TimeDelta::FromSeconds(1); 200 const base::TimeDelta default_time_out = base::TimeDelta::FromSeconds(1);
202 const base::TimeDelta max_time_out = base::TimeDelta::FromHours(1); 201 const base::TimeDelta max_time_out = base::TimeDelta::FromHours(1);
203 202
204 for (base::TimeDelta time_out = default_time_out;; 203 base::TimeDelta time_out = default_time_out;
tfarina 2015/12/30 20:32:59 really? Maybe just add a space after the first ';'
Lei Zhang 2015/12/30 20:59:59 Meh. For-loops without a condition are harder to r
205 time_out = std::min(time_out * 2, max_time_out)) { 204 while (1) {
206 base::FilePath chrome_path = 205 base::FilePath chrome_path =
207 chrome_launcher_support::GetAnyChromePath(false /* is_sxs */); 206 chrome_launcher_support::GetAnyChromePath(false /* is_sxs */);
208 207
209 if (!chrome_path.empty()) { 208 if (!chrome_path.empty()) {
210 base::CommandLine cmd(chrome_path); 209 base::CommandLine cmd(chrome_path);
211 CopyChromeSwitchesFromCurrentProcess(&cmd); 210 CopyChromeSwitchesFromCurrentProcess(&cmd);
212 211
213 // Required switches. 212 // Required switches.
214 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess); 213 cmd.AppendSwitchASCII(switches::kProcessType, switches::kServiceProcess);
215 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_); 214 cmd.AppendSwitchPath(switches::kUserDataDir, user_data_);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } else { 246 } else {
248 LOG(ERROR) << "Error waiting Chrome (" << ::GetLastError() << ")."; 247 LOG(ERROR) << "Error waiting Chrome (" << ::GetLastError() << ").";
249 } 248 }
250 if (base::Time::Now() - started > base::TimeDelta::FromHours(1)) { 249 if (base::Time::Now() - started > base::TimeDelta::FromHours(1)) {
251 // Reset timeout because process worked long enough. 250 // Reset timeout because process worked long enough.
252 time_out = default_time_out; 251 time_out = default_time_out;
253 } 252 }
254 } 253 }
255 if (stop_event_.TimedWait(time_out)) 254 if (stop_event_.TimedWait(time_out))
256 break; 255 break;
256
257 time_out = std::min(time_out * 2, max_time_out);
257 } 258 }
258 } 259 }
259 260
260 std::string ChromeLauncher::CreateServiceStateFile( 261 std::string ChromeLauncher::CreateServiceStateFile(
261 const std::string& proxy_id, 262 const std::string& proxy_id,
262 const std::vector<std::string>& printers) { 263 const std::vector<std::string>& printers) {
263 base::ScopedTempDir temp_user_data; 264 base::ScopedTempDir temp_user_data;
264 if (!temp_user_data.CreateUniqueTempDir()) { 265 if (!temp_user_data.CreateUniqueTempDir()) {
265 LOG(ERROR) << "Can't create temp dir."; 266 LOG(ERROR) << "Can't create temp dir.";
266 return std::string(); 267 return std::string();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 LOG(ERROR) << "Chrome launch failed."; 324 LOG(ERROR) << "Chrome launch failed.";
324 return std::string(); 325 return std::string();
325 } 326 }
326 if (!json.empty()) { 327 if (!json.empty()) {
327 // Close chrome because Service State is ready. 328 // Close chrome because Service State is ready.
328 CloseChrome(chrome_process.Pass(), thread_id); 329 CloseChrome(chrome_process.Pass(), thread_id);
329 return json; 330 return json;
330 } 331 }
331 } 332 }
332 } 333 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698