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

Side by Side Diff: views/widget/aero_tooltip_manager.cc

Issue 399016: Fix race conditions where an object's constructor uses PostTask on itself. T... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "views/widget/aero_tooltip_manager.h" 5 #include "views/widget/aero_tooltip_manager.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <commctrl.h> 8 #include <commctrl.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 10
(...skipping 29 matching lines...) Expand all
40 UpdateTooltip(mouse_pos.x(), mouse_pos.y()); 40 UpdateTooltip(mouse_pos.x(), mouse_pos.y());
41 } 41 }
42 42
43 // Delay opening of the tooltip just in case the user moves their 43 // Delay opening of the tooltip just in case the user moves their
44 // mouse to another control. We defer this from Init because we get 44 // mouse to another control. We defer this from Init because we get
45 // zero if we query it too soon. 45 // zero if we query it too soon.
46 if (!initial_delay_) { 46 if (!initial_delay_) {
47 initial_delay_ = static_cast<int>( 47 initial_delay_ = static_cast<int>(
48 ::SendMessage(tooltip_hwnd_, TTM_GETDELAYTIME, TTDT_INITIAL, 0)); 48 ::SendMessage(tooltip_hwnd_, TTM_GETDELAYTIME, TTDT_INITIAL, 0));
49 } 49 }
50 initial_timer_ = new InitialTimer(this, initial_delay_); 50 initial_timer_ = new InitialTimer(this);
51 initial_timer_->Start(initial_delay_);
51 } else { 52 } else {
52 // Hide the tooltip and cancel any timers. 53 // Hide the tooltip and cancel any timers.
53 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); 54 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0);
54 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_); 55 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_);
55 return; 56 return;
56 } 57 }
57 } 58 }
58 59
59 void AeroTooltipManager::OnMouseLeave() { 60 void AeroTooltipManager::OnMouseLeave() {
60 last_mouse_x_ = last_mouse_y_ = -1; 61 last_mouse_x_ = last_mouse_y_ = -1;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (!tooltip_showing_) { 102 if (!tooltip_showing_) {
102 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); 103 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0);
103 ::SendMessage(tooltip_hwnd_, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y)); 104 ::SendMessage(tooltip_hwnd_, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y));
104 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, true, (LPARAM)&toolinfo_); 105 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, true, (LPARAM)&toolinfo_);
105 } 106 }
106 } 107 }
107 108
108 /////////////////////////////////////////////////////////////////////////////// 109 ///////////////////////////////////////////////////////////////////////////////
109 // AeroTooltipManager::InitialTimer 110 // AeroTooltipManager::InitialTimer
110 111
111 AeroTooltipManager::InitialTimer::InitialTimer(AeroTooltipManager* manager, 112 AeroTooltipManager::InitialTimer::InitialTimer(AeroTooltipManager* manager)
112 int time) : manager_(manager) { 113 : manager_(manager) {
114 }
115
116 void AeroTooltipManager::InitialTimer::Start(int time) {
113 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod( 117 MessageLoop::current()->PostDelayedTask(FROM_HERE, NewRunnableMethod(
114 this, &InitialTimer::Execute), time); 118 this, &InitialTimer::Execute), time);
115 } 119 }
116 120
117 void AeroTooltipManager::InitialTimer::Disown() { 121 void AeroTooltipManager::InitialTimer::Disown() {
118 manager_ = NULL; 122 manager_ = NULL;
119 } 123 }
120 124
121 void AeroTooltipManager::InitialTimer::Execute() { 125 void AeroTooltipManager::InitialTimer::Execute() {
122 if (manager_) 126 if (manager_)
123 manager_->OnTimer(); 127 manager_->OnTimer();
124 } 128 }
125 129
126 } // namespace views 130 } // namespace views
OLDNEW
« views/widget/aero_tooltip_manager.h ('K') | « views/widget/aero_tooltip_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698