Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/product.h" | 5 #include "chrome/installer/util/product.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 int32* exit_code) const { | 73 int32* exit_code) const { |
| 74 if (application_path.empty()) | 74 if (application_path.empty()) |
| 75 return false; | 75 return false; |
| 76 | 76 |
| 77 CommandLine cmd(application_path.Append(installer::kChromeExe)); | 77 CommandLine cmd(application_path.Append(installer::kChromeExe)); |
| 78 cmd.AppendArguments(options, false); | 78 cmd.AppendArguments(options, false); |
| 79 | 79 |
| 80 bool success = false; | 80 bool success = false; |
| 81 STARTUPINFOW si = { sizeof(si) }; | 81 STARTUPINFOW si = { sizeof(si) }; |
| 82 PROCESS_INFORMATION pi = {0}; | 82 PROCESS_INFORMATION pi = {0}; |
| 83 // Cast away constness of the command_line_string() since CreateProcess | 83 // Cast away constness of the GetCommandLineString() since CreateProcess |
| 84 // might modify the string (insert \0 to separate the program from the | 84 // might modify the string (insert \0 to separate the program from the |
| 85 // arguments). Since we're not using the cmd variable beyond this point | 85 // arguments). Since we're not using the cmd variable beyond this point |
| 86 // we don't care. | 86 // we don't care. |
|
Evan Martin
2011/07/15 21:05:16
This feels pretty dangerous to me; for example, th
msw
2011/07/18 20:59:33
Yeah, this isn't a good practice. I changed this a
| |
| 87 if (!::CreateProcess(cmd.GetProgram().value().c_str(), | 87 if (!::CreateProcess(cmd.GetProgram().value().c_str(), |
| 88 const_cast<wchar_t*>(cmd.command_line_string().c_str()), | 88 const_cast<wchar_t*>(cmd.GetCommandLineString().c_str()), |
| 89 NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, | 89 NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, |
| 90 &si, &pi)) { | 90 &si, &pi)) { |
| 91 PLOG(ERROR) << "Failed to launch: " << cmd.command_line_string(); | 91 PLOG(ERROR) << "Failed to launch: " << cmd.GetCommandLineString(); |
| 92 } else { | 92 } else { |
| 93 ::CloseHandle(pi.hThread); | 93 ::CloseHandle(pi.hThread); |
| 94 | 94 |
| 95 DWORD ret = ::WaitForSingleObject(pi.hProcess, INFINITE); | 95 DWORD ret = ::WaitForSingleObject(pi.hProcess, INFINITE); |
| 96 DLOG_IF(ERROR, ret != WAIT_OBJECT_0) | 96 DLOG_IF(ERROR, ret != WAIT_OBJECT_0) |
| 97 << "Unexpected return value from WaitForSingleObject: " << ret; | 97 << "Unexpected return value from WaitForSingleObject: " << ret; |
| 98 if (::GetExitCodeProcess(pi.hProcess, &ret)) { | 98 if (::GetExitCodeProcess(pi.hProcess, &ret)) { |
| 99 DCHECK(ret != STILL_ACTIVE); | 99 DCHECK(ret != STILL_ACTIVE); |
| 100 success = true; | 100 success = true; |
| 101 if (exit_code) | 101 if (exit_code) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 144 |
| 145 void Product::AppendRenameFlags(CommandLine* command_line) const { | 145 void Product::AppendRenameFlags(CommandLine* command_line) const { |
| 146 operations_->AppendRenameFlags(options_, command_line); | 146 operations_->AppendRenameFlags(options_, command_line); |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const { | 149 bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const { |
| 150 return operations_->SetChannelFlags(options_, set, channel_info); | 150 return operations_->SetChannelFlags(options_, set, channel_info); |
| 151 } | 151 } |
| 152 | 152 |
| 153 } // namespace installer | 153 } // namespace installer |
| OLD | NEW |