OLD | NEW |
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, |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
13 // limitations under the License. | 13 // limitations under the License. |
14 | 14 |
15 #include "test/win/win_child_process.h" | 15 #include "test/win/win_child_process.h" |
16 | 16 |
17 #include <windows.h> | 17 #include <windows.h> |
18 #include <shellapi.h> | 18 #include <shellapi.h> |
19 | 19 |
20 #include <string> | 20 #include <string> |
21 | 21 |
22 #include "base/logging.h" | 22 #include "base/logging.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "gtest/gtest.h" | 25 #include "gtest/gtest.h" |
| 26 #include "util/stdlib/move.h" |
26 #include "util/stdlib/string_number_conversion.h" | 27 #include "util/stdlib/string_number_conversion.h" |
27 #include "util/string/split_string.h" | 28 #include "util/string/split_string.h" |
28 #include "util/win/handle.h" | 29 #include "util/win/handle.h" |
29 #include "util/win/scoped_local_alloc.h" | 30 #include "util/win/scoped_local_alloc.h" |
30 #include "test/paths.h" | 31 #include "test/paths.h" |
31 | 32 |
32 namespace crashpad { | 33 namespace crashpad { |
33 namespace test { | 34 namespace test { |
34 | 35 |
35 namespace { | 36 namespace { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 return false; | 119 return false; |
119 } | 120 } |
120 ScopedFileHANDLE temp_read(read); | 121 ScopedFileHANDLE temp_read(read); |
121 ScopedFileHANDLE temp_write(write); | 122 ScopedFileHANDLE temp_write(write); |
122 | 123 |
123 if (!read_inheritable && !UnsetHandleInheritance(temp_read.get())) | 124 if (!read_inheritable && !UnsetHandleInheritance(temp_read.get())) |
124 return false; | 125 return false; |
125 if (!write_inheritable && !UnsetHandleInheritance(temp_write.get())) | 126 if (!write_inheritable && !UnsetHandleInheritance(temp_write.get())) |
126 return false; | 127 return false; |
127 | 128 |
128 *read_handle = temp_read.Pass(); | 129 *read_handle = crashpad::move(temp_read); |
129 *write_handle = temp_write.Pass(); | 130 *write_handle = crashpad::move(temp_write); |
130 | 131 |
131 return true; | 132 return true; |
132 } | 133 } |
133 | 134 |
134 } // namespace | 135 } // namespace |
135 | 136 |
136 WinChildProcess::WinChildProcess() { | 137 WinChildProcess::WinChildProcess() { |
137 std::string switch_value; | 138 std::string switch_value; |
138 CHECK(GetSwitch(kIsMultiprocessChild, &switch_value)); | 139 CHECK(GetSwitch(kIsMultiprocessChild, &switch_value)); |
139 | 140 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 if (!LoggingReadFile(handles_for_parent->read.get(), &c, sizeof(c))) { | 206 if (!LoggingReadFile(handles_for_parent->read.get(), &c, sizeof(c))) { |
206 ADD_FAILURE() << "LoggedReadFile"; | 207 ADD_FAILURE() << "LoggedReadFile"; |
207 return scoped_ptr<Handles>(); | 208 return scoped_ptr<Handles>(); |
208 } | 209 } |
209 | 210 |
210 if (c != ' ') { | 211 if (c != ' ') { |
211 ADD_FAILURE() << "invalid data read from child"; | 212 ADD_FAILURE() << "invalid data read from child"; |
212 return scoped_ptr<Handles>(); | 213 return scoped_ptr<Handles>(); |
213 } | 214 } |
214 | 215 |
215 return handles_for_parent.Pass(); | 216 return crashpad::move(handles_for_parent); |
216 } | 217 } |
217 | 218 |
218 FileHandle WinChildProcess::ReadPipeHandle() const { | 219 FileHandle WinChildProcess::ReadPipeHandle() const { |
219 return pipe_read_.get(); | 220 return pipe_read_.get(); |
220 } | 221 } |
221 | 222 |
222 FileHandle WinChildProcess::WritePipeHandle() const { | 223 FileHandle WinChildProcess::WritePipeHandle() const { |
223 return pipe_write_.get(); | 224 return pipe_write_.get(); |
224 } | 225 } |
225 | 226 |
226 void WinChildProcess::CloseReadPipe() { | 227 void WinChildProcess::CloseReadPipe() { |
227 pipe_read_.reset(); | 228 pipe_read_.reset(); |
228 } | 229 } |
229 | 230 |
230 void WinChildProcess::CloseWritePipe() { | 231 void WinChildProcess::CloseWritePipe() { |
231 pipe_write_.reset(); | 232 pipe_write_.reset(); |
232 } | 233 } |
233 | 234 |
234 } // namespace test | 235 } // namespace test |
235 } // namespace crashpad | 236 } // namespace crashpad |
OLD | NEW |