| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/install_verification/win/module_list.h" | 5 #include "chrome/browser/install_verification/win/module_list.h" |
| 6 | 6 |
| 7 #include <Windows.h> | 7 #include <Windows.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 base::ScopedClosureRunner release_new_dll( | 37 base::ScopedClosureRunner release_new_dll( |
| 38 base::Bind(base::IgnoreResult(&::FreeLibrary), new_dll)); | 38 base::Bind(base::IgnoreResult(&::FreeLibrary), new_dll)); |
| 39 | 39 |
| 40 // Verify that there is an increase in the snapshot size. | 40 // Verify that there is an increase in the snapshot size. |
| 41 ASSERT_TRUE( | 41 ASSERT_TRUE( |
| 42 base::win::GetLoadedModulesSnapshot(::GetCurrentProcess(), &snapshot)); | 42 base::win::GetLoadedModulesSnapshot(::GetCurrentProcess(), &snapshot)); |
| 43 module_list = ModuleList::FromLoadedModuleSnapshot(snapshot); | 43 module_list = ModuleList::FromLoadedModuleSnapshot(snapshot); |
| 44 ASSERT_GT(module_list->size(), original_list_size); | 44 ASSERT_GT(module_list->size(), original_list_size); |
| 45 | 45 |
| 46 // Unload the module. | 46 // Unload the module. |
| 47 release_new_dll.Reset(); | 47 release_new_dll.RunAndReset(); |
| 48 | 48 |
| 49 // Reset module_list here. That should typically be the last ref on | 49 // Reset module_list here. That should typically be the last ref on |
| 50 // msvidc32.dll, so it will be unloaded now. | 50 // msvidc32.dll, so it will be unloaded now. |
| 51 module_list.reset(); | 51 module_list.reset(); |
| 52 ASSERT_EQ(NULL, ::GetModuleHandle(L"msvidc32.dll")); | 52 ASSERT_EQ(NULL, ::GetModuleHandle(L"msvidc32.dll")); |
| 53 | 53 |
| 54 // List the modules from the stale snapshot (including a dangling HMODULE to | 54 // List the modules from the stale snapshot (including a dangling HMODULE to |
| 55 // msvidc32.dll), simulating a race condition. | 55 // msvidc32.dll), simulating a race condition. |
| 56 module_list = ModuleList::FromLoadedModuleSnapshot(snapshot); | 56 module_list = ModuleList::FromLoadedModuleSnapshot(snapshot); |
| 57 ASSERT_EQ(module_list->size(), original_list_size); | 57 ASSERT_EQ(module_list->size(), original_list_size); |
| 58 } | 58 } |
| OLD | NEW |