| 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 "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 Loading... |
| 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 for (base::TimeDelta time_out = default_time_out; |
| 205 time_out = std::min(time_out * 2, max_time_out)) { | 204 time_out = std::min(time_out * 2, max_time_out)) { |
| 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); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 LOG(ERROR) << "Chrome launch failed."; | 322 LOG(ERROR) << "Chrome launch failed."; |
| 324 return std::string(); | 323 return std::string(); |
| 325 } | 324 } |
| 326 if (!json.empty()) { | 325 if (!json.empty()) { |
| 327 // Close chrome because Service State is ready. | 326 // Close chrome because Service State is ready. |
| 328 CloseChrome(chrome_process.Pass(), thread_id); | 327 CloseChrome(chrome_process.Pass(), thread_id); |
| 329 return json; | 328 return json; |
| 330 } | 329 } |
| 331 } | 330 } |
| 332 } | 331 } |
| OLD | NEW |