OLD | NEW |
---|---|
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_PUMP_WIN_H_ | 5 #ifndef BASE_MESSAGE_PUMP_WIN_H_ |
6 #define BASE_MESSAGE_PUMP_WIN_H_ | 6 #define BASE_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_pump.h" | 15 #include "base/message_pump.h" |
15 #include "base/message_pump_dispatcher.h" | 16 #include "base/message_pump_dispatcher.h" |
16 #include "base/message_pump_observer.h" | 17 #include "base/message_pump_observer.h" |
17 #include "base/observer_list.h" | 18 #include "base/observer_list.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 | 23 |
23 // MessagePumpWin serves as the base for specialized versions of the MessagePump | 24 // MessagePumpWin serves as the base for specialized versions of the MessagePump |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 // kMsgHaveWork messages. As a result, care is taken to do some peeking in | 118 // kMsgHaveWork messages. As a result, care is taken to do some peeking in |
118 // between the posting of each kMsgHaveWork message (i.e., after kMsgHaveWork | 119 // between the posting of each kMsgHaveWork message (i.e., after kMsgHaveWork |
119 // is peeked, and before a replacement kMsgHaveWork is posted). | 120 // is peeked, and before a replacement kMsgHaveWork is posted). |
120 // | 121 // |
121 // NOTE: Although it may seem odd that messages are used to start and stop this | 122 // NOTE: Although it may seem odd that messages are used to start and stop this |
122 // flow (as opposed to signaling objects, etc.), it should be understood that | 123 // flow (as opposed to signaling objects, etc.), it should be understood that |
123 // the native message pump will *only* respond to messages. As a result, it is | 124 // the native message pump will *only* respond to messages. As a result, it is |
124 // an excellent choice. It is also helpful that the starter messages that are | 125 // an excellent choice. It is also helpful that the starter messages that are |
125 // placed in the queue when new task arrive also awakens DoRunLoop. | 126 // placed in the queue when new task arrive also awakens DoRunLoop. |
126 // | 127 // |
128 class MessagePumpTSFInternal; | |
Yohei Yukawa
2012/08/15 09:10:49
Any ideas for this class name?
yoichio
2012/08/16 02:33:04
Done.
| |
129 | |
127 class BASE_EXPORT MessagePumpForUI : public MessagePumpWin { | 130 class BASE_EXPORT MessagePumpForUI : public MessagePumpWin { |
128 public: | 131 public: |
129 // The application-defined code passed to the hook procedure. | 132 // The application-defined code passed to the hook procedure. |
130 static const int kMessageFilterCode = 0x5001; | 133 static const int kMessageFilterCode = 0x5001; |
131 | 134 |
132 MessagePumpForUI(); | 135 MessagePumpForUI(); |
133 virtual ~MessagePumpForUI(); | 136 virtual ~MessagePumpForUI(); |
134 | 137 |
135 // MessagePump methods: | 138 // MessagePump methods: |
136 virtual void ScheduleWork(); | 139 virtual void ScheduleWork(); |
137 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); | 140 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); |
138 | 141 |
139 // Applications can call this to encourage us to process all pending WM_PAINT | 142 // Applications can call this to encourage us to process all pending WM_PAINT |
140 // messages. This method will process all paint messages the Windows Message | 143 // messages. This method will process all paint messages the Windows Message |
141 // queue can provide, up to some fixed number (to avoid any infinite loops). | 144 // queue can provide, up to some fixed number (to avoid any infinite loops). |
142 void PumpOutPendingPaintMessages(); | 145 void PumpOutPendingPaintMessages(); |
143 | 146 |
144 private: | 147 private: |
145 static LRESULT CALLBACK WndProcThunk( | 148 static LRESULT CALLBACK WndProcThunk( |
146 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | 149 HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); |
147 virtual void DoRunLoop(); | 150 virtual void DoRunLoop(); |
148 void InitMessageWnd(); | 151 void InitMessageWnd(); |
149 void WaitForWork(); | 152 void WaitForWork(); |
150 void HandleWorkMessage(); | 153 void HandleWorkMessage(); |
151 void HandleTimerMessage(); | 154 void HandleTimerMessage(); |
152 bool ProcessNextWindowsMessage(); | 155 bool ProcessNextWindowsMessage(); |
153 bool ProcessMessageHelper(const MSG& msg); | 156 bool ProcessMessageHelper(const MSG& msg); |
154 bool ProcessPumpReplacementMessage(); | 157 bool ProcessPumpReplacementMessage(); |
155 | 158 bool MessagePumpForUI::PeekMessageInternal( |
Yohei Yukawa
2012/08/15 09:10:49
How about ProcessPeekMessage?
yoichio
2012/08/16 02:33:04
Done.
| |
159 MSG* msg, HWND hwnd, UINT wmin, UINT wmax, UINT wmsg); | |
Yohei Yukawa
2012/08/15 09:10:49
nit: indent.
yoichio
2012/08/16 02:33:04
Done.
| |
156 // Instance of the module containing the window procedure. | 160 // Instance of the module containing the window procedure. |
157 HMODULE instance_; | 161 HMODULE instance_; |
158 | 162 |
159 // A hidden message-only window. | 163 // A hidden message-only window. |
160 HWND message_hwnd_; | 164 HWND message_hwnd_; |
165 | |
166 scoped_ptr<MessagePumpTSFInternal> tsf_message_pump_; | |
161 }; | 167 }; |
162 | 168 |
163 //----------------------------------------------------------------------------- | 169 //----------------------------------------------------------------------------- |
164 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a | 170 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a |
165 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not | 171 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not |
166 // deal with Windows mesagges, and instead has a Run loop based on Completion | 172 // deal with Windows mesagges, and instead has a Run loop based on Completion |
167 // Ports so it is better suited for IO operations. | 173 // Ports so it is better suited for IO operations. |
168 // | 174 // |
169 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin { | 175 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin { |
170 public: | 176 public: |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 // This list will be empty almost always. It stores IO completions that have | 337 // This list will be empty almost always. It stores IO completions that have |
332 // not been delivered yet because somebody was doing cleanup. | 338 // not been delivered yet because somebody was doing cleanup. |
333 std::list<IOItem> completed_io_; | 339 std::list<IOItem> completed_io_; |
334 | 340 |
335 ObserverList<IOObserver> io_observers_; | 341 ObserverList<IOObserver> io_observers_; |
336 }; | 342 }; |
337 | 343 |
338 } // namespace base | 344 } // namespace base |
339 | 345 |
340 #endif // BASE_MESSAGE_PUMP_WIN_H_ | 346 #endif // BASE_MESSAGE_PUMP_WIN_H_ |
OLD | NEW |