diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-10 18:45:58 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-10 18:45:58 +0000 |
commit | 9a18283569add624b3399ee4d64d7afef05c0190 (patch) | |
tree | 63f2295ef334ad07c2890549f5a6263020d7dc2a /base/process_util_unittest.cc | |
parent | b2d78470385b9131dd387183ce300fdaeb303cb5 (diff) | |
download | chromium_src-9a18283569add624b3399ee4d64d7afef05c0190.zip chromium_src-9a18283569add624b3399ee4d64d7afef05c0190.tar.gz chromium_src-9a18283569add624b3399ee4d64d7afef05c0190.tar.bz2 |
Cleanup in ProcessSingleton. These originated as candidate fixes for issue 111361, but the true fix is cpu@'s r119830.
a) Unify code to retrieve HMODULE based on address in base::GetModuleFromAddress. (cpu@'s r119830 already has the fix to use the DLL's HMODULE 119830 rather than the EXE's HINSTANCE)
b) Try harder to unregister the window class, by trying it first in ProcessSingleton::Cleanup, which gets called before the fast shutdown path calls ExitProcess(). Also, use correct HMODULE to unregister.
c) Avoid any possibility of a race to create the message window when the Create() method is called from NotifyOtherProcessOrCreate() or from outside the class by moving the implementation of Create(), which was always called from the constructor, into the constructor and making Create() just return true or false based on the success of the work already done.
BUG=111361
Review URL: http://codereview.chromium.org/9121046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121480 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util_unittest.cc')
-rw-r--r-- | base/process_util_unittest.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index c37de36..23f9940 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -184,6 +184,25 @@ TEST_F(ProcessUtilTest, GetProcId) { EXPECT_NE(id1, id2); base::CloseProcessHandle(handle); } + +TEST_F(ProcessUtilTest, GetModuleFromAddress) { + // Since the unit tests are their own EXE, this should be + // equivalent to the EXE's HINSTANCE. + // + // kExpectedKilledExitCode is a constant in this file and + // therefore within the unit test EXE. + EXPECT_EQ(::GetModuleHandle(NULL), + base::GetModuleFromAddress( + const_cast<int*>(&kExpectedKilledExitCode))); + + // Any address within the kernel32 module should return + // kernel32's HMODULE. Our only assumption here is that + // kernel32 is larger than 4 bytes. + HMODULE kernel32 = ::GetModuleHandle(L"kernel32.dll"); + HMODULE kernel32_from_address = + base::GetModuleFromAddress(reinterpret_cast<DWORD*>(kernel32) + 1); + EXPECT_EQ(kernel32, kernel32_from_address); +} #endif #if !defined(OS_MACOSX) |