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

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

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: CR feedback. 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
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 #include "base/win/wrapped_window_proc.h" 5 #include "base/win/wrapped_window_proc.h"
6 6
7 #include "base/atomicops.h" 7 #include "base/atomicops.h"
8 #include "base/logging.h"
9 #include "base/process_util.h"
8 10
9 namespace { 11 namespace {
10 12
11 base::win::WinProcExceptionFilter s_exception_filter = NULL; 13 base::win::WinProcExceptionFilter s_exception_filter = NULL;
12 14
13 } // namespace. 15 } // namespace.
14 16
15 namespace base { 17 namespace base {
16 namespace win { 18 namespace win {
17 19
18 WinProcExceptionFilter SetWinProcExceptionFilter( 20 WinProcExceptionFilter SetWinProcExceptionFilter(
19 WinProcExceptionFilter filter) { 21 WinProcExceptionFilter filter) {
20 subtle::AtomicWord rv = subtle::NoBarrier_AtomicExchange( 22 subtle::AtomicWord rv = subtle::NoBarrier_AtomicExchange(
21 reinterpret_cast<subtle::AtomicWord*>(&s_exception_filter), 23 reinterpret_cast<subtle::AtomicWord*>(&s_exception_filter),
22 reinterpret_cast<subtle::AtomicWord>(filter)); 24 reinterpret_cast<subtle::AtomicWord>(filter));
23 return reinterpret_cast<WinProcExceptionFilter>(rv); 25 return reinterpret_cast<WinProcExceptionFilter>(rv);
24 } 26 }
25 27
26 int CallExceptionFilter(EXCEPTION_POINTERS* info) { 28 int CallExceptionFilter(EXCEPTION_POINTERS* info) {
27 return s_exception_filter ? s_exception_filter(info) : 29 return s_exception_filter ? s_exception_filter(info) :
28 EXCEPTION_CONTINUE_SEARCH; 30 EXCEPTION_CONTINUE_SEARCH;
29 } 31 }
30 32
33 BASE_EXPORT void InitializeWindowClass(
34 const char16* class_name,
35 WNDPROC window_proc,
36 UINT style,
37 int class_extra,
38 int window_extra,
39 HCURSOR cursor,
40 HBRUSH background,
41 const char16* menu_name,
42 HICON large_icon,
43 HICON small_icon,
44 WNDCLASSEX* class_out) {
45 class_out->cbSize = sizeof(WNDCLASSEX);
dcheng 2012/05/04 19:40:31 Should we add a compile assert here so we don't fo
alexeypa (please no reviews) 2012/05/04 19:54:24 WNDCLASSEX is a public API. It is set in stone and
brettw 2012/05/04 20:00:55 I agree with no assert here.
46 class_out->style = style;
47 class_out->lpfnWndProc = window_proc;
48 class_out->cbClsExtra = class_extra;
49 class_out->cbWndExtra = window_extra;
50 class_out->hInstance = base::GetModuleFromAddress(window_proc);
51 class_out->hIcon = large_icon;
52 class_out->hCursor = cursor;
53 class_out->hbrBackground = background;
54 class_out->lpszMenuName = menu_name;
55 class_out->lpszClassName = class_name;
56 class_out->hIconSm = small_icon;
57
58 // Check if |window_proc| is valid.
59 DCHECK(class_out->hInstance != NULL);
60 }
61
31 } // namespace win 62 } // namespace win
32 } // namespace base 63 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698