summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 19:38:30 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 19:38:30 +0000
commita3153c47d3b5308e7a55c0924a0baa1a6e02dcd0 (patch)
treeb37c85641aef8df14c732e4b187444e040a11555 /chrome
parenta93e517bfe25f11b2c4cc7d69f386424b93a2efa (diff)
downloadchromium_src-a3153c47d3b5308e7a55c0924a0baa1a6e02dcd0.zip
chromium_src-a3153c47d3b5308e7a55c0924a0baa1a6e02dcd0.tar.gz
chromium_src-a3153c47d3b5308e7a55c0924a0baa1a6e02dcd0.tar.bz2
This CL adds macro used to track the creation and destruction
of HWNDs, in an attempt to detect potential double-delete. A double-delete of a HWND might be responsible for the crasher http://crbug.com/4714 Note: this CL was previously committed and reverted because it broke the sandbox integration module. Review URL: http://codereview.chromium.org/21032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9161 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/plugin_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc2
-rw-r--r--chrome/views/native_control.cc24
-rw-r--r--chrome/views/text_field.cc13
-rw-r--r--chrome/views/widget_win.cc3
5 files changed, 36 insertions, 9 deletions
diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc
index 0e06e3e..feab679 100644
--- a/chrome/browser/plugin_process_host.cc
+++ b/chrome/browser/plugin_process_host.cc
@@ -14,6 +14,7 @@
#include "base/path_service.h"
#include "base/process_util.h"
#include "base/thread.h"
+#include "base/win_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_plugin_browsing_context.h"
#include "chrome/browser/chrome_thread.h"
@@ -351,6 +352,7 @@ class CreateWindowTask : public Task {
MAKEINTATOM(window_class), 0,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
0, 0, 0, 0, parent_, 0, GetModuleHandle(NULL), 0);
+ TRACK_HWND_CREATION(window);
PluginProcessHostMsg_CreateWindow::WriteReplyParams(
reply_msg_, window);
@@ -372,6 +374,7 @@ class DestroyWindowTask : public Task {
virtual void Run() {
DestroyWindow(window_);
+ TRACK_HWND_DESTRUCTION(window_);
}
private:
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index 2c19e7e..f4c27dd 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -396,6 +396,7 @@ LRESULT RenderWidgetHostViewWin::OnCreate(CREATESTRUCT* create_struct) {
// Call the WM_INPUTLANGCHANGE message handler to initialize the input locale
// of a browser process.
OnInputLangChange(0, 0);
+ TRACK_HWND_CREATION(m_hWnd);
return 0;
}
@@ -413,6 +414,7 @@ void RenderWidgetHostViewWin::OnActivate(UINT action, BOOL minimized,
void RenderWidgetHostViewWin::OnDestroy() {
ResetTooltip();
TrackMouseLeave(false);
+ TRACK_HWND_DESTRUCTION(m_hWnd);
}
void RenderWidgetHostViewWin::OnPaint(HDC dc) {
diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc
index 3c0e8d0..1490f27 100644
--- a/chrome/views/native_control.cc
+++ b/chrome/views/native_control.cc
@@ -79,16 +79,20 @@ class NativeControlContainer : public CWindowImpl<NativeControlContainer,
private:
LRESULT OnCreate(LPCREATESTRUCT create_struct) {
+ TRACK_HWND_CREATION(m_hWnd);
+
control_ = parent_->CreateNativeControl(m_hWnd);
+ TRACK_HWND_CREATION(control_);
+
FocusManager::InstallFocusSubclass(control_, parent_);
- if (parent_->NotifyOnKeyDown()) {
- // We subclass the control hwnd so we get the WM_KEYDOWN messages.
- WNDPROC original_handler =
- win_util::SetWindowProc(control_,
- &NativeControl::NativeControlWndProc);
- SetProp(control_, kHandlerKey, original_handler);
- SetProp(control_, kNativeControlKey , parent_);
- }
+
+ // We subclass the control hwnd so we get the WM_KEYDOWN messages.
+ WNDPROC original_handler =
+ win_util::SetWindowProc(control_,
+ &NativeControl::NativeControlWndProc);
+ SetProp(control_, kHandlerKey, original_handler);
+ SetProp(control_, kNativeControlKey , parent_);
+
::ShowWindow(control_, SW_SHOW);
return 1;
}
@@ -121,6 +125,7 @@ class NativeControlContainer : public CWindowImpl<NativeControlContainer,
void OnDestroy() {
if (parent_)
parent_->OnDestroy();
+ TRACK_HWND_DESTRUCTION(m_hWnd);
}
void OnContextMenu(HWND window, const CPoint& location) {
@@ -363,7 +368,7 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, UINT message,
static_cast<NativeControl*>(GetProp(window, kNativeControlKey));
DCHECK(native_control);
- if (message == WM_KEYDOWN) {
+ if (message == WM_KEYDOWN && native_control->NotifyOnKeyDown()) {
if (native_control->OnKeyDown(static_cast<int>(w_param)))
return 0;
} else if (message == WM_DESTROY) {
@@ -371,6 +376,7 @@ LRESULT CALLBACK NativeControl::NativeControlWndProc(HWND window, UINT message,
reinterpret_cast<WNDPROC>(original_handler));
RemoveProp(window, kHandlerKey);
RemoveProp(window, kNativeControlKey);
+ TRACK_HWND_DESTRUCTION(window);
}
return CallWindowProc(reinterpret_cast<WNDPROC>(original_handler), window,
diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc
index 79ee7b9..7c4e2fd 100644
--- a/chrome/views/text_field.cc
+++ b/chrome/views/text_field.cc
@@ -70,7 +70,9 @@ class TextField::Edit
MSG_WM_CHAR(OnChar)
MSG_WM_CONTEXTMENU(OnContextMenu)
MSG_WM_COPY(OnCopy)
+ MSG_WM_CREATE(OnCreate)
MSG_WM_CUT(OnCut)
+ MSG_WM_DESTROY(OnDestroy)
MESSAGE_HANDLER_EX(WM_IME_STARTCOMPOSITION, OnImeStartComposition)
MESSAGE_HANDLER_EX(WM_IME_COMPOSITION, OnImeComposition)
MSG_WM_KEYDOWN(OnKeyDown)
@@ -116,7 +118,9 @@ class TextField::Edit
void OnChar(TCHAR key, UINT repeat_count, UINT flags);
void OnContextMenu(HWND window, const CPoint& point);
void OnCopy();
+ LRESULT OnCreate(CREATESTRUCT* create_struct);
void OnCut();
+ void OnDestroy();
LRESULT OnImeStartComposition(UINT message, WPARAM wparam, LPARAM lparam);
LRESULT OnImeComposition(UINT message, WPARAM wparam, LPARAM lparam);
void OnKeyDown(TCHAR key, UINT repeat_count, UINT flags);
@@ -414,6 +418,11 @@ void TextField::Edit::OnCopy() {
}
}
+LRESULT TextField::Edit::OnCreate(CREATESTRUCT* create_struct) {
+ TRACK_HWND_CREATION(m_hWnd);
+ return 0;
+}
+
void TextField::Edit::OnCut() {
if (parent_->IsReadOnly())
return;
@@ -425,6 +434,10 @@ void TextField::Edit::OnCut() {
ReplaceSel(L"", true);
}
+void TextField::Edit::OnDestroy() {
+ TRACK_HWND_DESTRUCTION(m_hWnd);
+}
+
LRESULT TextField::Edit::OnImeStartComposition(UINT message,
WPARAM wparam,
LPARAM lparam) {
diff --git a/chrome/views/widget_win.cc b/chrome/views/widget_win.cc
index 7268a59..5e60e38 100644
--- a/chrome/views/widget_win.cc
+++ b/chrome/views/widget_win.cc
@@ -162,6 +162,8 @@ void WidgetWin::Init(HWND parent, const gfx::Rect& bounds,
window_style_, bounds.x(), bounds.y(), bounds.width(),
bounds.height(), parent, NULL, NULL, this);
DCHECK(hwnd_);
+ TRACK_HWND_CREATION(hwnd_);
+
// The window procedure should have set the data for us.
DCHECK(win_util::GetWindowUserData(hwnd_) == this);
@@ -932,6 +934,7 @@ LRESULT CALLBACK WidgetWin::WndProc(HWND window, UINT message,
if (!widget->ProcessWindowMessage(window, message, w_param, l_param, result))
result = DefWindowProc(window, message, w_param, l_param);
if (message == WM_NCDESTROY) {
+ TRACK_HWND_DESTRUCTION(window);
widget->hwnd_ = NULL;
widget->OnFinalMessage(window);
}