diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 21:41:08 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-17 21:41:08 +0000 |
commit | 0c03b435f8457e8601c80f44a69a56d9f96a274a (patch) | |
tree | e681f3661ec27777c0d8c5d499c36ff1c43d1508 /views | |
parent | 03addd9009847497437ebe5466c164f50b93e990 (diff) | |
download | chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.zip chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.tar.gz chromium_src-0c03b435f8457e8601c80f44a69a56d9f96a274a.tar.bz2 |
Fix race conditions where an object's constructor uses PostTask on itself. This isn't safe since the posted task can execute before the constructor returns, leading to destruction of the object.
BUG=27944
Review URL: http://codereview.chromium.org/399016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32213 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/widget/aero_tooltip_manager.cc | 10 | ||||
-rw-r--r-- | views/widget/aero_tooltip_manager.h | 3 |
2 files changed, 9 insertions, 4 deletions
diff --git a/views/widget/aero_tooltip_manager.cc b/views/widget/aero_tooltip_manager.cc index 1d6693e..9899690 100644 --- a/views/widget/aero_tooltip_manager.cc +++ b/views/widget/aero_tooltip_manager.cc @@ -47,7 +47,8 @@ void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { initial_delay_ = static_cast<int>( ::SendMessage(tooltip_hwnd_, TTM_GETDELAYTIME, TTDT_INITIAL, 0)); } - initial_timer_ = new InitialTimer(this, initial_delay_); + initial_timer_ = new InitialTimer(this); + initial_timer_->Start(initial_delay_); } else { // Hide the tooltip and cancel any timers. ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); @@ -108,8 +109,11 @@ void AeroTooltipManager::OnTimer() { /////////////////////////////////////////////////////////////////////////////// // AeroTooltipManager::InitialTimer -AeroTooltipManager::InitialTimer::InitialTimer(AeroTooltipManager* manager, - int time) : manager_(manager) { +AeroTooltipManager::InitialTimer::InitialTimer(AeroTooltipManager* manager) + : manager_(manager) { +} + +void AeroTooltipManager::InitialTimer::Start(int time) { MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( this, &InitialTimer::Execute), time); } diff --git a/views/widget/aero_tooltip_manager.h b/views/widget/aero_tooltip_manager.h index dda3376..8cfca64 100644 --- a/views/widget/aero_tooltip_manager.h +++ b/views/widget/aero_tooltip_manager.h @@ -40,7 +40,8 @@ class AeroTooltipManager : public TooltipManagerWin { class InitialTimer : public base::RefCounted<InitialTimer> { public: - InitialTimer(AeroTooltipManager* manager, int time); + explicit InitialTimer(AeroTooltipManager* manager); + void Start(int time); void Disown(); void Execute(); |