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

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

Issue 606443003: Remove implicit HANDLE conversions from cloud_print. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | cloud_print/service/win/service_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 cmd.AppendSwitch(switches::kDisableSoftwareRasterizer); 217 cmd.AppendSwitch(switches::kDisableSoftwareRasterizer);
218 cmd.AppendSwitch(switches::kDisableSync); 218 cmd.AppendSwitch(switches::kDisableSync);
219 cmd.AppendSwitch(switches::kNoFirstRun); 219 cmd.AppendSwitch(switches::kNoFirstRun);
220 cmd.AppendSwitch(switches::kNoStartupWindow); 220 cmd.AppendSwitch(switches::kNoStartupWindow);
221 221
222 base::win::ScopedHandle chrome_handle; 222 base::win::ScopedHandle chrome_handle;
223 base::Time started = base::Time::Now(); 223 base::Time started = base::Time::Now();
224 DWORD thread_id = 0; 224 DWORD thread_id = 0;
225 LaunchProcess(cmd, &chrome_handle, &thread_id); 225 LaunchProcess(cmd, &chrome_handle, &thread_id);
226 226
227 HANDLE handles[] = {stop_event_.handle(), chrome_handle}; 227 HANDLE handles[] = { stop_event_.handle(), chrome_handle.Get() };
228 DWORD wait_result = WAIT_TIMEOUT; 228 DWORD wait_result = WAIT_TIMEOUT;
229 while (wait_result == WAIT_TIMEOUT) { 229 while (wait_result == WAIT_TIMEOUT) {
230 cloud_print::SetGoogleUpdateUsage(kGoogleUpdateId); 230 cloud_print::SetGoogleUpdateUsage(kGoogleUpdateId);
231 wait_result = ::WaitForMultipleObjects(arraysize(handles), handles, 231 wait_result = ::WaitForMultipleObjects(arraysize(handles), handles,
232 FALSE, kUsageUpdateTimeoutMs); 232 FALSE, kUsageUpdateTimeoutMs);
233 } 233 }
234 if (wait_result == WAIT_OBJECT_0) { 234 if (wait_result == WAIT_OBJECT_0) {
235 ShutdownChrome(chrome_handle, thread_id); 235 ShutdownChrome(chrome_handle.Get(), thread_id);
236 break; 236 break;
237 } else if (wait_result == WAIT_OBJECT_0 + 1) { 237 } else if (wait_result == WAIT_OBJECT_0 + 1) {
238 LOG(ERROR) << "Chrome process exited."; 238 LOG(ERROR) << "Chrome process exited.";
239 } else { 239 } else {
240 LOG(ERROR) << "Error waiting Chrome (" << ::GetLastError() << ")."; 240 LOG(ERROR) << "Error waiting Chrome (" << ::GetLastError() << ").";
241 } 241 }
242 if (base::Time::Now() - started > base::TimeDelta::FromHours(1)) { 242 if (base::Time::Now() - started > base::TimeDelta::FromHours(1)) {
243 // Reset timeout because process worked long enough. 243 // Reset timeout because process worked long enough.
244 time_out = default_time_out; 244 time_out = default_time_out;
245 } 245 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 cloud_devices::GetCloudPrintEnableWithSigninURL(proxy_id).spec()); 295 cloud_devices::GetCloudPrintEnableWithSigninURL(proxy_id).spec());
296 296
297 base::win::ScopedHandle chrome_handle; 297 base::win::ScopedHandle chrome_handle;
298 DWORD thread_id = 0; 298 DWORD thread_id = 0;
299 if (!LaunchProcess(cmd, &chrome_handle, &thread_id)) { 299 if (!LaunchProcess(cmd, &chrome_handle, &thread_id)) {
300 LOG(ERROR) << "Unable to launch Chrome."; 300 LOG(ERROR) << "Unable to launch Chrome.";
301 return std::string(); 301 return std::string();
302 } 302 }
303 303
304 for (;;) { 304 for (;;) {
305 DWORD wait_result = ::WaitForSingleObject(chrome_handle, 500); 305 DWORD wait_result = ::WaitForSingleObject(chrome_handle.Get(), 500);
306 std::string json = ReadAndUpdateServiceState(temp_user_data.path(), 306 std::string json = ReadAndUpdateServiceState(temp_user_data.path(),
307 proxy_id); 307 proxy_id);
308 if (wait_result == WAIT_OBJECT_0) { 308 if (wait_result == WAIT_OBJECT_0) {
309 // Return what we have because browser is closed. 309 // Return what we have because browser is closed.
310 return json; 310 return json;
311 } 311 }
312 if (wait_result != WAIT_TIMEOUT) { 312 if (wait_result != WAIT_TIMEOUT) {
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, 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 | « no previous file | cloud_print/service/win/service_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698