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

Side by Side Diff: chrome/browser/extensions/api/messaging/native_process_launcher_win.cc

Issue 90963002: Revert of Base: Remove Receive() from ScopedHandle. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « base/win/startup_information_unittest.cc ('k') | chrome/browser/first_run/upgrade_util_win.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 "chrome/browser/extensions/api/messaging/native_process_launcher.h" 5 #include "chrome/browser/extensions/api/messaging/native_process_launcher.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 string16 command_line_string = command_line.GetCommandLineString(); 130 string16 command_line_string = command_line.GetCommandLineString();
131 131
132 string16 command = base::StringPrintf( 132 string16 command = base::StringPrintf(
133 L"%ls /c %ls < %ls > %ls", 133 L"%ls /c %ls < %ls > %ls",
134 comspec.get(), command_line_string.c_str(), 134 comspec.get(), command_line_string.c_str(),
135 in_pipe_name.c_str(), out_pipe_name.c_str()); 135 in_pipe_name.c_str(), out_pipe_name.c_str());
136 136
137 base::LaunchOptions options; 137 base::LaunchOptions options;
138 options.start_hidden = true; 138 options.start_hidden = true;
139 base::win::ScopedHandle cmd_handle; 139 base::ProcessHandle cmd_handle;
140 if (!base::LaunchProcess(command.c_str(), options, &cmd_handle)) { 140 if (!base::LaunchProcess(command.c_str(), options, &cmd_handle)) {
141 LOG(ERROR) << "Error launching process " 141 LOG(ERROR) << "Error launching process "
142 << command_line.GetProgram().MaybeAsASCII(); 142 << command_line.GetProgram().MaybeAsASCII();
143 return false; 143 return false;
144 } 144 }
145 145
146 bool stdout_connected = ConnectNamedPipe(stdout_pipe.Get(), NULL) ? 146 bool stdout_connected = ConnectNamedPipe(stdout_pipe.Get(), NULL) ?
147 TRUE : GetLastError() == ERROR_PIPE_CONNECTED; 147 TRUE : GetLastError() == ERROR_PIPE_CONNECTED;
148 bool stdin_connected = ConnectNamedPipe(stdin_pipe.Get(), NULL) ? 148 bool stdin_connected = ConnectNamedPipe(stdin_pipe.Get(), NULL) ?
149 TRUE : GetLastError() == ERROR_PIPE_CONNECTED; 149 TRUE : GetLastError() == ERROR_PIPE_CONNECTED;
150 if (!stdout_connected || !stdin_connected) { 150 if (!stdout_connected || !stdin_connected) {
151 base::KillProcess(cmd_handle.Get(), 0, false); 151 base::KillProcess(cmd_handle, 0, false);
152 base::CloseProcessHandle(cmd_handle);
152 LOG(ERROR) << "Failed to connect IO pipes when starting " 153 LOG(ERROR) << "Failed to connect IO pipes when starting "
153 << command_line.GetProgram().MaybeAsASCII(); 154 << command_line.GetProgram().MaybeAsASCII();
154 return false; 155 return false;
155 } 156 }
156 157
157 *process_handle = cmd_handle.Take(); 158 *process_handle = cmd_handle;
158 *read_file = stdout_pipe.Take(); 159 *read_file = stdout_pipe.Take();
159 *write_file = stdin_pipe.Take(); 160 *write_file = stdin_pipe.Take();
160 161
161 return true; 162 return true;
162 } 163 }
163 164
164 } // namespace extensions 165 } // namespace extensions
OLDNEW
« no previous file with comments | « base/win/startup_information_unittest.cc ('k') | chrome/browser/first_run/upgrade_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698