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

Side by Side Diff: win8/delegate_execute/chrome_util.cc

Issue 71013004: Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix delegate_execute for google_chrome_build Created 7 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/function_exec_script.cc ('k') | win8/delegate_execute/command_execute_impl.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 "win8/delegate_execute/chrome_util.h" 5 #include "win8/delegate_execute/chrome_util.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 namespace delegate_execute { 97 namespace delegate_execute {
98 98
99 void UpdateChromeIfNeeded(const base::FilePath& chrome_exe) { 99 void UpdateChromeIfNeeded(const base::FilePath& chrome_exe) {
100 #if defined(GOOGLE_CHROME_BUILD) 100 #if defined(GOOGLE_CHROME_BUILD)
101 // Nothing to do if a browser is already running or if there's no 101 // Nothing to do if a browser is already running or if there's no
102 // new_chrome.exe. 102 // new_chrome.exe.
103 if (IsBrowserRunning(chrome_exe) || !NewChromeExeExists(chrome_exe)) 103 if (IsBrowserRunning(chrome_exe) || !NewChromeExeExists(chrome_exe))
104 return; 104 return;
105 105
106 base::ProcessHandle process_handle = base::kNullProcessHandle; 106 base::win::ScopedHandle process_handle;
107 107
108 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) { 108 if (InstallUtil::IsPerUserInstall(chrome_exe.value().c_str())) {
109 // Read the update command from the registry. 109 // Read the update command from the registry.
110 string16 update_command; 110 string16 update_command;
111 if (!GetUpdateCommand(true, &update_command)) { 111 if (!GetUpdateCommand(true, &update_command)) {
112 AtlTrace("%hs. Failed to read update command from registry.\n", 112 AtlTrace("%hs. Failed to read update command from registry.\n",
113 __FUNCTION__); 113 __FUNCTION__);
114 } else { 114 } else {
115 // Run the update command. 115 // Run the update command.
116 base::LaunchOptions launch_options; 116 base::LaunchOptions launch_options;
117 launch_options.start_hidden = true; 117 launch_options.start_hidden = true;
118 if (!base::LaunchProcess(update_command, launch_options, 118 if (!base::LaunchProcess(update_command, launch_options,
119 &process_handle)) { 119 &process_handle)) {
120 AtlTrace("%hs. Failed to launch command to finalize update; " 120 AtlTrace("%hs. Failed to launch command to finalize update; "
121 "error %u.\n", __FUNCTION__, ::GetLastError()); 121 "error %u.\n", __FUNCTION__, ::GetLastError());
122 process_handle = base::kNullProcessHandle;
123 } 122 }
124 } 123 }
125 } else { 124 } else {
126 // Run the update command via Google Update. 125 // Run the update command via Google Update.
127 HRESULT hr = S_OK; 126 HRESULT hr = S_OK;
128 base::win::ScopedComPtr<IProcessLauncher> process_launcher; 127 base::win::ScopedComPtr<IProcessLauncher> process_launcher;
129 hr = process_launcher.CreateInstance(__uuidof(ProcessLauncherClass)); 128 hr = process_launcher.CreateInstance(__uuidof(ProcessLauncherClass));
130 if (FAILED(hr)) { 129 if (FAILED(hr)) {
131 AtlTrace("%hs. Failed to Create ProcessLauncher; hr=0x%X.\n", 130 AtlTrace("%hs. Failed to Create ProcessLauncher; hr=0x%X.\n",
132 __FUNCTION__, hr); 131 __FUNCTION__, hr);
133 } else { 132 } else {
134 ULONG_PTR handle = 0; 133 ULONG_PTR handle = 0;
135 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 134 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
136 hr = process_launcher->LaunchCmdElevated( 135 hr = process_launcher->LaunchCmdElevated(
137 dist->GetAppGuid().c_str(), kRenameCommandValue, 136 dist->GetAppGuid().c_str(), kRenameCommandValue,
138 GetCurrentProcessId(), &handle); 137 GetCurrentProcessId(), &handle);
139 if (FAILED(hr)) { 138 if (FAILED(hr)) {
140 AtlTrace("%hs. Failed to launch command to finalize update; " 139 AtlTrace("%hs. Failed to launch command to finalize update; "
141 "hr=0x%X.\n", __FUNCTION__, hr); 140 "hr=0x%X.\n", __FUNCTION__, hr);
142 } else { 141 } else {
143 process_handle = reinterpret_cast<base::ProcessHandle>(handle); 142 process_handle.Set(reinterpret_cast<base::ProcessHandle>(handle));
144 } 143 }
145 } 144 }
146 } 145 }
147 146
148 // Wait for the update to complete and report the results. 147 // Wait for the update to complete and report the results.
149 if (process_handle != base::kNullProcessHandle) { 148 if (process_handle.IsValid()) {
150 int exit_code = 0; 149 int exit_code = 0;
151 // WaitForExitCode will close the handle in all cases. 150 // WaitForExitCode will close the handle in all cases.
152 if (!base::WaitForExitCode(process_handle, &exit_code)) { 151 if (!base::WaitForExitCode(process_handle.Take(), &exit_code)) {
153 AtlTrace("%hs. Failed to get result when finalizing update.\n", 152 AtlTrace("%hs. Failed to get result when finalizing update.\n",
154 __FUNCTION__); 153 __FUNCTION__);
155 } else if (exit_code != installer::RENAME_SUCCESSFUL) { 154 } else if (exit_code != installer::RENAME_SUCCESSFUL) {
156 AtlTrace("%hs. Failed to finalize update with exit code %d.\n", 155 AtlTrace("%hs. Failed to finalize update with exit code %d.\n",
157 __FUNCTION__, exit_code); 156 __FUNCTION__, exit_code);
158 } else { 157 } else {
159 AtlTrace("%hs. Finalized pending update.\n", __FUNCTION__); 158 AtlTrace("%hs. Finalized pending update.\n", __FUNCTION__);
160 } 159 }
161 } 160 }
162 #endif 161 #endif
163 } 162 }
164 163
165 } // delegate_execute 164 } // delegate_execute
OLDNEW
« no previous file with comments | « tools/gn/function_exec_script.cc ('k') | win8/delegate_execute/command_execute_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698