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

Side by Side Diff: chrome/installer/util/google_update_util.cc

Issue 759903002: Upgrade the windows specific version of LaunchProcess to avoid raw handles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix chrome build Created 6 years 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 "chrome/installer/util/google_update_util.h" 5 #include "chrome/installer/util/google_update_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } 82 }
83 83
84 // Launches command |cmd_string|, and waits for |timeout| milliseconds before 84 // Launches command |cmd_string|, and waits for |timeout| milliseconds before
85 // timing out. To wait indefinitely, one can set 85 // timing out. To wait indefinitely, one can set
86 // |timeout| to be base::TimeDelta::FromMilliseconds(INFINITE). 86 // |timeout| to be base::TimeDelta::FromMilliseconds(INFINITE).
87 // Returns true if this executes successfully. 87 // Returns true if this executes successfully.
88 // Returns false if command execution fails to execute, or times out. 88 // Returns false if command execution fails to execute, or times out.
89 bool LaunchProcessAndWaitWithTimeout(const base::string16& cmd_string, 89 bool LaunchProcessAndWaitWithTimeout(const base::string16& cmd_string,
90 base::TimeDelta timeout) { 90 base::TimeDelta timeout) {
91 bool success = false; 91 bool success = false;
92 base::win::ScopedHandle process;
93 int exit_code = 0; 92 int exit_code = 0;
94 VLOG(0) << "Launching: " << cmd_string; 93 VLOG(0) << "Launching: " << cmd_string;
95 if (!base::LaunchProcess(cmd_string, base::LaunchOptions(), 94 base::Process process =
96 &process)) { 95 base::LaunchProcess(cmd_string, base::LaunchOptions());
96 if (!process.IsValid()) {
97 PLOG(ERROR) << "Failed to launch (" << cmd_string << ")"; 97 PLOG(ERROR) << "Failed to launch (" << cmd_string << ")";
98 } else if (!base::WaitForExitCodeWithTimeout(process.Get(), &exit_code, 98 } else if (!base::WaitForExitCodeWithTimeout(process.Handle(), &exit_code,
99 timeout)) { 99 timeout)) {
100 // The GetExitCodeProcess failed or timed-out. 100 // The GetExitCodeProcess failed or timed-out.
101 LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than " 101 LOG(ERROR) <<"Command (" << cmd_string << ") is taking more than "
102 << timeout.InMilliseconds() << " milliseconds to complete."; 102 << timeout.InMilliseconds() << " milliseconds to complete.";
103 } else if (exit_code != 0) { 103 } else if (exit_code != 0) {
104 LOG(ERROR) << "Command (" << cmd_string << ") exited with code " 104 LOG(ERROR) << "Command (" << cmd_string << ") exited with code "
105 << exit_code; 105 << exit_code;
106 } else { 106 } else {
107 success = true; 107 success = true;
108 } 108 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 if (base::win::GetVersion() >= base::win::VERSION_VISTA && 183 if (base::win::GetVersion() >= base::win::VERSION_VISTA &&
184 base::win::UserAccountControlIsEnabled()) { 184 base::win::UserAccountControlIsEnabled()) {
185 base::LaunchElevatedProcess(cmd, launch_options); 185 base::LaunchElevatedProcess(cmd, launch_options);
186 } else { 186 } else {
187 base::LaunchProcess(cmd, launch_options, NULL); 187 base::LaunchProcess(cmd, launch_options, NULL);
188 } 188 }
189 } 189 }
190 190
191 } // namespace google_update 191 } // namespace google_update
OLDNEW
« no previous file with comments | « chrome/installer/test/alternate_version_generator.cc ('k') | chrome/installer/util/install_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698