OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <windows.h> | 5 #include <windows.h> |
6 #include <sddl.h> | 6 #include <sddl.h> |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "base/memory/free_deleter.h" | 11 #include "base/memory/free_deleter.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
12 #include "base/process/process.h" | 13 #include "base/process/process.h" |
13 #include "base/rand_util.h" | 14 #include "base/rand_util.h" |
14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
16 #include "base/test/multiprocess_test.h" | 17 #include "base/test/multiprocess_test.h" |
17 #include "base/test/test_timeouts.h" | 18 #include "base/test/test_timeouts.h" |
18 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
19 #include "base/win/win_util.h" | 20 #include "base/win/win_util.h" |
20 #include "testing/multiprocess_func_list.h" | 21 #include "testing/multiprocess_func_list.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 power_of_ten *= 10; | 82 power_of_ten *= 10; |
82 } | 83 } |
83 | 84 |
84 return win::ScopedHandle(reinterpret_cast<HANDLE>(handle_as_int)); | 85 return win::ScopedHandle(reinterpret_cast<HANDLE>(handle_as_int)); |
85 } | 86 } |
86 | 87 |
87 // Writes a HANDLE to a pipe as a raw int, least significant digit first. | 88 // Writes a HANDLE to a pipe as a raw int, least significant digit first. |
88 void WriteHandleToPipe(HANDLE pipe, HANDLE handle) { | 89 void WriteHandleToPipe(HANDLE pipe, HANDLE handle) { |
89 uint32_t handle_as_int = base::win::HandleToUint32(handle); | 90 uint32_t handle_as_int = base::win::HandleToUint32(handle); |
90 | 91 |
91 scoped_ptr<char, base::FreeDeleter> buffer(static_cast<char*>(malloc(1000))); | 92 std::unique_ptr<char, base::FreeDeleter> buffer( |
| 93 static_cast<char*>(malloc(1000))); |
92 size_t index = 0; | 94 size_t index = 0; |
93 while (handle_as_int > 0) { | 95 while (handle_as_int > 0) { |
94 buffer.get()[index] = handle_as_int % 10; | 96 buffer.get()[index] = handle_as_int % 10; |
95 handle_as_int /= 10; | 97 handle_as_int /= 10; |
96 ++index; | 98 ++index; |
97 } | 99 } |
98 | 100 |
99 ::ConnectNamedPipe(pipe, nullptr); | 101 ::ConnectNamedPipe(pipe, nullptr); |
100 DWORD written; | 102 DWORD written; |
101 ASSERT_TRUE(::WriteFile(pipe, buffer.get(), index, &written, NULL)); | 103 ASSERT_TRUE(::WriteFile(pipe, buffer.get(), index, &written, NULL)); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 WriteHandleToPipe(communication_pipe.Get(), raw_handle); | 215 WriteHandleToPipe(communication_pipe.Get(), raw_handle); |
214 | 216 |
215 int exit_code; | 217 int exit_code; |
216 EXPECT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), | 218 EXPECT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(), |
217 &exit_code)); | 219 &exit_code)); |
218 EXPECT_EQ(0, exit_code); | 220 EXPECT_EQ(0, exit_code); |
219 } | 221 } |
220 | 222 |
221 } // namespace | 223 } // namespace |
222 } // namespace base | 224 } // namespace base |
OLD | NEW |