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

Side by Side Diff: base/message_loop/message_pump_win.h

Issue 1156503005: Don't peek messages in the MessagePumpForUI class when we receive our kMsgHaveWork message. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent Created 5 years, 6 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ 5 #ifndef BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_
6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ 6 #define BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <list> 10 #include <list>
11 11
12 #include "base/base_export.h" 12 #include "base/base_export.h"
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_pump.h" 15 #include "base/message_loop/message_pump.h"
15 #include "base/message_loop/message_pump_dispatcher.h" 16 #include "base/message_loop/message_pump_dispatcher.h"
16 #include "base/observer_list.h" 17 #include "base/observer_list.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "base/win/scoped_handle.h" 19 #include "base/win/scoped_handle.h"
19 20
20 namespace base { 21 namespace base {
21 22
23 class Thread;
24
22 // MessagePumpWin serves as the base for specialized versions of the MessagePump 25 // MessagePumpWin serves as the base for specialized versions of the MessagePump
23 // for Windows. It provides basic functionality like handling of observers and 26 // for Windows. It provides basic functionality like handling of observers and
24 // controlling the lifetime of the message pump. 27 // controlling the lifetime of the message pump.
25 class BASE_EXPORT MessagePumpWin : public MessagePump { 28 class BASE_EXPORT MessagePumpWin : public MessagePump {
26 public: 29 public:
27 MessagePumpWin() : have_work_(0), state_(NULL) {} 30 MessagePumpWin() : have_work_(0), state_(NULL) {}
28 31
29 // Like MessagePump::Run, but MSG objects are routed through dispatcher. 32 // Like MessagePump::Run, but MSG objects are routed through dispatcher.
30 void RunWithDispatcher(Delegate* delegate, MessagePumpDispatcher* dispatcher); 33 void RunWithDispatcher(Delegate* delegate, MessagePumpDispatcher* dispatcher);
31 34
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 void DoRunLoop() override; 131 void DoRunLoop() override;
129 void InitMessageWnd(); 132 void InitMessageWnd();
130 void WaitForWork(); 133 void WaitForWork();
131 void HandleWorkMessage(); 134 void HandleWorkMessage();
132 void HandleTimerMessage(); 135 void HandleTimerMessage();
133 void RescheduleTimer(); 136 void RescheduleTimer();
134 bool ProcessNextWindowsMessage(); 137 bool ProcessNextWindowsMessage();
135 bool ProcessMessageHelper(const MSG& msg); 138 bool ProcessMessageHelper(const MSG& msg);
136 bool ProcessPumpReplacementMessage(); 139 bool ProcessPumpReplacementMessage();
137 140
141 // We spawn a worker thread to periodically post (3 ms) the kMsgHaveWork
142 // message to the UI message pump. This is to ensure that the main thread
143 // gets to process tasks and delayed tasks when there is no activity in the
144 // Windows message pump or when there is a nested modal loop (sizing/moving/
145 // drag drop/message boxes) etc.
146 void DoWorkerThreadRunLoop();
147
148 // This function is posted as part of a user mode APC to shutdown the worker
149 // thread when the main message pump is shutting down.
150 static void CALLBACK ShutdownWorkerThread(ULONG_PTR param);
151
138 // Atom representing the registered window class. 152 // Atom representing the registered window class.
139 ATOM atom_; 153 ATOM atom_;
140 154
141 // A hidden message-only window. 155 // A hidden message-only window.
142 HWND message_hwnd_; 156 HWND message_hwnd_;
157
158 // This thread is used to periodically wake up the main thread to process
159 // tasks.
160 scoped_ptr<base::Thread> ui_worker_thread_;
161
162 // Defaults to false. Set to true when the ui worker thread needs to be shut
163 // down.
164 bool exit_ui_worker_thread_;
143 }; 165 };
144 166
145 //----------------------------------------------------------------------------- 167 //-----------------------------------------------------------------------------
146 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a 168 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a
147 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not 169 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not
148 // deal with Windows mesagges, and instead has a Run loop based on Completion 170 // deal with Windows mesagges, and instead has a Run loop based on Completion
149 // Ports so it is better suited for IO operations. 171 // Ports so it is better suited for IO operations.
150 // 172 //
151 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin { 173 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin {
152 public: 174 public:
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // This list will be empty almost always. It stores IO completions that have 354 // This list will be empty almost always. It stores IO completions that have
333 // not been delivered yet because somebody was doing cleanup. 355 // not been delivered yet because somebody was doing cleanup.
334 std::list<IOItem> completed_io_; 356 std::list<IOItem> completed_io_;
335 357
336 ObserverList<IOObserver> io_observers_; 358 ObserverList<IOObserver> io_observers_;
337 }; 359 };
338 360
339 } // namespace base 361 } // namespace base
340 362
341 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_ 363 #endif // BASE_MESSAGE_LOOP_MESSAGE_PUMP_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_pump_win.cc » ('j') | base/message_loop/message_pump_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698