Chromium Code Reviews| Index: chrome_frame/update_launcher.cc |
| =================================================================== |
| --- chrome_frame/update_launcher.cc (revision 194111) |
| +++ chrome_frame/update_launcher.cc (working copy) |
| @@ -50,35 +50,24 @@ |
| return command; |
| } |
| -// Because we do not have 'base' and all of its pretty RAII helpers, please |
| -// ensure that this function only ever contains a single 'return', in order |
| -// to reduce the chance of introducing a leak. |
| DWORD LaunchUpdateCommand(const std::wstring& command) { |
| - DWORD exit_code = kLaunchFailureExitCode; |
| - |
| base::win::ScopedCOMInitializer com_initializer; |
| - if (com_initializer.succeeded()) { |
| - base::win::ScopedComPtr<IProcessLauncher> ipl; |
| - HANDLE process = NULL; |
| + if (!com_initializer.succeeded()) |
| + return kLaunchFailureExitCode; |
| - HRESULT hr = ipl.CreateInstance(__uuidof(ProcessLauncherClass)); |
| + base::win::ScopedComPtr<IProcessLauncher> ipl; |
| + if (FAILED(ipl.CreateInstance(__uuidof(ProcessLauncherClass)))) |
| + return kLaunchFailureExitCode; |
| - if (SUCCEEDED(hr)) { |
| - ULONG_PTR phandle = NULL; |
| - DWORD id = ::GetCurrentProcessId(); |
| + ULONG_PTR phandle = NULL; |
|
grt (UTC plus 2)
2013/04/15 23:32:54
can this be a base::win::ScopedHandle, using its R
Peter Kasting
2013/04/16 00:09:22
I don't think using Receive() will work because th
|
| + if (FAILED(ipl->LaunchCmdElevated(kChromeFrameGuid, command.c_str(), |
| + ::GetCurrentProcessId(), &phandle))) |
| + return kLaunchFailureExitCode; |
| - hr = ipl->LaunchCmdElevated(kChromeFrameGuid, |
| - command.c_str(), id, &phandle); |
| - if (SUCCEEDED(hr)) { |
| - process = reinterpret_cast<HANDLE>(phandle); |
| - exit_code = WaitForProcessExitCode(process); |
| - } |
| - } |
| - |
| - if (process) |
| - ::CloseHandle(process); |
| - } |
| - |
| + HANDLE process = reinterpret_cast<HANDLE>(phandle); |
| + DWORD exit_code = WaitForProcessExitCode(process); |
| + if (process) |
| + ::CloseHandle(process); |
| return exit_code; |
| } |