| 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 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/win/base_features.h" |
| 9 #include "base/win/current_module.h" | 10 #include "base/win/current_module.h" |
| 10 #include "base/win/scoped_handle.h" | 11 #include "base/win/scoped_handle.h" |
| 11 | 12 |
| 12 namespace base { | 13 namespace base { |
| 13 namespace win { | 14 namespace win { |
| 14 namespace testing { | 15 namespace testing { |
| 15 | 16 |
| 16 extern "C" bool __declspec(dllexport) RunTest(); | 17 extern "C" bool __declspec(dllexport) RunTest(); |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 ::CloseHandle(start_event); | 76 ::CloseHandle(start_event); |
| 76 for (const auto& thread : threads_) { | 77 for (const auto& thread : threads_) { |
| 77 ::WaitForSingleObject(thread, INFINITE); | 78 ::WaitForSingleObject(thread, INFINITE); |
| 78 ::CloseHandle(thread); | 79 ::CloseHandle(thread); |
| 79 } | 80 } |
| 80 | 81 |
| 81 return true; | 82 return true; |
| 82 } | 83 } |
| 83 | 84 |
| 84 bool InternalRunLocationTest() { | 85 bool InternalRunLocationTest() { |
| 86 #if BUILDFLAG(ENABLE_HANDLE_VERIFIER) |
| 85 // Create a new handle and then set LastError again. | 87 // Create a new handle and then set LastError again. |
| 86 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); | 88 HANDLE handle = ::CreateMutex(nullptr, false, nullptr); |
| 87 if (!handle) | 89 if (!handle) |
| 88 return false; | 90 return false; |
| 89 ScopedHandle handle_holder(handle); | 91 ScopedHandle handle_holder(handle); |
| 90 | 92 |
| 91 HMODULE verifier_module = GetHandleVerifierModuleForTesting(); | 93 HMODULE verifier_module = GetHandleVerifierModuleForTesting(); |
| 92 if (!verifier_module) | 94 if (!verifier_module) |
| 93 return false; | 95 return false; |
| 94 | 96 |
| 95 // Get my module | 97 // Get my module |
| 96 HMODULE my_module = CURRENT_MODULE(); | 98 HMODULE my_module = CURRENT_MODULE(); |
| 97 if (!my_module) | 99 if (!my_module) |
| 98 return false; | 100 return false; |
| 99 | 101 |
| 100 HMODULE main_module = ::GetModuleHandle(NULL); | 102 HMODULE main_module = ::GetModuleHandle(NULL); |
| 101 | 103 |
| 102 #if defined(COMPONENT_BUILD) | 104 #if defined(COMPONENT_BUILD) |
| 103 // In a component build ActiveVerifier will always be created inside base.dll | 105 // In a component build ActiveVerifier will always be created inside base.dll |
| 104 // as the code always lives there. | 106 // as the code always lives there. |
| 105 if (verifier_module == my_module || verifier_module == main_module) | 107 if (verifier_module == my_module || verifier_module == main_module) |
| 106 return false; | 108 return false; |
| 107 #else | 109 #else |
| 108 // In a non-component build, ActiveVerifier should always be created in the | 110 // In a non-component build, ActiveVerifier should always be created in the |
| 109 // version of base linked with the main executable. | 111 // version of base linked with the main executable. |
| 110 if (verifier_module == my_module || verifier_module != main_module) | 112 if (verifier_module == my_module || verifier_module != main_module) |
| 111 return false; | 113 return false; |
| 112 #endif | 114 #endif |
| 115 #endif // BUILDFLAG(ENABLE_HANDLE_VERIFIER) |
| 113 return true; | 116 return true; |
| 114 } | 117 } |
| 115 | 118 |
| 116 } // namespace | 119 } // namespace |
| 117 | 120 |
| 118 bool RunTest() { | 121 bool RunTest() { |
| 119 return InternalRunThreadTest() && InternalRunLocationTest(); | 122 return InternalRunThreadTest() && InternalRunLocationTest(); |
| 120 } | 123 } |
| 121 | 124 |
| 122 } // testing | 125 } // testing |
| 123 } // win | 126 } // win |
| 124 } // base | 127 } // base |
| OLD | NEW |