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

Side by Side Diff: chrome/browser/first_run/upgrade_util_win.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/browser/first_run/upgrade_util.h" 5 #include "chrome/browser/first_run/upgrade_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <psapi.h> 8 #include <psapi.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 10
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str()); 251 InstallUtil::IsPerUserInstall(cur_chrome_exe.value().c_str());
252 HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; 252 HKEY reg_root = user_install ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
253 BrowserDistribution *dist = BrowserDistribution::GetDistribution(); 253 BrowserDistribution *dist = BrowserDistribution::GetDistribution();
254 base::win::RegKey key; 254 base::win::RegKey key;
255 if (key.Open(reg_root, dist->GetVersionKey().c_str(), 255 if (key.Open(reg_root, dist->GetVersionKey().c_str(),
256 KEY_QUERY_VALUE) == ERROR_SUCCESS) { 256 KEY_QUERY_VALUE) == ERROR_SUCCESS) {
257 // First try to rename exe by launching rename command ourselves. 257 // First try to rename exe by launching rename command ourselves.
258 std::wstring rename_cmd; 258 std::wstring rename_cmd;
259 if (key.ReadValue(google_update::kRegRenameCmdField, 259 if (key.ReadValue(google_update::kRegRenameCmdField,
260 &rename_cmd) == ERROR_SUCCESS) { 260 &rename_cmd) == ERROR_SUCCESS) {
261 base::win::ScopedHandle handle;
262 base::LaunchOptions options; 261 base::LaunchOptions options;
263 options.wait = true; 262 options.wait = true;
264 options.start_hidden = true; 263 options.start_hidden = true;
265 if (base::LaunchProcess(rename_cmd, options, &handle)) { 264 base::Process process = base::LaunchProcess(rename_cmd, options);
265 if (process.IsValid()) {
266 DWORD exit_code; 266 DWORD exit_code;
267 ::GetExitCodeProcess(handle.Get(), &exit_code); 267 ::GetExitCodeProcess(process.Handle(), &exit_code);
268 if (exit_code == installer::RENAME_SUCCESSFUL) 268 if (exit_code == installer::RENAME_SUCCESSFUL)
269 return true; 269 return true;
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 // Rename didn't work so try to rename by calling Google Update 274 // Rename didn't work so try to rename by calling Google Update
275 return InvokeGoogleUpdateForRename(); 275 return InvokeGoogleUpdateForRename();
276 } 276 }
277 277
(...skipping 26 matching lines...) Expand all
304 return false; 304 return false;
305 // At this point the chrome.exe has been swapped with the new one. 305 // At this point the chrome.exe has been swapped with the new one.
306 if (!RelaunchChromeBrowser(command_line)) { 306 if (!RelaunchChromeBrowser(command_line)) {
307 // The re-launch fails. Feel free to panic now. 307 // The re-launch fails. Feel free to panic now.
308 NOTREACHED(); 308 NOTREACHED();
309 } 309 }
310 return true; 310 return true;
311 } 311 }
312 312
313 } // namespace upgrade_util 313 } // namespace upgrade_util
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/messaging/native_process_launcher_win.cc ('k') | chrome/browser/ui/views/uninstall_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698