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

Side by Side Diff: third_party/crashpad/crashpad/test/win/win_child_process.cc

Issue 1911823002: Convert //third_party from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update crashpad's README.chromium Created 4 years, 8 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
OLDNEW
1 // Copyright 2015 The Crashpad Authors. All rights reserved. 1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 char c = ' '; 158 char c = ' ';
159 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c)); 159 CheckedWriteFile(WritePipeHandle(), &c, sizeof(c));
160 } 160 }
161 161
162 // static 162 // static
163 bool WinChildProcess::IsChildProcess() { 163 bool WinChildProcess::IsChildProcess() {
164 return GetSwitch(kIsMultiprocessChild, nullptr); 164 return GetSwitch(kIsMultiprocessChild, nullptr);
165 } 165 }
166 166
167 // static 167 // static
168 scoped_ptr<WinChildProcess::Handles> WinChildProcess::Launch() { 168 std::unique_ptr<WinChildProcess::Handles> WinChildProcess::Launch() {
169 // Make pipes for child-to-parent and parent-to-child communication. 169 // Make pipes for child-to-parent and parent-to-child communication.
170 scoped_ptr<Handles> handles_for_parent(new Handles); 170 std::unique_ptr<Handles> handles_for_parent(new Handles);
171 ScopedFileHANDLE read_for_child; 171 ScopedFileHANDLE read_for_child;
172 ScopedFileHANDLE write_for_child; 172 ScopedFileHANDLE write_for_child;
173 173
174 if (!CreateInheritablePipe( 174 if (!CreateInheritablePipe(
175 &handles_for_parent->read, false, &write_for_child, true)) { 175 &handles_for_parent->read, false, &write_for_child, true)) {
176 return scoped_ptr<Handles>(); 176 return std::unique_ptr<Handles>();
177 } 177 }
178 178
179 if (!CreateInheritablePipe( 179 if (!CreateInheritablePipe(
180 &read_for_child, true, &handles_for_parent->write, false)) { 180 &read_for_child, true, &handles_for_parent->write, false)) {
181 return scoped_ptr<Handles>(); 181 return std::unique_ptr<Handles>();
182 } 182 }
183 183
184 // Build a command line for the child process that tells it only to run the 184 // Build a command line for the child process that tells it only to run the
185 // current test, and to pass down the values of the pipe handles. 185 // current test, and to pass down the values of the pipe handles.
186 const ::testing::TestInfo* const test_info = 186 const ::testing::TestInfo* const test_info =
187 ::testing::UnitTest::GetInstance()->current_test_info(); 187 ::testing::UnitTest::GetInstance()->current_test_info();
188 std::wstring command_line = 188 std::wstring command_line =
189 Paths::Executable().value() + L" " + 189 Paths::Executable().value() + L" " +
190 base::UTF8ToUTF16(base::StringPrintf("--gtest_filter=%s.%s %s=0x%x|0x%x", 190 base::UTF8ToUTF16(base::StringPrintf("--gtest_filter=%s.%s %s=0x%x|0x%x",
191 test_info->test_case_name(), 191 test_info->test_case_name(),
192 test_info->name(), 192 test_info->name(),
193 kIsMultiprocessChild, 193 kIsMultiprocessChild,
194 HandleToInt(write_for_child.get()), 194 HandleToInt(write_for_child.get()),
195 HandleToInt(read_for_child.get()))); 195 HandleToInt(read_for_child.get())));
196 196
197 // Command-line buffer cannot be constant, per CreateProcess signature. 197 // Command-line buffer cannot be constant, per CreateProcess signature.
198 handles_for_parent->process = LaunchCommandLine(&command_line[0]); 198 handles_for_parent->process = LaunchCommandLine(&command_line[0]);
199 if (!handles_for_parent->process.is_valid()) 199 if (!handles_for_parent->process.is_valid())
200 return scoped_ptr<Handles>(); 200 return std::unique_ptr<Handles>();
201 201
202 // Block until the child process has launched. CreateProcess() returns 202 // Block until the child process has launched. CreateProcess() returns
203 // immediately, and test code expects process initialization to have 203 // immediately, and test code expects process initialization to have
204 // completed so it can, for example, read the process memory. 204 // completed so it can, for example, read the process memory.
205 char c; 205 char c;
206 if (!LoggingReadFile(handles_for_parent->read.get(), &c, sizeof(c))) { 206 if (!LoggingReadFile(handles_for_parent->read.get(), &c, sizeof(c))) {
207 ADD_FAILURE() << "LoggedReadFile"; 207 ADD_FAILURE() << "LoggedReadFile";
208 return scoped_ptr<Handles>(); 208 return std::unique_ptr<Handles>();
209 } 209 }
210 210
211 if (c != ' ') { 211 if (c != ' ') {
212 ADD_FAILURE() << "invalid data read from child"; 212 ADD_FAILURE() << "invalid data read from child";
213 return scoped_ptr<Handles>(); 213 return std::unique_ptr<Handles>();
214 } 214 }
215 215
216 return std::move(handles_for_parent); 216 return std::move(handles_for_parent);
217 } 217 }
218 218
219 FileHandle WinChildProcess::ReadPipeHandle() const { 219 FileHandle WinChildProcess::ReadPipeHandle() const {
220 return pipe_read_.get(); 220 return pipe_read_.get();
221 } 221 }
222 222
223 FileHandle WinChildProcess::WritePipeHandle() const { 223 FileHandle WinChildProcess::WritePipeHandle() const {
224 return pipe_write_.get(); 224 return pipe_write_.get();
225 } 225 }
226 226
227 void WinChildProcess::CloseReadPipe() { 227 void WinChildProcess::CloseReadPipe() {
228 pipe_read_.reset(); 228 pipe_read_.reset();
229 } 229 }
230 230
231 void WinChildProcess::CloseWritePipe() { 231 void WinChildProcess::CloseWritePipe() {
232 pipe_write_.reset(); 232 pipe_write_.reset();
233 } 233 }
234 234
235 } // namespace test 235 } // namespace test
236 } // namespace crashpad 236 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698