From 192bae97dc70dae27bf536e76e127b0ca9572283 Mon Sep 17 00:00:00 2001 From: "cpu@chromium.org" Date: Wed, 21 Oct 2009 18:41:44 +0000 Subject: Added a static function pointer to cache the SetActiveURL pointer. - Windows only change. This is basically landing jschuh change http://codereview.chromium.org/293040 TEST=none BUG=25366 Review URL: http://codereview.chromium.org/313009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29677 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/child_process_logging_win.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'chrome/common/child_process_logging_win.cc') diff --git a/chrome/common/child_process_logging_win.cc b/chrome/common/child_process_logging_win.cc index 2221713..e8ddd02 100644 --- a/chrome/common/child_process_logging_win.cc +++ b/chrome/common/child_process_logging_win.cc @@ -11,19 +11,21 @@ #include "googleurl/src/gurl.h" namespace child_process_logging { - +// exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL. typedef void (__cdecl *MainSetActiveURL)(const wchar_t*); void SetActiveURL(const GURL& url) { - HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); - if (!exe_module) - return; - - MainSetActiveURL set_active_url = - reinterpret_cast( - GetProcAddress(exe_module, "SetActiveURL")); - if (!set_active_url) - return; + static MainSetActiveURL set_active_url = NULL; + // note: benign race condition on set_active_url. + if (!set_active_url) { + HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); + if (!exe_module) + return; + set_active_url = reinterpret_cast( + GetProcAddress(exe_module, "SetActiveURL")); + if (!set_active_url) + return; + } (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str()); } -- cgit v1.1