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

Side by Side Diff: trunk/src/base/message_pump_win.h

Issue 15973003: Revert 201955 "Allow multiple base::MessagePumpForUI instances t..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « trunk/src/base/base.gypi ('k') | trunk/src/base/message_pump_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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/memory/scoped_ptr.h"
15 #include "base/message_pump.h" 15 #include "base/message_pump.h"
16 #include "base/message_pump_dispatcher.h" 16 #include "base/message_pump_dispatcher.h"
17 #include "base/message_pump_observer.h" 17 #include "base/message_pump_observer.h"
18 #include "base/observer_list.h" 18 #include "base/observer_list.h"
19 #include "base/time.h" 19 #include "base/time.h"
20 #include "base/win/message_window.h"
21 #include "base/win/scoped_handle.h" 20 #include "base/win/scoped_handle.h"
22 21
23 namespace base { 22 namespace base {
24 23
25 // MessagePumpWin serves as the base for specialized versions of the MessagePump 24 // MessagePumpWin serves as the base for specialized versions of the MessagePump
26 // for Windows. It provides basic functionality like handling of observers and 25 // for Windows. It provides basic functionality like handling of observers and
27 // controlling the lifetime of the message pump. 26 // controlling the lifetime of the message pump.
28 class BASE_EXPORT MessagePumpWin : public MessagePump { 27 class BASE_EXPORT MessagePumpWin : public MessagePump {
29 public: 28 public:
30 MessagePumpWin() : have_work_(0), state_(NULL) {} 29 MessagePumpWin() : have_work_(0), state_(NULL) {}
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // 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
120 // between the posting of each kMsgHaveWork message (i.e., after kMsgHaveWork 119 // between the posting of each kMsgHaveWork message (i.e., after kMsgHaveWork
121 // is peeked, and before a replacement kMsgHaveWork is posted). 120 // is peeked, and before a replacement kMsgHaveWork is posted).
122 // 121 //
123 // 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
124 // 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
125 // 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
126 // 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
127 // placed in the queue when new task arrive also awakens DoRunLoop. 126 // placed in the queue when new task arrive also awakens DoRunLoop.
128 // 127 //
129 class BASE_EXPORT MessagePumpForUI 128 class BASE_EXPORT MessagePumpForUI : public MessagePumpWin {
130 : public MessagePumpWin,
131 public win::MessageWindow::Delegate {
132 public: 129 public:
133 // A MessageFilter implements the common Peek/Translate/Dispatch code to deal 130 // A MessageFilter implements the common Peek/Translate/Dispatch code to deal
134 // with windows messages. 131 // with windows messages.
135 // This abstraction is used to inject TSF message peeking. See 132 // This abstraction is used to inject TSF message peeking. See
136 // TextServicesMessageFilter. 133 // TextServicesMessageFilter.
137 class BASE_EXPORT MessageFilter { 134 class BASE_EXPORT MessageFilter {
138 public: 135 public:
139 virtual ~MessageFilter() {} 136 virtual ~MessageFilter() {}
140 // Implements the functionality exposed by the OS through PeekMessage. 137 // Implements the functionality exposed by the OS through PeekMessage.
141 virtual BOOL DoPeekMessage(MSG* msg, 138 virtual BOOL DoPeekMessage(MSG* msg,
(...skipping 29 matching lines...) Expand all
171 // MessagePump methods: 168 // MessagePump methods:
172 virtual void ScheduleWork(); 169 virtual void ScheduleWork();
173 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time); 170 virtual void ScheduleDelayedWork(const TimeTicks& delayed_work_time);
174 171
175 // Applications can call this to encourage us to process all pending WM_PAINT 172 // Applications can call this to encourage us to process all pending WM_PAINT
176 // messages. This method will process all paint messages the Windows Message 173 // messages. This method will process all paint messages the Windows Message
177 // queue can provide, up to some fixed number (to avoid any infinite loops). 174 // queue can provide, up to some fixed number (to avoid any infinite loops).
178 void PumpOutPendingPaintMessages(); 175 void PumpOutPendingPaintMessages();
179 176
180 private: 177 private:
181 // win::MessageWindow::Delegate interface. 178 static LRESULT CALLBACK WndProcThunk(HWND window_handle,
182 virtual bool HandleMessage(HWND hwnd, 179 UINT message,
183 UINT message, 180 WPARAM wparam,
184 WPARAM wparam, 181 LPARAM lparam);
185 LPARAM lparam,
186 LRESULT* result) OVERRIDE;
187
188 virtual void DoRunLoop(); 182 virtual void DoRunLoop();
183 void InitMessageWnd();
189 void WaitForWork(); 184 void WaitForWork();
190 void HandleWorkMessage(); 185 void HandleWorkMessage();
191 void HandleTimerMessage(); 186 void HandleTimerMessage();
192 bool ProcessNextWindowsMessage(); 187 bool ProcessNextWindowsMessage();
193 bool ProcessMessageHelper(const MSG& msg); 188 bool ProcessMessageHelper(const MSG& msg);
194 bool ProcessPumpReplacementMessage(); 189 bool ProcessPumpReplacementMessage();
195 190
196 scoped_ptr<MessageFilter> message_filter_; 191 // Instance of the module containing the window procedure.
192 HMODULE instance_;
197 193
198 // A hidden message-only window. 194 // A hidden message-only window.
199 scoped_ptr<win::MessageWindow> window_; 195 HWND message_hwnd_;
196
197 scoped_ptr<MessageFilter> message_filter_;
200 }; 198 };
201 199
202 //----------------------------------------------------------------------------- 200 //-----------------------------------------------------------------------------
203 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a 201 // MessagePumpForIO extends MessagePumpWin with methods that are particular to a
204 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not 202 // MessageLoop instantiated with TYPE_IO. This version of MessagePump does not
205 // deal with Windows mesagges, and instead has a Run loop based on Completion 203 // deal with Windows mesagges, and instead has a Run loop based on Completion
206 // Ports so it is better suited for IO operations. 204 // Ports so it is better suited for IO operations.
207 // 205 //
208 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin { 206 class BASE_EXPORT MessagePumpForIO : public MessagePumpWin {
209 public: 207 public:
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 // This list will be empty almost always. It stores IO completions that have 387 // This list will be empty almost always. It stores IO completions that have
390 // not been delivered yet because somebody was doing cleanup. 388 // not been delivered yet because somebody was doing cleanup.
391 std::list<IOItem> completed_io_; 389 std::list<IOItem> completed_io_;
392 390
393 ObserverList<IOObserver> io_observers_; 391 ObserverList<IOObserver> io_observers_;
394 }; 392 };
395 393
396 } // namespace base 394 } // namespace base
397 395
398 #endif // BASE_MESSAGE_PUMP_WIN_H_ 396 #endif // BASE_MESSAGE_PUMP_WIN_H_
OLDNEW
« no previous file with comments | « trunk/src/base/base.gypi ('k') | trunk/src/base/message_pump_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698