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

Side by Side Diff: base/win/wrapped_window_proc.h

Issue 10315012: Added base::win::InitializeWindowClass() wrapper to make sure that window classes are properly asso… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | « base/message_pump_win.cc ('k') | base/win/wrapped_window_proc.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Provides a way to handle exceptions that happen while a WindowProc is 5 // Provides a way to handle exceptions that happen while a WindowProc is
6 // running. The behavior of exceptions generated inside a WindowProc is OS 6 // running. The behavior of exceptions generated inside a WindowProc is OS
7 // dependent, but it is possible that the OS just ignores the exception and 7 // dependent, but it is possible that the OS just ignores the exception and
8 // continues execution, which leads to unpredictable behavior for Chrome. 8 // continues execution, which leads to unpredictable behavior for Chrome.
9 9
10 #ifndef BASE_WIN_WRAPPED_WINDOW_PROC_H_ 10 #ifndef BASE_WIN_WRAPPED_WINDOW_PROC_H_
11 #define BASE_WIN_WRAPPED_WINDOW_PROC_H_ 11 #define BASE_WIN_WRAPPED_WINDOW_PROC_H_
12 #pragma once 12 #pragma once
13 13
14 #include <windows.h> 14 #include <windows.h>
15 15
16 #include "base/base_export.h" 16 #include "base/base_export.h"
17 #include "base/string16.h"
17 18
18 namespace base { 19 namespace base {
19 namespace win { 20 namespace win {
20 21
21 // An exception filter for a WindowProc. The return value determines how the 22 // An exception filter for a WindowProc. The return value determines how the
22 // exception should be handled, following standard SEH rules. However, the 23 // exception should be handled, following standard SEH rules. However, the
23 // expected behavior for this function is to not return, instead of returning 24 // expected behavior for this function is to not return, instead of returning
24 // EXCEPTION_EXECUTE_HANDLER or similar, given that in general we are not 25 // EXCEPTION_EXECUTE_HANDLER or similar, given that in general we are not
25 // prepared to handle exceptions. 26 // prepared to handle exceptions.
26 typedef int (__cdecl *WinProcExceptionFilter)(EXCEPTION_POINTERS* info); 27 typedef int (__cdecl *WinProcExceptionFilter)(EXCEPTION_POINTERS* info);
27 28
28 // Sets the filter to deal with exceptions inside a WindowProc. Returns the old 29 // Sets the filter to deal with exceptions inside a WindowProc. Returns the old
29 // exception filter, if any. 30 // exception filter, if any.
30 // This function should be called before any window is created. 31 // This function should be called before any window is created.
31 BASE_EXPORT WinProcExceptionFilter SetWinProcExceptionFilter( 32 BASE_EXPORT WinProcExceptionFilter SetWinProcExceptionFilter(
32 WinProcExceptionFilter filter); 33 WinProcExceptionFilter filter);
33 34
34 // Calls the registered exception filter. 35 // Calls the registered exception filter.
35 BASE_EXPORT int CallExceptionFilter(EXCEPTION_POINTERS* info); 36 BASE_EXPORT int CallExceptionFilter(EXCEPTION_POINTERS* info);
36 37
38 // Initializes the WNDCLASSEX structure |*class_out| to be passed to
39 // RegisterClassEx() making sure that it is associated with the module
40 // containing the window procedure.
41 BASE_EXPORT void InitializeWindowClass(
42 WNDCLASSEX* class_out,
Sergey Ulanov 2012/05/03 18:07:14 Since this is an output parameter, shouldn't it be
alexeypa (please no reviews) 2012/05/03 18:10:55 Yes, indeed. I'll fix that.
43 const char16* class_name,
44 WNDPROC window_proc,
45 UINT style,
46 int class_extra,
47 int window_extra,
48 HCURSOR cursor,
49 HBRUSH background,
50 const char16* menu_name,
51 HICON large_icon,
52 HICON small_icon);
53
37 // Wrapper that supplies a standard exception frame for the provided WindowProc. 54 // Wrapper that supplies a standard exception frame for the provided WindowProc.
38 // The normal usage is something like this: 55 // The normal usage is something like this:
39 // 56 //
40 // LRESULT CALLBACK MyWinProc(HWND hwnd, UINT message, 57 // LRESULT CALLBACK MyWinProc(HWND hwnd, UINT message,
41 // WPARAM wparam, LPARAM lparam) { 58 // WPARAM wparam, LPARAM lparam) {
42 // // Do Something. 59 // // Do Something.
43 // } 60 // }
44 // 61 //
45 // ... 62 // ...
46 // 63 //
(...skipping 13 matching lines...) Expand all
60 rv = proc(hwnd, message, wparam, lparam); 77 rv = proc(hwnd, message, wparam, lparam);
61 } __except(CallExceptionFilter(GetExceptionInformation())) { 78 } __except(CallExceptionFilter(GetExceptionInformation())) {
62 } 79 }
63 return rv; 80 return rv;
64 } 81 }
65 82
66 } // namespace win 83 } // namespace win
67 } // namespace base 84 } // namespace base
68 85
69 #endif // BASE_WIN_WRAPPED_WINDOW_PROC_H_ 86 #endif // BASE_WIN_WRAPPED_WINDOW_PROC_H_
OLDNEW
« no previous file with comments | « base/message_pump_win.cc ('k') | base/win/wrapped_window_proc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698