Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Side by Side Diff: chrome/common/child_process_logging_win.cc

Issue 313009: Added a static function pointer to cache the SetActiveURL pointer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/common/child_process_logging.h" 5 #include "chrome/common/child_process_logging.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/common/chrome_constants.h" 10 #include "chrome/common/chrome_constants.h"
11 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 12
13 namespace child_process_logging { 13 namespace child_process_logging {
14 14 // exported in breakpad_win.cc: void __declspec(dllexport) __cdecl SetActiveURL.
15 typedef void (__cdecl *MainSetActiveURL)(const wchar_t*); 15 typedef void (__cdecl *MainSetActiveURL)(const wchar_t*);
16 16
17 void SetActiveURL(const GURL& url) { 17 void SetActiveURL(const GURL& url) {
18 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName); 18 static MainSetActiveURL set_active_url = NULL;
19 if (!exe_module) 19 // note: benign race condition on set_active_url.
20 return; 20 if (!set_active_url) {
21 21 HMODULE exe_module = GetModuleHandle(chrome::kBrowserProcessExecutableName);
22 MainSetActiveURL set_active_url = 22 if (!exe_module)
23 reinterpret_cast<MainSetActiveURL>( 23 return;
24 GetProcAddress(exe_module, "SetActiveURL")); 24 set_active_url = reinterpret_cast<MainSetActiveURL>(
25 if (!set_active_url) 25 GetProcAddress(exe_module, "SetActiveURL"));
26 return; 26 if (!set_active_url)
27 return;
28 }
27 29
28 (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str()); 30 (set_active_url)(UTF8ToWide(url.possibly_invalid_spec()).c_str());
29 } 31 }
30 32
31 } // namespace child_process_logging 33 } // namespace child_process_logging
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698