Chromium Code Reviews| 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 "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 Loading... | |
| 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); | |
|
Matt Giuca
2014/10/30 02:54:50
Question for Vitaly: Is there a reason why cloud_p
grt (UTC plus 2)
2014/10/30 16:44:53
The canary population is extremely small, and in m
Vitaly Buka (NO REVIEWS)
2014/10/30 16:46:17
It's OK to try Canary first here and then fallback
Matt Giuca
2015/01/09 06:17:32
Echoing my statements in chrome_launcher_support.c
grt (UTC plus 2)
2015/01/09 17:45:28
Is the only path to installing canary cloud print
Matt Giuca
2015/01/12 06:54:26
I don't know. Vitaly, can you answer this?
TBH I
Vitaly Buka (NO REVIEWS)
2015/01/12 08:24:43
sgtm.
There is no canary build of cloud print ser
grt (UTC plus 2)
2015/01/12 14:02:41
SGTM
| |
| 202 | 203 |
| 203 if (!chrome_path.empty()) { | 204 if (!chrome_path.empty()) { |
| 204 CommandLine cmd(chrome_path); | 205 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 Loading... | |
| 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 = chrome_launcher_support::GetAnyChromePath(false); |
| 262 if (chrome_path.empty()) { | 263 if (chrome_path.empty()) { |
| 263 LOG(ERROR) << "Can't find Chrome."; | 264 LOG(ERROR) << "Can't find Chrome."; |
| 264 return std::string(); | 265 return std::string(); |
| 265 } | 266 } |
| 266 | 267 |
| 267 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json"); | 268 base::FilePath printers_file = temp_user_data.path().Append(L"printers.json"); |
| 268 | 269 |
| 269 base::ListValue printer_list; | 270 base::ListValue printer_list; |
| 270 printer_list.AppendStrings(printers); | 271 printer_list.AppendStrings(printers); |
| 271 std::string printers_json; | 272 std::string printers_json; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 LOG(ERROR) << "Chrome launch failed."; | 314 LOG(ERROR) << "Chrome launch failed."; |
| 314 return std::string(); | 315 return std::string(); |
| 315 } | 316 } |
| 316 if (!json.empty()) { | 317 if (!json.empty()) { |
| 317 // Close chrome because Service State is ready. | 318 // Close chrome because Service State is ready. |
| 318 CloseChrome(chrome_handle.Get(), thread_id); | 319 CloseChrome(chrome_handle.Get(), thread_id); |
| 319 return json; | 320 return json; |
| 320 } | 321 } |
| 321 } | 322 } |
| 322 } | 323 } |
| OLD | NEW |