| OLD | NEW |
| 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 "base/strings/stringprintf.h" | 5 #include "base/strings/stringprintf.h" |
| 6 #include "base/win/scoped_handle.h" | 6 #include "base/win/scoped_handle.h" |
| 7 #include "sandbox/win/src/handle_closer_agent.h" | 7 #include "sandbox/win/src/handle_closer_agent.h" |
| 8 #include "sandbox/win/src/sandbox.h" | 8 #include "sandbox/win/src/sandbox.h" |
| 9 #include "sandbox/win/src/sandbox_factory.h" | 9 #include "sandbox/win/src/sandbox_factory.h" |
| 10 #include "sandbox/win/src/target_services.h" | 10 #include "sandbox/win/src/target_services.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 static volatile LONG waiters_remaining = kWaitCount; | 150 static volatile LONG waiters_remaining = kWaitCount; |
| 151 CHECK(!timeout); | 151 CHECK(!timeout); |
| 152 CHECK(::CloseHandle(event)); | 152 CHECK(::CloseHandle(event)); |
| 153 if (::InterlockedDecrement(&waiters_remaining) == 0) | 153 if (::InterlockedDecrement(&waiters_remaining) == 0) |
| 154 CHECK(::SetEvent(finish_event)); | 154 CHECK(::SetEvent(finish_event)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Run a thread pool inside a sandbox without a CSRSS connection. | 157 // Run a thread pool inside a sandbox without a CSRSS connection. |
| 158 SBOX_TESTS_COMMAND int RunThreadPool(int argc, wchar_t **argv) { | 158 SBOX_TESTS_COMMAND int RunThreadPool(int argc, wchar_t **argv) { |
| 159 HANDLE wait_list[20]; | 159 HANDLE wait_list[20]; |
| 160 CHECK(finish_event = ::CreateEvent(NULL, TRUE, FALSE, NULL)); | 160 finish_event = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
| 161 CHECK(finish_event); |
| 161 | 162 |
| 162 // Set up a bunch of waiters. | 163 // Set up a bunch of waiters. |
| 163 HANDLE pool = NULL; | 164 HANDLE pool = NULL; |
| 164 for (int i = 0; i < kWaitCount; ++i) { | 165 for (int i = 0; i < kWaitCount; ++i) { |
| 165 HANDLE event = ::CreateEvent(NULL, TRUE, FALSE, NULL); | 166 HANDLE event = ::CreateEvent(NULL, TRUE, FALSE, NULL); |
| 166 CHECK(event); | 167 CHECK(event); |
| 167 CHECK(::RegisterWaitForSingleObject(&pool, event, ThreadPoolTask, event, | 168 CHECK(::RegisterWaitForSingleObject(&pool, event, ThreadPoolTask, event, |
| 168 INFINITE, WT_EXECUTEONLYONCE)); | 169 INFINITE, WT_EXECUTEONLYONCE)); |
| 169 wait_list[i] = event; | 170 wait_list[i] = event; |
| 170 } | 171 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 185 runner.SetTestState(AFTER_REVERT); | 186 runner.SetTestState(AFTER_REVERT); |
| 186 sandbox::TargetPolicy* policy = runner.GetPolicy(); | 187 sandbox::TargetPolicy* policy = runner.GetPolicy(); |
| 187 | 188 |
| 188 // Sever the CSRSS connection by closing ALPC ports inside the sandbox. | 189 // Sever the CSRSS connection by closing ALPC ports inside the sandbox. |
| 189 CHECK_EQ(policy->AddKernelObjectToClose(L"ALPC Port", NULL), SBOX_ALL_OK); | 190 CHECK_EQ(policy->AddKernelObjectToClose(L"ALPC Port", NULL), SBOX_ALL_OK); |
| 190 | 191 |
| 191 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"RunThreadPool")); | 192 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"RunThreadPool")); |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace sandbox | 195 } // namespace sandbox |
| OLD | NEW |