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

Side by Side Diff: chrome/installer/util/product.cc

Issue 7386002: Rename CommandLine::GetCommandLineString(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge, use writable string copies, restore TODO comment and empty string compare. Created 9 years, 5 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
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 int32* exit_code) const { 72 int32* exit_code) const {
73 if (application_path.empty()) 73 if (application_path.empty())
74 return false; 74 return false;
75 75
76 CommandLine cmd(application_path.Append(installer::kChromeExe)); 76 CommandLine cmd(application_path.Append(installer::kChromeExe));
77 cmd.AppendArguments(options, false); 77 cmd.AppendArguments(options, false);
78 78
79 bool success = false; 79 bool success = false;
80 STARTUPINFOW si = { sizeof(si) }; 80 STARTUPINFOW si = { sizeof(si) };
81 PROCESS_INFORMATION pi = {0}; 81 PROCESS_INFORMATION pi = {0};
82 // Cast away constness of the command_line_string() since CreateProcess 82 // Create a writable copy of the command line string, since CreateProcess
83 // might modify the string (insert \0 to separate the program from the 83 // might modify the string (insert \0 to separate the program from the
84 // arguments). Since we're not using the cmd variable beyond this point 84 // arguments). Since we're not using the cmd variable beyond this point
grt (UTC plus 2) 2011/07/19 03:19:34 The "Since we're not using..." comment isn't relev
msw 2011/07/19 07:14:26 Done.
85 // we don't care. 85 // we don't care.
86 scoped_ptr_malloc<wchar_t> writable_command_line_string(
grt (UTC plus 2) 2011/07/19 03:19:34 Why not: std::wstring writable_command_line_string
msw 2011/07/19 07:14:26 Done.
Evan Martin 2011/07/19 14:35:05 Oh yeah, should have remembered this earlier: http
87 ::_wcsdup(cmd.GetCommandLineString().c_str()));
86 if (!::CreateProcess(cmd.GetProgram().value().c_str(), 88 if (!::CreateProcess(cmd.GetProgram().value().c_str(),
87 const_cast<wchar_t*>(cmd.command_line_string().c_str()), 89 writable_command_line_string.get(),
88 NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, 90 NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,
89 &si, &pi)) { 91 &si, &pi)) {
90 PLOG(ERROR) << "Failed to launch: " << cmd.command_line_string(); 92 PLOG(ERROR) << "Failed to launch: " << writable_command_line_string.get();
grt (UTC plus 2) 2011/07/19 03:19:34 How about either cmd.GetCommandLineString() (to lo
msw 2011/07/19 07:14:26 Done.
91 } else { 93 } else {
92 ::CloseHandle(pi.hThread); 94 ::CloseHandle(pi.hThread);
93 95
94 DWORD ret = ::WaitForSingleObject(pi.hProcess, INFINITE); 96 DWORD ret = ::WaitForSingleObject(pi.hProcess, INFINITE);
95 DLOG_IF(ERROR, ret != WAIT_OBJECT_0) 97 DLOG_IF(ERROR, ret != WAIT_OBJECT_0)
96 << "Unexpected return value from WaitForSingleObject: " << ret; 98 << "Unexpected return value from WaitForSingleObject: " << ret;
97 if (::GetExitCodeProcess(pi.hProcess, &ret)) { 99 if (::GetExitCodeProcess(pi.hProcess, &ret)) {
98 DCHECK(ret != STILL_ACTIVE); 100 DCHECK(ret != STILL_ACTIVE);
99 success = true; 101 success = true;
100 if (exit_code) 102 if (exit_code)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 145
144 void Product::AppendRenameFlags(CommandLine* command_line) const { 146 void Product::AppendRenameFlags(CommandLine* command_line) const {
145 operations_->AppendRenameFlags(options_, command_line); 147 operations_->AppendRenameFlags(options_, command_line);
146 } 148 }
147 149
148 bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const { 150 bool Product::SetChannelFlags(bool set, ChannelInfo* channel_info) const {
149 return operations_->SetChannelFlags(options_, set, channel_info); 151 return operations_->SetChannelFlags(options_, set, channel_info);
150 } 152 }
151 153
152 } // namespace installer 154 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698