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

Side by Side Diff: chrome/browser/first_run/first_run_win.cc

Issue 3429029: Wait for renaming chrome.exe to finish during shutdown for... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/first_run.h" 5 #include "chrome/browser/first_run/first_run.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 bool InvokeGoogleUpdateForRename() { 77 bool InvokeGoogleUpdateForRename() {
78 ScopedComPtr<IProcessLauncher> ipl; 78 ScopedComPtr<IProcessLauncher> ipl;
79 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) { 79 if (!FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) {
80 ULONG_PTR phandle = NULL; 80 ULONG_PTR phandle = NULL;
81 DWORD id = GetCurrentProcessId(); 81 DWORD id = GetCurrentProcessId();
82 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 82 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
83 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(), 83 if (!FAILED(ipl->LaunchCmdElevated(dist->GetAppGuid().c_str(),
84 google_update::kRegRenameCmdField, 84 google_update::kRegRenameCmdField,
85 id, &phandle))) { 85 id, &phandle))) {
86 HANDLE handle = HANDLE(phandle); 86 HANDLE handle = HANDLE(phandle);
87 WaitForSingleObject(handle, INFINITE);
87 DWORD exit_code; 88 DWORD exit_code;
88 ::GetExitCodeProcess(handle, &exit_code); 89 ::GetExitCodeProcess(handle, &exit_code);
89 ::CloseHandle(handle); 90 ::CloseHandle(handle);
90 if (exit_code == installer_util::RENAME_SUCCESSFUL) 91 if (exit_code == installer_util::RENAME_SUCCESSFUL)
91 return true; 92 return true;
92 } 93 }
93 } 94 }
94 return false; 95 return false;
95 } 96 }
96 97
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 if (base::LaunchApp(rename_cmd, true, true, &handle)) { 288 if (base::LaunchApp(rename_cmd, true, true, &handle)) {
288 DWORD exit_code; 289 DWORD exit_code;
289 ::GetExitCodeProcess(handle, &exit_code); 290 ::GetExitCodeProcess(handle, &exit_code);
290 ::CloseHandle(handle); 291 ::CloseHandle(handle);
291 if (exit_code == installer_util::RENAME_SUCCESSFUL) 292 if (exit_code == installer_util::RENAME_SUCCESSFUL)
292 return true; 293 return true;
293 } 294 }
294 } 295 }
295 296
296 // Rename didn't work so try to rename by calling Google Update 297 // Rename didn't work so try to rename by calling Google Update
297 if (InvokeGoogleUpdateForRename()) 298 return InvokeGoogleUpdateForRename();
298 return true;
299
300 // Rename still didn't work so just try to rename exe ourselves (for
301 // backward compatibility, can be deleted once the new process works).
302 std::wstring backup_exe;
303 if (!GetBackupChromeFile(&backup_exe))
cpu_(ooo_6.6-7.5) 2010/09/28 01:16:21 are you sure we want to remove this fallback? I d
304 return false;
305 if (::ReplaceFileW(curr_chrome_exe.c_str(), new_chrome_exe.value().c_str(),
306 backup_exe.c_str(), REPLACEFILE_IGNORE_MERGE_ERRORS,
307 NULL, NULL)) {
308 return true;
309 }
310 return false;
311 } 299 }
312 300
313 // static 301 // static
314 bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) { 302 bool Upgrade::DoUpgradeTasks(const CommandLine& command_line) {
315 if (!Upgrade::SwapNewChromeExeIfPresent()) 303 if (!Upgrade::SwapNewChromeExeIfPresent())
316 return false; 304 return false;
317 // 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.
318 if (!Upgrade::RelaunchChromeBrowser(command_line)) { 306 if (!Upgrade::RelaunchChromeBrowser(command_line)) {
319 // The re-launch fails. Feel free to panic now. 307 // The re-launch fails. Feel free to panic now.
320 NOTREACHED(); 308 NOTREACHED();
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 852
865 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { 853 Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) {
866 if (version > 10000) { 854 if (version > 10000) {
867 // This is a test value. We want to make sure we exercise 855 // This is a test value. We want to make sure we exercise
868 // returning this early. See EarlyReturnTest test harness. 856 // returning this early. See EarlyReturnTest test harness.
869 return Upgrade::TD_NOT_NOW; 857 return Upgrade::TD_NOT_NOW;
870 } 858 }
871 TryChromeDialog td(version); 859 TryChromeDialog td(version);
872 return td.ShowModal(); 860 return td.ShowModal();
873 } 861 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698